Where do I actually store this uhm? - 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: Where do I actually store this uhm? (
/showthread.php?tid=316880)
Where do I actually store this uhm? -
Twinki1993 - 09.02.2012
Well, I've been trying to make that if player gets some score like 10, 11 dunno he will get awarded. I made a code but dunno where to store it. OnPlayerUpdate it will spam me a lot and I have something that it's not working tho.
OnPlayerUpdate
Original code:
PHP Code:
if(GetPlayerScore(playerid) == 11)
{
GivePlayerMoney(playerid, 1000);
SendClientMessage(playerid, COLOR_LIGHTBLUE, "<!>Congradulations! You have reached 10 score and you have became Private 2!");
SendClientMessage(playerid, COLOR_LIGHTBLUE, "<!>You have been awarded with 1000$!");
return 1;
}
Other code that I've been given.
PHP Code:
forward TimerTick();
public TimerTick()
{
for (new Lplayerid = 0; Lplayerid < MAX_PLAYERS; Lplayerid++)
{
if (!IsPlayerConnected(Lplayerid)) continue;
if (TenScore[Lplayerid]) continue;
if (GetPlayerScore(Lplayerid) >= 11)
{
GivePlayerMoney(Lplayerid, 1000);
SendClientMessage(Lplayerid, COLOR_LIGHTBLUE, "<!>Congradulations! You have reached 10 score and you have became Private 2!");
SendClientMessage(Lplayerid, COLOR_LIGHTBLUE, "<!>You have been awarded with 1000$!");
TenScore[Lplayerid] = true; //Set the variable as 'true' so it doesn't start spamming next time.
}
if (GetPlayerScore(Lplayerid) >= 21)
{
GivePlayerMoney(Lplayerid, 2000);
SendClientMessage(Lplayerid, COLOR_LIGHTBLUE, "<!>Congradulations! You have reached 20 score and you have became Private 2!");
SendClientMessage(Lplayerid, COLOR_LIGHTBLUE, "<!>You have been awarded with 2000$!");
TenScore[Lplayerid] = true; //Set the variable as 'true' so it doesn't start spamming next time.
}
}
return true;
}
Re: Where do I actually store this uhm? -
[ABK]Antonio - 09.02.2012
I would put it where you're setting scores, if you have mulitple places just make a stock then use that line wherever its setting
If you're set on OnPlayerUpdate, simply add a new bool like,
pawn Code:
new bool:gotMessage1[MAX_PLAYERS] = false,
bool:gotMessage2[MAX_PLAYERS] = false;
Then create an if statement inside of that checker like, if(GetPlayerScore(playerid) >= 11 && gotMessage1[playerid] == false) we would do stuff including setting gotmessage1 to true