Author Topic: syntax error  (Read 471 times)

halp? I can't find it!

Add-Ons/Script_Thirst/server.cs Line: 17 - Syntax error.

Code: [Select]
function thirstTick()
{
//Do stuff
needs();
needs_HUD();

//Reiterate
schedule(1000, 0, hungerTick);
}

function needs_HUD()
{
while(%i < clientGroup.getCount())
{
%client = clientgroup.getobject(%i);

commandToClient(%client, 'bottomPrint', "\c3Thirst: \c6" @ %client.thirst, 1);

%i++;
}
}

function needs()
{
while(%i < clientGroup.getCount())
{
%client = clientgroup.getobject(%i);

if(%client.thirst == 0)
{
%client.player.kill();
}
else
{
%client.thirst--;
}

%i++;
}
}

registerOutputEvent(GameConnection,AddNeeds,"list 25 50 75 100");

function GameConnection::AddNeeds(%client, %amnt)
{
%client.thirst += %amnt;

if(%client.thirst > 100)
{
%client.thirst = 100;
}
}

package thirst
{
function GameConnection::spawnPlayer(%client)
{
%client.thirst = 100;
Parent::spawnPlayer(%client);
}
};

activatePackage(thirst);

I'm not sure what the syntax error is but I'm going to point out numerous errors in your code.
1. "thirstTick" is re-scheduling hungerTick not thirstTick.
2. You're going 2 loops which are both going to lag the server, even one will, so you should only use one for both displaying ui and checking their thirst.
3. You're list is in a wrong format. Check out other events that use lists to see what to do.

kthx, this is my new code:
Code: [Select]
function thirstTick()
{
//Do stuff
needs();

//Reiterate
schedule(1000, 0, thirstTick);
}

function needs()
{
while(%i < clientGroup.getCount())
{
%client = clientgroup.getobject(%i);

if(%client.thirst == 0)
{
%client.player.kill();
}
else
{
%client.thirst--;
}
                commandToClient(%client, 'bottomPrint', "\c3Thirst: \c6" @ %client.thirst, 1);

%i++;
}
}

registerOutputEvent(GameConnection,AddNeeds,"list 25 0 50 1 75 2 100 3");

function GameConnection::AddNeeds(%client, %amnt)
{
%client.thirst += (%amnt + 1)*25;

if(%client.thirst > 100)
{
%client.thirst = 100;
}
}

package thirst
{
function GameConnection::spawnPlayer(%client)
{
%client.thirst = 100;
Parent::spawnPlayer(%client);
}
};

activatePackage(thirst);

Okay. Now the thing seems to work. Thanks.