Just a small problem. Common one. [+Rep] -
Twinki1993 - 06.02.2012
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(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;
}
Re: Just a small problem. Common one. [+Rep] -
[ABK]Antonio - 06.02.2012
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
}
Re: Just a small problem. Common one. [+Rep] -
Twinki1993 - 06.02.2012
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
??
Re: Just a small problem. Common one. [+Rep] -
[ABK]Antonio - 06.02.2012
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
Re: Just a small problem. Common one. [+Rep] -
2KY - 06.02.2012
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;
}
Re: Just a small problem. Common one. [+Rep] -
Twinki1993 - 06.02.2012
Both not working.. Where should I move it.. OnPlayerStateChange?
Re: Just a small problem. Common one. [+Rep] -
2KY - 06.02.2012
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;
}
Re: Just a small problem. Common one. [+Rep] -
Twinki1993 - 06.02.2012
@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
Re: Just a small problem. Common one. [+Rep] -
2KY - 06.02.2012
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?
Re: Just a small problem. Common one. [+Rep] -
Twinki1993 - 06.02.2012
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