Global Variable error. - 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: Global Variable error. (
/showthread.php?tid=538088)
Global Variable error. -
Gogeta101 - 19.09.2014
I have onduty command and when you go onduty your onduty variable is 1 but when you die it will be seted to 0 but after i die onduty varibale its still 1.
pawn Код:
new AdminDuty[MAX_PLAYERS];
public OnPlayerDeath(playerid, killerid, reason)
{
if(AdminDuty[playerid] == 1)
{
Delete3DTextLabel(DutyLabel[playerid]);
AdminDuty[playerid] = 0;
}
return 1;
}
command(onduty, playerid, params[])
{
if(Player[playerid][pAdmin] >= 1)
{
new sendername[MAX_PLAYERS];
new string[128];
SetPlayerHealth(playerid, 999999);
SetPlayerArmour(playerid, 999999);
GetPlayerName(playerid,sendername, sizeof(sendername));
format(string, sizeof(string),"Administrator %s is now onduty Admin",sendername);
SendClientMessageToAll(COLOR_PINK,string);
SetPlayerColor(playerid, COLOR_PINK);
SetPlayerSkin(playerid, 217);
GivePlayerWeapon(playerid, 38 , 999999);
AdminDuty[playerid] = 1;
DutyLabel[playerid] = Create3DTextLabel("Admin on duty. DO NOT ATTACK!", ONDUTY_COLOR, 0.0, 0.0, 0.0, 15.0, 0);
Attach3DTextLabelToPlayer(DutyLabel[playerid], playerid, 0.0, 0.0, 0.7);
}
else
{
SendClientMessage(playerid, COLOR_RED , "[SERVER]:You are not allowed to use this command");
}
return 1;
}
Re: Global Variable error. -
PMH - 19.09.2014
how u know it's still 1? i don't think there's any problem with the code u provided..
but try finding
and check whether u're setting it to 1 in any other callback e.g OnPlayerSpawn
Re: Global Variable error. -
Marricio - 19.09.2014
Is DutyLabel variable size set to MAX_PLAYERS?
Re: Global Variable error. -
Gogeta101 - 19.09.2014
Yes it is