SA-MP Forums Archive
[HELP] Game Crash - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] Game Crash (/showthread.php?tid=212798)



[HELP] Game Crash - Larsey123IsMe - 18.01.2011

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/smack", cmdtext, true, 6))
    {
        new targetid = strval(cmdtext[6]);
        new Float:x, Float:y, Float:z;

        new Float:health;
        GetPlayerHealth(targetid, health);

        new pName [MAX_PLAYER_NAME], tName [MAX_PLAYER_NAME], string [128];
        GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
        GetPlayerName(targetid, tName, MAX_PLAYER_NAME);
   
        if(string[playerid] > '9' || string[playerid] < '0') return SendClientMessage(playerid,COLOR_RED,"ID must be a number");
        if(cmdtext[6] == 0) return SendClientMessage(playerid,COLOR_RED,"USAGE: /smack <ID>");
        if(GetPlayerPos(targetid, x, y, z) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "Invalid ID");
       
        if(!IsPlayerNearPlayer(playerid, targetid, 2.0)) return SendClientMessage(playerid, 0xFFFFFFFF, "Not Near");

        if (health < 50.0)
        {
            format(string, sizeof(string), "%s(%d) has smacked %s(%d) to death",pName, playerid, tName, targetid);
            SendClientMessageToAll(0xFF0000FF, string);

            SetPlayerHealth(targetid, 0);
            return 1;
        }
        else
        {
            format(string, sizeof(string), "%s(%d) has smacked  %s(%d)",pName, playerid, tName, targetid);
            SendClientMessageToAll(0xFF0000FF, string);
            return 1;
        }
    }
The:
pawn Код:
if(string[playerid] > '9' || string[playerid] < '0') return SendClientMessage(playerid,COLOR_RED,"ID must be a number");
make my game crash if i do commands like:
/
/s
/sm
/sma
/smac

So? How to fix my crashing problem :S


Re: [HELP] Game Crash - Backwardsman97 - 18.01.2011

Try this. http://pastebin.com/HujHN3Y3


Re: [HELP] Game Crash - Larsey123IsMe - 18.01.2011

Quote:
Originally Posted by Backwardsman97
Посмотреть сообщение
Then it tells me "SERVER: Unknown Command." :S


Re: [HELP] Game Crash - Backwardsman97 - 18.01.2011

Well I would just suggest using dcmd.