SA-MP Forums Archive
Player variables dont reset - 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: Player variables dont reset (/showthread.php?tid=513892)



Player variables dont reset - Dusan01 - 18.05.2014

Hi guys, i have problem with player variables. When player connect his variable sets to 0 and when he disconnect also set to 0, and for example hes variable is 925 and that player disconect now, and when another player connect with that id his variable sets like on that player(925)?


Re: Player variables dont reset - PrivatioBoni - 18.05.2014

Show how you did it then lol


Re: Player variables dont reset - JFF - 18.05.2014

Yeah show the codes


Re: Player variables dont reset - Dusan01 - 18.05.2014

at the top of GM:
Код:
#undef MAX_PLAYERS
#define MAX_PLAYERS 200
new aduty[MAX_PLAYERS];
on player connect and disconnect:
Код:
aduty[playerid] = 0;
and that is variable for admin duty, and my sererver have 80-120 players and i connect to server as admin and i try /aduty and aduty only active when aduty is 0 and deactive when is 1, and when i type /aduty it dont response like that variable is seted to 0 or 1...


Re: Player variables dont reset - JFF - 18.05.2014

Show us the aduty command script


Re: Player variables dont reset - Dusan01 - 18.05.2014

Код:
CMD:aduty(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 1) return SCM(playerid, GRAD2, "{07C1F5}{FFFFFF} Nisi ovlascen!");
if(aduty[playerid] == 0)
{
if(PlayerInfo[playerid][pAdmin] >= 5)
{
new astring[126];
format(astring, sizeof(astring), "{07C1F5}{FFFFFF}Admin {07C1F5}%s {FFFFFF}Je sada na admin duznosti!",GetName(playerid));
ABroadCast(-1, astring, 4);
aduty[playerid] = 1;
SetPlayerColor(playerid, 0xFF0000FF);
SetPlayerSkin(playerid, 294);
return 1;
}
if(PlayerInfo[playerid][pAdmin] >= 1)
{
new astring[126];
format(astring, sizeof(astring), "{07C1F5}{FFFFFF}Admin {07C1F5}%s {FFFFFF}Je sada na admin duznosti!",GetName(playerid));
ABroadCast(-1, astring, 4);
aduty[playerid] = 1;
SetPlayerColor(playerid,0xFF0000FF);
SetPlayerSkin(playerid, 294);
return 1;
}
return 1;
}
if(aduty[playerid] == 1)
{
new astring[126];
format(astring, sizeof(astring), "{07C1F5}{FFFFFF}Admin {07C1F5}%s {FFFFFF}Vise nije na duznosti!",GetName(playerid));
ABroadCast(-1, astring, 4);
aduty[playerid] = 0;
SetPlayerColor(playerid,COLOR_GRAD2);
SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
return 1;
}
return 1;
}



Re: Player variables dont reset - Threshold - 18.05.2014

You just need to do aduty[playerid] = 0; under OnPlayerDisconnect..


Re: Player variables dont reset - Dusan01 - 19.05.2014

Quote:
Originally Posted by BenzoAMG
Посмотреть сообщение
You just need to do aduty[playerid] = 0; under OnPlayerDisconnect..
Yes i did that, but still sometims get bugged.... :/


Re: Player variables dont reset - RajatPawar - 19.05.2014

There's a difference between PVars and normal arrays! Your title is misleading.

Quote:
Originally Posted by Dusan01
Посмотреть сообщение
Yes i did that, but still sometims get bugged.... :/
If you set it EXPLICITLY to 0 under OnPlayerDisconnect, there is no way it can automatically be set to another value when a player connects, unless your script itself sets it. Add prints to debug.