Timer rank spam - 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: Timer rank spam (
/showthread.php?tid=410757)
Timer rank spam -
stormchaser206 - 26.01.2013
I am tired of getting the spam in chat using my script's rank system.
Here is my code:
pawn Код:
public RankDetection(playerid)
{
if(PlayerInfo[playerid][Xp] == 0)
{
SendClientMessage(playerid, COLOR_GREEN, "You have been promoted to Private II!");
PlayAudioStreamForPlayer(playerid, "https://dl.dropbox.com/u/77376451/rankupmwffa.mp3");
return 0;
}
return 0;
}
I've tried OnPlayerUpdate, I have tried return 1. I don't get what the problem is. There are no errors, just it spams you in game.
Thanks for any help.
Re: Timer rank spam -
Infamous - 26.01.2013
Can you show us your timer? It's probably looping over and over.
Re: Timer rank spam -
DaRk_RaiN - 26.01.2013
Variable.
pawn Код:
public RankDetection(playerid)
{
if(PlayerInfo[playerid][Xp] == 0 && Detected[playerid] != 1 )
{
SendClientMessage(playerid, COLOR_GREEN, "You have been promoted to Private II!");
PlayAudioStreamForPlayer(playerid, "https://dl.dropbox.com/u/77376451/rankupmwffa.mp3");
Detected[playerid] = 1;
return 1;
}
return 1;
}
Re: Timer rank spam -
stormchaser206 - 26.01.2013
Infamouz,
It's called in OnPlayerConnect, but here is the line with SetTimerEx:
pawn Код:
rtimer = SetTimerEx("RankDetection", 1500, 1, "i", playerid);
I have a feeling it is because i set it to whenever it is equal to.
Re: Timer rank spam -
stormchaser206 - 26.01.2013
Thanks Dark_Rain, got it to work
Re: Timer rank spam -
Infamous - 26.01.2013
Well you could use the suggestion above although I would prefer to call the timer once every-time the players rank is set/increased.
Re: Timer rank spam -
stormchaser206 - 26.01.2013
Dark_Rain, how can i set it so that i can do it with more than one rank? Because the same code wouldnt work because it would be detected.
Re: Timer rank spam -
KingHual - 26.01.2013
Quote:
Originally Posted by stormchaser206
Dark_Rain, how can i set it so that i can do it with more than one rank? Because the same code wouldnt work because it would be detected.
|
Use a switch/case statement.
pawn Код:
switch(PlayerInfo[playerid][Xp])
{
case 20:
{
SendClientMessage(playerid, COLOR_GREEN, "You have been promoted to Private I!");
}
case 40:
{
SendClientMessage(playerid, COLOR_GREEN, "You have been promoted to Private II!");
}
//etc.
}
And I recommend not using any timers for that, just call the function whenever the score increases.
Re: Timer rank spam -
stormchaser206 - 26.01.2013
Quote:
Originally Posted by king_hual
Use a switch/case statement.
pawn Код:
switch(PlayerInfo[playerid][Xp]) { case 20: { SendClientMessage(playerid, COLOR_GREEN, "You have been promoted to Private I!"); } case 40: { SendClientMessage(playerid, COLOR_GREEN, "You have been promoted to Private II!"); } //etc. }
And I recommend not using any timers for that, just call the function whenever the score increases.
|
Could you explain more?
Re: Timer rank spam -
KingHual - 26.01.2013
Quote:
Originally Posted by stormchaser206
Could you explain more?
|
Explain what? The code or the suggestion?