SA-MP Forums Archive
freeze/unfreeze command - 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: freeze/unfreeze command (/showthread.php?tid=272224)



freeze/unfreeze command - phil_lendon - 27.07.2011

Before you say it i have looked around, no luck what i want is a /freeze command for strcmp and it works like
/freeze [id] and for the victims screen in big words It goes "Freeze Mofo!" And Ofc they cant move until /unfreeze so any help for /freeze and /unfreeze?


Re: freeze/unfreeze command - iPLEOMAX - 27.07.2011

TogglePlayerControllable();


Re: freeze/unfreeze command - Riddick94 - 27.07.2011

You wan't /freeze and /unfreeze commands on strcmp? why not in sscanf.. it's better than strcmp. Think.. : >


Re: freeze/unfreeze command - phil_lendon - 27.07.2011

I only understand strcmp


Re: freeze/unfreeze command - phil_lendon - 27.07.2011

i dont get sscanf also iPleao i dont get how to add the ID part to that.
crap double post.


Re: freeze/unfreeze command - iPLEOMAX - 27.07.2011

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;
}