[HELP] Game Crash
#1

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
Reply
#2

Try this. http://pastebin.com/HujHN3Y3
Reply
#3

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

Well I would just suggest using dcmd.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)