SA-MP Forums Archive
Freeze CMD - 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)
+--- Thread: Freeze CMD (/showthread.php?tid=480139)



Freeze CMD - xHarshx - 09.12.2013

Hello guys I need a little help on making Freezing CMD that freeze's EVERYONE in the server, not one particular person.
In my RP script, I already made a cmd called: /freeze (it unfreezes' and freezes') but that only freezes one player like.../freeze 16 [16 = ID]. But I want to make a CMD called /freezeall, so that it can freeze everyone in the server and also I need a cmd to unfreeze all. I am a new beginner scripter, so please help me out!
Whos' ever help I find helpful, they get a +REP!


Re: Freeze CMD - Sublime - 09.12.2013

You first make a loop through all players (I'm using foreach for faster loop), and set TogglePlayerControllable to 0 all in a CMD. Eg;

pawn Код:
CMD:freezeall(playerid, params[])
{
    foreach (new i : Player)
    {
        TogglePlayerControllable(playerid, 0);
        SendClientMessage(playerid, -1, "You are freezed!");
    }
}
If you don't use foreach, then you use the for loop like eg;

pawn Код:
for (new i = 0; i != MAX_PLAYERS; ++i)
    {
        TogglePlayerControllable(playerid, 0);
        SendClientMessage(playerid, -1, "You are freezed!");
    }



Re: Freeze CMD - Ardendshy - 09.12.2013

Код:
for(new PlayerID = 0; PlayerID < GetMaxPlayers(); PlayerID++)
{
	TogglePlayerControllable(PlayeriD,0);
}
This code freeze all players at server.


Re: Freeze CMD - xHarshx - 09.12.2013

Sublime, I have a question, can you also add the part in my CMD where if you freeze everyone, it should display a message to everyone saying: AdmCmd: Administrator %s has frozen all players.
Thanks and most of it is what I wanted.


Re: Freeze CMD - Sublime - 09.12.2013

pawn Код:
CMD:freezeall(playerid, params[])
{
    foreach (new i : Player)
    {
        TogglePlayerControllable(playerid, 0);
       
        new name[MAX_PLAYER_NAME], string[128];
        GetPlayerName(playerid, name, sizeof(name));
        format(string, sizeof(string), "AdmCmd: Administrator %s has frozen all players.", name);
        SendClientMessageToAll(-1, string);
    }
}



Re: Freeze CMD - xHarshx - 09.12.2013

And Also a CMD to make everyone unfrozen. (/unfreezeall). and it should display a server message saying: "Administrator %s has unfrozen all players.". Sorry for the bugging :P


Re: Freeze CMD - xHarshx - 09.12.2013

ERRORS:
pawn Код:
F:\UP COMPUTER\HARSHPREET SINGH NIJHAR\SA-MP (SERVER)\CG-RP - LINUX\CG-RP\gamemodes\CG-RP.pwn(65920) : error 017: undefined symbol "foreach"
F:\UP COMPUTER\HARSHPREET SINGH NIJHAR\SA-MP (SERVER)\CG-RP - LINUX\CG-RP\gamemodes\CG-RP.pwn(65920) : error 029: invalid expression, assumed zero
F:\UP COMPUTER\HARSHPREET SINGH NIJHAR\SA-MP (SERVER)\CG-RP - LINUX\CG-RP\gamemodes\CG-RP.pwn(65920) : error 017: undefined symbol "i"
F:\UP COMPUTER\HARSHPREET SINGH NIJHAR\SA-MP (SERVER)\CG-RP - LINUX\CG-RP\gamemodes\CG-RP.pwn(65920) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.



Re: Freeze CMD - DavidLuango - 09.12.2013

Код:
CMD:unfreezeall(playerid, params[])
{
    foreach (new i : Player)
    {
        TogglePlayerControllable(playerid, 1);
        
        new name[MAX_PLAYER_NAME], string[128];
        GetPlayerName(playerid, name, sizeof(name));
        format(string, sizeof(string), "AdmCmd: Administrator %s has unfrozen all players.", name);
        SendClientMessageToAll(-1, string);
    }
}
and for foreach download foreach include https://sampforum.blast.hk/showthread.php?tid=92679
then do #include <foreach>
It will most likely happen to remove those errors.


Re: Freeze CMD - xHarshx - 09.12.2013

I did that already still the same errors.


Re: Freeze CMD - xHarshx - 09.12.2013

THe unfreeze CMD works but the freezeall cmd doesn't work.