Command is crashing the server
#7

Alright, as you can see, the problem is somewhere between 2 and 3. To get the exact location, we can place debug prints after each function. I'll make it easy for you and do it for you.
pawn Код:
CMD:stats(playerid, params[])
{
    GetPlayerName(playerid, pName, sizeof(pName));

    if(IsPlayerConnected(playerid))
    {
        print("DEBUG: CMDSTART");
        new
            string[ 128 ],
            Age = PlayerInfo[ playerid ][ pAge ],
            Money = GetPlayerCash( playerid )
        ;
        print("DEBUG: 1");
        new Sex[20];
        if(PlayerInfo[ playerid ][ pSex ] == 1) { Sex = "Male"; }
        else if(PlayerInfo[ playerid ][ pSex ] == 2) { Sex = "Female"; }
        print("DEBUG: 2");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "_________________________STATISTICS OF %s_________________________, pName");
        print("DEBUG: 2.1");
        SendClientMessage(playerid, -1, "");
        print("DEBUG: 2.2");
        format(string, sizeof(string), "Name: {FFFFFF}%s {6FDD96}| Money: {FFFFFF}%d {6FDD96}| Age: {FFFFFF}%d {6FDD96}| Sex: {FFFFFF}%s", pName, Money, Age, Sex);
        print("DEBUG: 2.3");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
        print("DEBUG: 2.4");
        SendClientMessage(playerid, -1, "");
        print("DEBUG: 2.5");
        SendClientMessage(playerid, COLOR_LIGHTBLUE,"____________________________________________________________________");
        print("DEBUG:3");
    }
    return 1;
}
For bigger codes this solution wouldn't be fast enough, but I think that for this command it's alright to do it like this, since you'll find the exact crash location.
Now do the same as you did first, and I hope we get the exact crash location.

In advance, if it's the colors that cause the problem, do they work in other messages? If not, you might want to have a look at the color defines and redo it.

EDIT:

Quote:
Originally Posted by CutX
Посмотреть сообщение
do not use %s in SendClientMessage
pawn Код:
SendClientMessage(playerid, COLOR_LIGHTBLUE, "_________________________STATISTICS OF %s_________________________, pName");
of course it's crashing if you go using format Specifiers in SendClientMessage.
just do it like this
pawn Код:
format(string, sizeof(string), "_________________________STATISTICS OF %s_________________________",pName);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
i think they should add that tho the wiki in some warning-box-thingy
LOL, good point. I didn't even notice. I'll try and add it to the wiki.
Reply


Messages In This Thread
Command is crashing the server - by Twizted - 11.05.2014, 08:01
Re: Command is crashing the server - by Mriss - 11.05.2014, 08:03
Re: Command is crashing the server - by Jstylezzz - 11.05.2014, 08:03
Re: Command is crashing the server - by DaniceMcHarley - 11.05.2014, 08:05
Re: Command is crashing the server - by Twizted - 11.05.2014, 08:07
Re: Command is crashing the server - by CutX - 11.05.2014, 08:13
Re: Command is crashing the server - by Jstylezzz - 11.05.2014, 08:14
Re: Command is crashing the server - by Twizted - 11.05.2014, 08:20

Forum Jump:


Users browsing this thread: 1 Guest(s)