Returning to ID 0 for some reason...
#1

I was just wondering, this was working at one point, can somebody tell me why this is only working for ID 0?

pawn Код:
new string[128];
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            PlayerInfo[i][pCheck] = 1;
            CheckNumber[i] = 1000+random(8999);
            format(string, 128, "Type /signcheck %d to receive your paycheck.", CheckNumber[i]);
            SendClientMessageToAll(COLOR_LIGHTBLUE, string);
            format(string, sizeof(string), "~y~PayDay~n~~w~Paycheck");
            GameTextForPlayer(i, string, 5000, 1);
        }
    }
Reply
#2

I try this

pawn Код:
public PayCheck()
{
    new string[128];
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(PlayerInfo[i][pCheck] == 1)
            {
                CheckNumber[i] = 1000+random(8999);
                format(string, 128, "Type /signcheck %d to receive your paycheck.", CheckNumber[i]);
                SendClientMessageToAll(COLOR_LIGHTBLUE, string);
                format(string, sizeof(string), "~y~PayDay~n~~w~Paycheck");
                GameTextForPlayer(i, string, 5000, 1);
                return 1;
            }
        }
    }
    return 1;
}
And then it will give everyone a paycheck but say theres 3 people on. it will show that message 3 times, say there is 6 people on it will spam the message 6 times, it doesn't make any sense.
Reply
#3

http://pastebin.ca/2005021
Reply
#4

Thanks bcc, Ian Stuart btw.
Reply
#5

Okay well I tried your code, everytime I type /payday nothing happens, and only ID 0 is getting a paycheck, when I had it set up how i did on my last reply, it would give people a payday, but it would spam it....
Reply
#6

Your prior code was simply sending the message for ID 0 to everybody. Are you still halting the loop by returning?
Reply
#7

Well I removed the /signcheck system and replaced it with the original paycheck. Anyways what my question is. Why would the normal paycheck work and not the /signcheck message? Makes no sense.
Reply
#8

Because you have this in a loop.

pawn Код:
format(string, 128, "Type /signcheck %d to receive your paycheck.", CheckNumber[i]);
SendClientMessageToAll(COLOR_LIGHTBLUE, string);
The loop is running 499 times and the message will be sent to everyone everytime a player is online according to your code. What you need to quite simply do, is change

SendClientMessageToAll

to

SendClientMessageToPlayer(i,COLOR_LIGHTBLUE,string );
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)