Repeating message - 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: Repeating message (
/showthread.php?tid=591183)
Repeating message -
Face9000 - 09.10.2015
Hello, can someone tell me why this message is repeating multiple times?
Код:
public UpdateLmsTxd()
{
new LmsString[100];
format(LmsString,sizeof(LmsString),"Players Alive: ~r~%d",PlayersAlive);
TextDrawSetString(LmsTxd,LmsString);
if(PlayersAlive == 1)
{
foreach (new i : Player)
{
new pName[24], String[128];
GetPlayerName(i,pName,24);
format(String, sizeof(String), "{F2C80C}%s (%d) {FFFFFF}has won the {F2C80C}Last Man Standing game!", pName, i);
SendClientMessageToAll(-1, String);
format(String, sizeof(String), "~r~%s (%d) ~w~has won the ~r~Last Man Standing ~w~game!",pName, i);
GameTextForAll(String,5000,4);
CallRemoteFunction("LMS_REWARD","",i);
SetTimer("WaitChange",5000,0);
}
}
return 1;
}
The message is "bla bla has won last man standing".
Re: Repeating message -
Sjn - 09.10.2015
I guess its cause you are sending the message inside a loop?
Re: Repeating message -
Face9000 - 09.10.2015
So how i can fix it?
Re: Repeating message -
sanamalik400 - 09.10.2015
omg i think this is not face9000 ,,coz he is good scripter..anyone using his account
Re: Repeating message -
Face9000 - 09.10.2015
Is me, but sometimes easy things can fuck you up more than hard things lol. Sjn, i need to to use a loop because i need to extract the last player alive name's and id's...Should i remove the loop?
Re: Repeating message -
Infinity - 09.10.2015
Sorry, but that code makes no sense at all. First of all, of course the message is going to be repeated. For every player, you send a message to everyone on the server. So having 100 people online will result in 100 messages sent.
You say you want to get the name and ID of the last player alive. This code won't do that. You just print all names of all players when one player is left.
Re: Repeating message -
xVIP3Rx - 09.10.2015
pawn Код:
public UpdateLmsTxd()
{
new LmsString[32];
format(LmsString,sizeof(LmsString),"Players Alive: ~r~%d",PlayersAlive);
TextDrawSetString(LmsTxd,LmsString);
if(PlayersAlive == 1)
{
foreach (new i : Player)
{
if(IsPlayerInLastManStanding?(i))//ofcourse this isn't right, but you should have something to check whether a player is in the "Last Man Standing" or not
{
new pName[24], String[128];
GetPlayerName(i, pName,24);
format(String, sizeof(String), "{F2C80C}%s (%d) {FFFFFF}has won the {F2C80C}Last Man Standing game!", pName, i)
SendClientMessageToAll(-1, String);
format(String, sizeof(String), "~r~%s (%d) ~w~has won the ~r~Last Man Standing ~w~game!",pName, i);
GameTextForAll(String,5000,4);
CallRemoteFunction("LMS_REWARD","",i);
SetTimer("WaitChange",5000,0);
return 1;
}
}
}
return 1;
}
Re: Repeating message -
Face9000 - 09.10.2015
Same thing.
Re: Repeating message -
Face9000 - 12.10.2015
Bump.
Re: Repeating message -
jeffery30162 - 13.10.2015
Don't forget to foward