Just a small problem. Common one. [+Rep]
#1

So I have no errors compiling the script but I have the problem.

When player reaches 11 score it starts spamming him with this. It gives his all this things every second....

Code:

PHP код:
public OnPlayerUpdate(playerid)
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;
    } 
Reply
#2

Add an if statement checking if a variable is a certain value...Like,

pawn Код:
new bool:gotMessage = false;
pawn Код:
if(gotMessage == false)
{
    //we continue and inside of it if they don't have it we set it to true so they do have it
}
Reply
#3

Would this stack for the money too?

Bump: Tested but not helping. It's still spamming with cash and messages.


Could it be because of the
PHP код:
return 1
??
Reply
#4

I don't recommend using onplayerupdate for this...you can put it else where..but this should work

pawn Код:
new bool:gotMoney[MAX_PLAYERS] = false;

public OnPlayerUpdate(playerid)
{
    if(GetPlayerScore(playerid) == 11 && gotMoney[playerid] == false)
    {
        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$!");
        gotMoney[playerid] = true;
    }
    return 1;
}

EDIT: Fixed a minor mistake
Reply
#5

Try putting it inside of a timer.

pawn Код:
new
    bool: CheckedScore[MAX_PLAYERS];

SetTimer("ScoreChecker", 1000, true);

forward ScoreChecker(playerid);
public ScoreChecker(playerid)
    {
        if(CheckedScore[playerid] == false) {
            return GivePlayerMoney(playerid, 1000);
        }
        else return 0;
    }
Reply
#6

Both not working.. Where should I move it.. OnPlayerStateChange?
Reply
#7

Add a new variable outside of a callback.. (global variable)
pawn Код:
new bool: ScoreChecked[MAX_PLAYERS] = false;
Start a timer in OnGameModeInit like so..

pawn Код:
SetTimer("ScoreChecker", 1000, true);
Then, anywhere OUTSIDE of a callback:

pawn Код:
forward ScoreChecker(playerid);

public ScoreChecker(playerid)
{
    if(CheckedScore[playerid] == false) {
        CheckedScore[playerid] = true;
        return GivePlayerMoney(playerid, 1000);
    }
    else return 1;
}
Reply
#8

@2KY I did how you told me to but still it's not working.

BUMP: This is my code. The normal one
http://pastebin.com/TSUkq8nm
Reply
#9

Quote:
Originally Posted by Twinki1993
Посмотреть сообщение
@2KY I did how you told me to but still it's not working.
I honestly don't see how.. Where did you add the new variable (the bool:...), did you set the timer in GameModeInit, and did you place the forward & public (for the timer) OUTSIDE of an existing callback?
Reply
#10

Well I did it how you told me too. Must be something else wrong then... If you want I can show you my whole script and if possible your try to put it inside and check.

Bump: here's my whole script code http://pastebin.com/9bsQNZq8
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)