Repeating message
#1

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".
Reply
#2

I guess its cause you are sending the message inside a loop?
Reply
#3

So how i can fix it?
Reply
#4

omg i think this is not face9000 ,,coz he is good scripter..anyone using his account
Reply
#5

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?
Reply
#6

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.
Reply
#7

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;
}
Reply
#8

Same thing.
Reply
#9

Bump.
Reply
#10

Don't forget to foward
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)