SA-MP Forums Archive
TogglePlayerControllable - 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: TogglePlayerControllable (/showthread.php?tid=509813)



TogglePlayerControllable - Yasubo - 28.04.2014

How to make /freezeall

How to make /unfreezeall

Whats the code?


Re: TogglePlayerControllable - Luis- - 28.04.2014

You would use TogglePlayerControllable, and use sscanf. I'm not giving you the code though csuse how are you supposed to learn by someone else doing the work for you?


AW: TogglePlayerControllable - xerox8521 - 28.04.2014

Why would you need sscanf ? Simple plain for loop (or foreach if you have the include) and then use TogglePlayerControllable


Re: TogglePlayerControllable - PrivatioBoni - 28.04.2014

https://sampwiki.blast.hk/wiki/Loops

You wouldn't need sscanf really - if it's just like /freezeall.


Re: TogglePlayerControllable - Yasubo - 28.04.2014

Quote:
Originally Posted by PrivatioBoni
Посмотреть сообщение
https://sampwiki.blast.hk/wiki/Loops

You wouldn't need sscanf really - if it's just like /freezeall.
What is loop?


Re: TogglePlayerControllable - brent94 - 28.04.2014

Quote:
Originally Posted by Luis-
Посмотреть сообщение
You would use TogglePlayerControllable, and use sscanf. I'm not giving you the code though csuse how are you supposed to learn by someone else doing the work for you?
Exactly. I'm going to give him some beginner level code with simple enough comments, that also require no additional includes or plugins so hopefully he actually uses it to learn (at least I hope).

Yasubo, please take this code and try to learn from it. Modify it, add to it, take from it. You need to learn from the code to gain an understanding of it. Best of luck to you.

pawn Код:
#include <a_samp>

new bool:frozen;

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp("/freezeall", cmdtext, true))
    {
        if(frozen == true) // If 'frozen' equals 'true', then everyone is already frozen.
        {
            SendClientMessage(playerid, 0xFF0000FF, "Error: Everyone is already frozen!");
        }

        frozen = true; // Set 'frozen' to equal 'true'.

        for(new i = 0; i < MAX_PLAYERS; i ++) // Going through numbers 0 - 500. MAX_PLAYERS equals 500.
        {
            if(!IsPlayerConnected(i)) // Checking if the player(i) is connected.
            {
                TogglePlayerControllable(i, 0); // Freezing the player(i).
                // Each player must be frozen separately because there is no ToggleAllControllable function.
            }
        }

        SendClientMessage(playerid, 0xFFFFFFFF, "You have frozen everyone!");
    }

    if(!strcmp("/unfreezeall", cmdtext, true))
    {
        if(frozen == false) // If 'frozen' equals 'false', then no one is frozen.
        {
            SendClientMessage(playerid, 0xFF0000FF, "Error: Everyone is already unfrozen!");
        }

        frozen = false; // Set 'frozen' to equal 'false'.

        for(new i = 0; i < MAX_PLAYERS; i ++) // Going through numbers 0 - 500. MAX_PLAYERS equals 500.
        {
            if(!IsPlayerConnected(i)) // Checking if the player(i) is connected.
            {
                TogglePlayerControllable(i, 0); // Unfreezing the player(i).
                // Each player must be unfrozen separately because there is no ToggleAllControllable function.
            }
        }

        SendClientMessage(playerid, 0xFFFFFFFF, "You have unfrozen everyone!");
    }
    return 0;
}



Re: TogglePlayerControllable - IceBilizard - 28.04.2014

simple with zcmd and its faster use zcmd and foreach

like this

pawn Код:
CMD:freezeall(playerid, params[])
{
    if(PlayerInfo[playerid][AdminLevel] >= 3)//here you can admin level which you are using
    {
        foreach (new i : Player)
        {
            if(PlayerInfo[i][AdminLevel] < 1)//here you can admin level which you are using
            {
                TogglePlayerControllable(i, 0);
            }
        }
        new string[60];
        format(string,sizeof(string), "An Admin has frozen everyone");
        SendClientMessageToAll(COLOR_SYSTEM, string);
        return 1;
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "You are not authorized to use this command.");
        return 1;
    }
}
CMD:unfreezeall(playerid, params[])
{
    if(PlayerInfo[playerid][AdminLevel] >= 3)//here you can admin level which you are using
    {
        foreach (new i : Player)
        {
            if(PlayerInfo[i][AdminLevel] < 1)//here you can admin level which you are using
            {
                TogglePlayerControllable(i, 1);
            }
        }
        new string[60];
        format(string,sizeof(string), "An Admin has unfrozen everyone");
        SendClientMessageToAll(COLOR_SYSTEM, string);
        return 1;
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "You are not authorized to use this command.");
        return 1;
    }
}



Re: TogglePlayerControllable - Luis- - 28.04.2014

Didn't read it properly, thought it was for one player.