TogglePlayerControllable
#1

How to make /freezeall

How to make /unfreezeall

Whats the code?
Reply
#2

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

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

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

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

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

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)