Freeze CMD
#1

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

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!");
    }
Reply
#3

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

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.
Reply
#5

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);
    }
}
Reply
#6

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

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.
Reply
#8

Код:
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.
Reply
#9

I did that already still the same errors.
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)