#1

So I got one problem. I don't know why is it happening or I'm just stupid not to see cause but here it is.

Code:
pawn Код:
public AddPlayerRaceCount(playerid,place)
{
    printf("AddplayerRaceCount: playerid: %d, place: %d",playerid,place);
    //code
    switch(place1) //place1 is defined don't worry
    {
        case 1:
        {
            print("1");
            //code
            for(new i=0;i<MAX_PLAYERS;i++)
            {
                if(IsPlayerConnected(i))
                {
                    printf("player ID %d is here: bet id is %d and playerid(aka winner is %d)",i,Info[i][BetID],playerid);
                    if(Info[i][BetID] == playerid)
                    {
                        new amount = Info[i][BetAmount]*2;
                        format(msg,170,"BetSys: %s won $%d by betting on %s to win race!",PlayerName(i),amount,PlayerName(playerid));
                        SendClientMessageToAll(ORANGE,msg);
                        GivePlayerCash(i,amount);
                        print("Won bet");
                    }
                    print("restored vars");
                }
            }
            print("2");
//rest of code
And here is debug

Код:
[16:40:36] AddplayerRaceCount: playerid: 1, place: 2
[16:40:36] 1
[16:40:36] player ID 0 is here: bet id is 1 and playerid(aka winner is 1)
[16:40:36] Won bet
[16:40:36] restored vars
[16:40:36] player ID 1 is here: bet id is 1 and playerid(aka winner is 105)
[16:40:36] restored vars
[16:40:36] player ID 2 is here: bet id is 1 and playerid(aka winner is 105)
[16:40:36] restored vars
[16:40:36] 2
[16:40:36] 3
[16:40:36] 4
[16:40:36] end
3,4, end are prints till callback end.

As you can see playerid is good for i=0 in loop. But for i=1 in loop playerid becomes 105. Same for i=2 and so on. Any solution?
Reply
#2

is it IRC bots ;o if it is there is no !msg Sir D:
Reply
#3

msg is defined up //code before loop start.
Reply
#4

//code
switch(place1) //place1 is defined don't worry
{
case 1:
{
print("1");
//code

it isn't there bro
Reply
#5

You see where it says //code? //code replaces actual code that exists there which isn't important for you to see.
Reply
#6

Define msg
Reply
#7

//code is

new msg[50];
new place1 = place - 1;
if(place1 > 3 || place1 < 1) return 1;

Which can't help you. Problem is in loop. Not with message.
Reply
#8

Buffer overflow. Msg is 50 cells long, and you are allowing packing of 170 cells into it. Increase the size, or reduce allowed characters in format (second argument)
Reply
#9

Okey I see that. You sure it will cause playerid to change value? I can't test atm.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)