Author Topic: Variable is becoming null, no idea why.  (Read 1080 times)

Code: [Select]
if(!isObject(publicClient))
{
new AiConnection(publicClient) { BL_ID = 888888; };
publicClient.isAdmin = true;
publicClient.isSuperAdmin = true;
}

function GameConnection::getMinigame(%this)
{
if(!%this.minigame)
return 0;
else
return %this.minigame;
}

function MinigameSO::Stop(%this)
{
%members = %this.numMembers;

for(%i=0;%i<%members;%i++)
%client[%i] = %this.member[%i];

%this.endGame();

for(%i=0;%i<%members;%i++)
{
%client[%i].player.delete();
%client[%i].spawnPlayer();
}
}

function addMinigame(%id,%brickdamage,%building,%painting,%fallingdamage,%datablock,%points_breakbrick,%points_die,%points_killplayer,%points_killself,%respawntime,%selfdamage,%e0,%e1,%e2,%e3,%e4,%title,%vehicledamage,%weapondamage,%color,%timelimit)
{
%minigame = new ScriptObject(%id)
{
colorIdx = %color;
class = minigameSO;
numMembers = 0;

brickDamage = %brickdamage;
brickRespawnTime = 10000;
EnableBuilding = %building;
EnablePainting = %painting;
name = %id;
enableWand = 0;
fallingDamage = %fallingdamage;
inviteOnly = 0;

playerDataBlock = %datablock;
PlayersUseOwnBricks = 0;
Points_BreakBrick = %points_breakbrick;
Points_Die = %points_die;
Points_KillPlayer = %points_killplayer;
Points_KillSelf = %points_killself;
Points_PlantBrick = 0;
respawnTime = %respawntime;
SelfDamage = %selfdamage;

StartEquip0 = nameToID(%e0);
StartEquip1 = nameToID(%e1);
StartEquip2 = nameToID(%e2);
StartEquip3 = nameToID(%e3);
StartEquip4 = nameToID(%e4);

title = %title;
useAllPlayerBricks = 0;
useSpawnBricks = 0;
VehicleDamage = %vehicledamage;
vehicleRespawnTime = 0;
weaponDamage = %weapondamage;

spawnBricks = 0;
};

//BLOCKLAND YOU PIECE OF CRAP ugh
echo("addMinigame");
echo(%timelimit);
eval("$" @ %id @ "_TIMELIMIT = " @ %timelimit @ ";");
%spawns = 0;
%group = "BrickGroup_" @ getNumKeyID();
%correct_name = "_" @ %id @ "_SPAWN";
for(%i=0;%i<%group.getCount();%i++)
{
%brick = %group.getObject(%i);
echo("LOOKED AT BRICK" SPC %brick);

if(%brick.getName() $= %correct_name)
{
echo(%brick SPC "IS A SPAWN BRICK [IDX" SPC %spawns @ "]");
%minigame.spawnBrick[%spawns] = %brick;
%spawns++;
}
}
%minigame.spawnBricks = %spawns;
%minigame.schedule(100,setTimeLimit,%timelimit);
}

//KING OF THE HILL :: RAIDEN21
//addMinigame(_MG_ARCADE_KOTH,0,           0,        0,        0,             PlayerNoJet,0,                 0,          1,                 0,               10000,       1,          SwordItem,"", "", "", "", "King of the Hill (by Raiden21)",0,             1,            0,     300000);
//           (%id,            %brickdamage,%building,%painting,%fallingdamage,%datablock, %points_breakbrick,%points_die,%points_killplayer,%points_killself,%respawntime,%selfdamage,%e0,      %e1,%e2,%e3,%e4,%title,                          %vehicledamage,%weapondamage,%color,%timelimit)

package ArcadeSupportPackage
{
function Player::activateStuff(%player)
{
parent::activateStuff(%player);

echo(%player);
echo(%player.client);

%start = %player.getEyePoint();
%direction  = %player.getEyeVector();
%path = vectorScale(%direction,5);
%stop = vectorAdd(%start,%path);
%ray = containerRayCast(%start,%stop,$TypeMasks::All,%player);
%col = firstWord(%ray);

if(!isObject(%col))
return;
if(%col.getClassName() $= "fxDTSBrick" && %col.getName() $= "_MG_ARCADE_KOTH_JOIN")
{
if(!isObject(MG_ARCADE_KOTH))
addMinigame("MG_ARCADE_KOTH",0,0,0,0,PlayerNoJet,0,0,1,0,10000,1,SwordItem,"","","","","King of the Hill (by Raiden21)",0,1,0,"300000");

if(%col.stackBL_ID == getNumKeyID())
MG_ARCADE_KOTH.schedule(33,addMember,%player.client);
else
messageClient(%player.client,'',"ERROR: Brick is not owned by server owner! Cannot join this game.");
}
}

function MinigameSO::removeMember(%this,%client,%b,%c,%d)
{
parent::removeMember(%this,%client,%b,%c,%d);

if(!%client.player)
%client.spawnPlayer();
}

function GameConnection::spawnPlayer(%this,%a,%b,%c,%d)
{
parent::spawnPlayer(%this,%a,%b,%c,%d);

if(%this.getMinigame() !$= "-1")
{
%minigame = %this.getMinigame();
%spawn = getRandom(0,%minigame.spawnBricks);
%position = %minigame.spawnBrick[%spawn].getPosition();
%this.player.setTransform(getWords(%position,0,1) SPC getWord(%position,2) + 0.3);
}
}

function MinigameSO::reset(%this,%a,%b,%c,%d)
{
%this.respawnAll();
parent::reset(%this,%a,%b,%c,%d);

%this.started = getSimTime();
}

function MinigameSO::timeLimitTick(%this,%a,%b,%c,%d)
{
echo("timeLimitTick");
eval("%timelimit = $" @ %this.getName() @ "_TIMELIMIT;");

if(getSimTime() - %this.started > %timelimit)
parent::timeLimitTick(%this,%a,%b,%c,%d);
}
};
activatePackage(ArcadeSupportPackage);
addMinigame is where it's happening, and variable in question is %timelimit.
I tried setting 300000 to a string just to see and ofc it's still coming back as absolutely nothing.

This is for my Arcade server, for games that need their own minigame.

Where exactly are you setting the variable? At the moment, I don't see it being assigned a value at all.

%id,%brickdamage,%building,%painting,%fallingdamage,%datablock,%points_breakbrick,%points_die,%points_killplayer,%points_killself,%respawntime,%selfdamage,%e0,%e1,%e2,%e3,%e4,%title,%vehicledamage,%weapondamage,%color,%timelimit

I see more than 20 arguments here, don't you?

You can only have 20 arguments in a function.

You can only have 20 arguments in a function.
wow
that's dumb.

Thanks


use tab separated lists like this
I would use that, but it looks like it's meant for default minigames.

I'm trying to make something that will make minigames on-the-fly without me being there.

I would use that, but it looks like it's meant for default minigames.

I'm trying to make something that will make minigames on-the-fly without me being there.

Compress similar things: "%damageRule", "%startEquip", "%pointsRule" - that kind of thing.

Use a hash table psuedoarray, like this: $MGPreset_[%gamemode,%val]. That would condense the amount of arguments to 2. %gamemode and %val are seperated by underscores.

Alternatively, you could assign values to a SimObject and pass that on, but I recommend hashtables.

In both cases, you'd have to make owner values so you know who made what gamemode preset, or else people could edit others' gamemode presets.

The eval lines are not necessary.
eval("$" @ %id @ "_TIMELIMIT = " @ %timelimit @ ";"); ==> $TimeLimit_[%id] = %timelimit;
eval("%timelimit = $" @ %this.getName() @ "_TIMELIMIT;"); ==> %timelimit = $TimeLimit_[%this.getName()];
« Last Edit: December 31, 2013, 04:13:23 AM by Axo-Tak »

It's already solved and it's already working fine, thanks though. I no longer needed eval because %timelimit being blank was screwing with me until I realized it was blank.

Use a hash table psuedoarray, like this: $MGPreset_[%gamemode,%val]. That would condense the amount of arguments to 2. %gamemode and %val are seperated by underscores.

Alternatively, you could assign values to a SimObject and pass that on, but I recommend hashtables.

That has nothing to do with neither hash tables or pseudo-arrays, though..