Where do I actually store this uhm?
#1

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(playerid1000);
        
SendClientMessage(playeridCOLOR_LIGHTBLUE"<!>Congradulations! You have reached 10 score and you have became Private 2!");
        
SendClientMessage(playeridCOLOR_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 0Lplayerid MAX_PLAYERSLplayerid++) 
    {
        if (!
IsPlayerConnected(Lplayerid)) continue; 
        if (
TenScore[Lplayerid]) continue; 
        if (
GetPlayerScore(Lplayerid) >= 11)
        {
            
GivePlayerMoney(Lplayerid1000);
            
SendClientMessage(LplayeridCOLOR_LIGHTBLUE"<!>Congradulations! You have reached 10 score and you have became Private 2!");
            
SendClientMessage(LplayeridCOLOR_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(Lplayerid2000);
            
SendClientMessage(LplayeridCOLOR_LIGHTBLUE"<!>Congradulations! You have reached 20 score and you have became Private 2!");
            
SendClientMessage(LplayeridCOLOR_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;

Reply
#2

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)