freeze/unfreeze command
#6

Try this, not tested.

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256];
    new idx;
    cmd = strtok(cmdtext, idx);

    if(strcmp(cmd, "/freeze", true) == 0)
    {
        new tmp[32];
        tmp = strtok(cmdtext, idx);
        TogglePlayerControllable( strval(tmp), false );
        GameTextForPlayer( strval(tmp), "~r~Frozen!", 2000, 3);
        return 1;
    }
     
    if(strcmp(cmd, "/unfreeze", true) == 0)
    {
        new tmp[32];
        tmp = strtok(cmdtext, idx);
        TogglePlayerControllable( strval(tmp), true );
        GameTextForPlayer( strval(tmp), "~g~Unfrozen!", 2000, 3);
        return 1;
    }
   
    return 0;
}

//Place this at the end of your script.
//If you have one, no need then.
stock strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
Reply


Messages In This Thread
freeze/unfreeze command - by phil_lendon - 27.07.2011, 16:37
Re: freeze/unfreeze command - by iPLEOMAX - 27.07.2011, 16:41
Re: freeze/unfreeze command - by Riddick94 - 27.07.2011, 16:42
Re: freeze/unfreeze command - by phil_lendon - 27.07.2011, 16:43
Re: freeze/unfreeze command - by phil_lendon - 27.07.2011, 16:45
Re: freeze/unfreeze command - by iPLEOMAX - 27.07.2011, 17:11

Forum Jump:


Users browsing this thread: 3 Guest(s)