need help with an /afk cmd :) -
Tyler_Idy - 23.10.2009
up up up it says: forward afk(playerid);
if(strcmp(cmdtext,"/afk",true,10) == 0)
{
new Float:PH;
new afktimer;
afktimer = SetTimer("afk",30,true);
GetPlayerHealth(playerid,PH);
}
if(strcmp(cmdtext,"/ak"true,10) == 0)
{
KillTimer(afktimer);
TogglePlayerControllable(playerid,1);
Delete3DTextLabel(afktext);
}
return 0;
}
public afk(playerid)
{
new Float:PH, Float:PX, Float:PY, Float:PZ;
new afktext;
GetPlayerHealth(playerid,PH);
SetPlayerHealth(playerid,PH);
TogglePlayerControllable(playerid,0);
afktext = Create3DTextLabel("AFK",0xFE9D02FF,PX,PY,PZ+0.5,20 ,-1);
}
what is wrong? here are the errors...
C:\Users\Administrator\Desktop\Pawno 0.3\gamemodes\ala.pwn(212) : warning 204: symbol is assigned a value that is never used: "afktimer"
C:\Users\Administrator\Desktop\Pawno 0.3\gamemodes\ala.pwn(212 -- 215) : error 001: expected token: "-string end-", but found "-identifier-"
C:\Users\Administrator\Desktop\Pawno 0.3\gamemodes\ala.pwn(215) : warning 215: expression has no effect
C:\Users\Administrator\Desktop\Pawno 0.3\gamemodes\ala.pwn(215) : warning 215: expression has no effect
C:\Users\Administrator\Desktop\Pawno 0.3\gamemodes\ala.pwn(215) : error 001: expected token: ";", but found ")"
C:\Users\Administrator\Desktop\Pawno 0.3\gamemodes\ala.pwn(215) : error 029: invalid expression, assumed zero
C:\Users\Administrator\Desktop\Pawno 0.3\gamemodes\ala.pwn(215) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
4 Errors.
Re: need help with an /afk cmd :) -
Joe Staff - 23.10.2009
You don't need a timer in a /AFK command. Setting TogglePlayerControllable to 0 will freeze the player's position and health on its own. What you should do is force a player to stand still for 30 seconds with no interuptions (Change in health, position or key state) so the player can't abuse invulnerability.
Also you have placed your 'afktimer' inside of the callback, it has to be a global variable (outside of all callbacks).