/afk command, 4 errors - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /afk command, 4 errors (
/showthread.php?tid=459841)
/afk command, 4 errors -
Gecko75 - 24.08.2013
I made this command, however after I changed the AFK[MAX_PLAYERS] and put it into the command, it's giving me these errors.
Code:
Код:
CMD:afk(playerid, params[])
{
new sendername[MAX_PLAYER_NAME], string[128];
new PlayerText3D:AFK, Float:x, Float:y, Float:z;
else if(AFK[playerid] == 1)
{
GetPlayerName(playerid, sendername, sizeof(sendername));
sendername[strfind(sendername,"_")] = ' ';
format(string, sizeof(string), "[SERVER] {FFFFFF}%s is no longer AFK.", sendername,playerid);
SendClientMessageToAll(COLOR_YELLOW, string);
SetPlayerHealth(playerid,100);
SetPlayerArmour(playerid,0);
SetOriginalColor(playerid);
AFK[playerid] = 0;
DeletePlayer3DTextLabel(playerid, PlayerText3D:AFK);
TogglePlayerControllable(playerid, 1);
}
else
{
GetPlayerName(playerid, sendername, sizeof(sendername));
sendername[strfind(sendername,"_")] = ' ';
format(string, sizeof(string), "[SERVER] %s is now AFK.",sendername,playerid);
SendClientMessageToAll(COLOR_YELLOW, string);
SetPlayerHealth(playerid,1000000);
SetPlayerArmour(playerid,1000000);
SetPlayerColor(playerid,0x96008CFF);
AFK[playerid] = 1;
GetPlayerPos(playerid, Float:x, Float:y, Float:z);
AFK = CreatePlayer3DTextLabel(playerid,"[[ AFK ]]",COLOR_GREEN,Float:x,Float:y,Float:z,40.0);
TogglePlayerControllable(playerid, 0);
}
return 1;
}
Errors:
Код:
C:\Users\Scoot\Desktop\gecko\gamemodes\Gecko.pwn(1817) : error 029: invalid expression, assumed zero
C:\Users\Scoot\Desktop\gecko\gamemodes\Gecko.pwn(1817) : warning 215: expression has no effect
C:\Users\Scoot\Desktop\gecko\gamemodes\Gecko.pwn(1817) : error 001: expected token: ";", but found "if"
C:\Users\Scoot\Desktop\gecko\gamemodes\Gecko.pwn(1817) : error 028: invalid subscript (not an array or too many subscripts): "AFK"
C:\Users\Scoot\Desktop\gecko\gamemodes\Gecko.pwn(1817) : fatal error 107: too many error messages on one line
Line 1817:
Код:
else if(AFK[playerid] == 1)
Re: /afk command, 4 errors -
coole210 - 24.08.2013
Change else if to if.
Re: /afk command, 4 errors -
Gecko75 - 24.08.2013
still giving me errors.
Re: /afk command, 4 errors -
coole210 - 24.08.2013
Well, first of all.. You might want to make the 3D text label 'AFK' a global variable, with a MAX_PLAYERS size, because re-creating the same variable within a command will not delete the right text label.
Second,
pawn Код:
DeletePlayer3DTextLabel(playerid, PlayerText3D:AFK);
You don't need 'PlayerText3D:' in this case, only when creating the variable.
And third, what errors are you getting now?
Re: /afk command, 4 errors -
Gecko75 - 24.08.2013
Fixed, thanks.