Why this command crash the gamemode?
#1

Hello to everyone. I wanted to ask why this command does crash my gamemode! Thanks in advance.
pawn Код:
if(strcmp(cmd, "/vme", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(gPlayerLogged[playerid] == 0)
            {
                SendClientMessage(playerid, COLOR_GREY, " You're not logged in.!");
                return 1;
            }
            GetPlayerRPName(playerid, sendername, sizeof(sendername));
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[96];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USO: /vme [visual action]");
                return 1;
            }
            if(PlayerInfo[playerid][pMask] == 1)
            {
                format(string, sizeof(string), "> %s", result);
            }
            else
            {
                format(string, sizeof(string), "> %s", result);
            }
            SetPlayerChatBubble(playerid, string, COLOR_PURPLE, 30.0, 15000);
            SendClientMessage(playerid, COLOR_PURPLE, "> %s %s", sendername, result);
        }
        return 1;
    }
Reply
#2

Use this plugin: https://sampforum.blast.hk/showthread.php?tid=262796
Go into-game and use the command, when it crashes. Send the last log created by crashdetect to us here.
It'd be quicker and easier to us find the error.
Reply
#3

Ok! Here's the error...
Код:
[22:32:56] [debug] Server crashed while executing PLRP.amx
[22:32:56] [debug] AMX backtrace:
[22:32:56] [debug] #0 native SendClientMessage () [0046fba0] from samp-server.exe
[22:32:56] [debug] #1 0042c638 in public OnPlayerCommandText (0x00000002, 0x0120d62c) from PLRP.amx
[22:32:56] [debug] Native backtrace:
[22:32:56] [debug] #0 004975fc in ?? () from C:\Windows.old.000\Users\Crasn\Downloads\Ubuntu 2.4 iso\Ubuntu Install\ubuntu2.4.iso\readme\samp-server.exe
Reply
#4

Oooh, how didn't I see that! I'm sorry!

Replace this:
pawn Код:
SendClientMessage(playerid, COLOR_PURPLE, "> %s %s", sendername, result);
With this:
pawn Код:
new _string[128]; format(_string, sizeof(_string), "> %s %s", sendername, result);
SendClientMessage(playerid, COLOR_PURPLE, _string);
This should work now.
Reply
#5

Thank you very much! REP+!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)