TogglePlayerControlable please help me !
#1

Guys , how do i can make this TogglePLayerControlable to a players , example if im admin im gonna freeze player and unfreeze

Quote:

if(strcmp(cmdtext, "/freeze", true) == 0)
if(IsPlayerAdmin(playerid))
{
TogglePlayerControllable(playerid,0);
return 1;
}
// Unfreezes a player when they types /unfreezeme
if(strcmp(cmdtext, "/unfreeze", true) == 0)
if(IsPlayerAdmin(playerid))
{
TogglePlayerControllable(playerid,1);
return 1;
}

the problem is when i type /freeze i am freezing . so how to make that like this command /freeze [playerid] [reason]
and /unfreeze [playerid] .

i don't want with timer.

please help me and i will give REP++
Reply
#2

Код:
Try to use sscanf and zcmd
 CMD:freeze(playerid, params[])
{
new id, reason[100], string[500];
if(IsPlayerAdmin(playerid))
{
if(sscanf(params, "ds[100]", id, reason)) return SendClientMessage(playerid, WHITE, " command: /freeze [playerid] [reason]");
TogglePlayerControllable(id, 0);
format(string, sizeof(string), "[ admin ] %s has been frozen by %s for %s", GetName(id), GetName(playerid),    reason);
  SendClientMessageToAll(RED, string);
  return 1;
 }
else return SendClientMessage(playerid, RED, "[admcmd] This is an admin command, thus you are unable to use it.");
}
( UNTESTED! )
Reply
#3

okay bro thanks , i will give you REP+ if this works

but how to unfreeze? that what i said , i don't want with timer
Reply
#4

create a global variable
On Top
pawn Код:
new Freezed[MAX_PLAYERS];
In your freeze command, When you freeze someone add this
pawn Код:
Freezed[playerid] = 1;
And when un-freezing check
under /unfreeze command
pawn Код:
CMD:unfreeze(playerid, params[])
{
    new id;
    if(Freezed[playerid] == 1) //Means player is Frozen
    {
       
        TogglePlayerControlable(id, true); //Unfreeze player
    }
    else // Means player is not frozen
    {
        SendClientMessage(playerid, -1, "Player is not frozen");
    }
    return 1;
}
Note: This will not work, it's just example. So don't copy it.
Reply
#5

Quote:
Originally Posted by Rudy_
Посмотреть сообщение
create a global variable
On Top
pawn Код:
new Freezed[MAX_PLAYERS];
In your freeze command, When you freeze someone add this
pawn Код:
Freezed[playerid] = 1;
And when un-freezing check
under /unfreeze command
pawn Код:
CMD:unfreeze(playerid, params[])
{
    new id;
    if(Freezed[playerid] == 1) //Means player is Frozen
    {
       
        TogglePlayerControlable(id, true); //Unfreeze player
    }
    else // Means player is not frozen
    {
        SendClientMessage(playerid, -1, "Player is not frozen");
    }
    return 1;
}
Note: This will not work, it's just example. So don't copy it.
To be honest he doesn't really need to do that, he could easily just do the way I did it but reverse it to the other way around.
Reply
#6

Quote:
Originally Posted by Malicious
Посмотреть сообщение
To be honest he doesn't really need to do that, he could easily just do the way I did it but reverse it to the other way around.
There's no big difference, My way just let's you not Freeze a player who is already frozen and won't let you unfreeze someone that is not frozen. + using my way, you can create Both Freeze and unfreeze in only freeze command then you don't need unfreeze.
Reply
#7

hmm . i don't understand both of you , please give me a full script command including , includes that i need .

wait i got this script in ******

Quote:

#include <a_samp>
#include <zcmd>

#if defined FILTERSCRIPT

new Float:FX[MAX_PLAYERS], Float:FY[MAX_PLAYERS], Float:FZ[MAX_PLAYERS]; // X, Y, Z we will store the coordinates at when we freeze someone
new IsFrozen[MAX_PLAYERS]; // The variable we will use to check if a player is frozen or not
new playerb; // Definition for the player we're going to freeze, I like to keep it in public to avoid making new variable under each command

CMD:freeze(playerid, params[]) // ZCMD Start
{
if(sscanf(params, "u", playerb)) return SendClientMessage(playerid, 0xFFFFFFAA, "USAGE: /freeze [playerid]"); // SSCANF check if we entered an id or not
if(!IsPlayerConnected(playerb)) return SendClientMessage(playerid, 0xFFFFFFAA, "Invalid player id"); // Check if the player id we entered is valid
if(IsFrozen[playerb]) return SendClientMessage(playerid, 0xFFFFFFAA, "Player is already frozen."); // Check if the player is frozen already
IsFrozen[playerb] = 1; // Sets the player's frozen variable to 1
GetPlayerPos(playerb, FX[playerb], FY[playerb], FZ[playerb]); // Saves the player's coordinates to the variables we defined at the top
SendClientMessage(playerb, 0xFFFFFFAA, "You have been frozen."); // Sends a message to the player informing him about being frozen
return 1;
}

CMD:unfreeze(playerid, params[]) // ZCMD Start
{
if(sscanf(params, "u", playerb)) return SendClientMessage(playerid, 0xFFFFFFAA, "USAGE: /unfreeze [playerid]");// SSCANF check if we entered an id or not
if(!IsPlayerConnected(playerb)) return SendClientMessage(playerid, 0xFFFFFFAA, "Invalid player id"); // Check if the player id we entered is valid
if(!IsFrozen[playerb]) return SendClientMessage(playerid, 0xFFFFFFAA, "Player is not frozen."); // Check if the player is not frozen
IsFrozen[playerb] = 0; // Sets the player's frozen variable to 0
SendClientMessage(playerb, 0xFFFFFFAA, "You have been unfrozen."); // Sends a message to the player informing him about being unfrozen
return 1;
}
#endif

is this right?
Reply
#8

Not really...

pawn Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>

new IsFrozen[MAX_PLAYERS];

CMD:freeze(playerid, params[])
{
    new playerb;
    if(sscanf(params, "u", playerb)) return SendClientMessage(playerid, 0xFFFFFFAA, "USAGE: /freeze [playerid]"); // SSCANF check if we entered an id or not
    if(!IsPlayerConnected(playerb)) return SendClientMessage(playerid, 0xFFFFFFAA, "Invalid player id"); // Check if the player id we entered is valid
    if(IsFrozen[playerb]) return SendClientMessage(playerid, 0xFFFFFFAA, "Player is already frozen."); // Check if the player is frozen already
    IsFrozen[playerb] = 1; // Sets the player's frozen variable to 1
    SendClientMessage(playerb, 0xFFFFFFAA, "You have been frozen."); // Sends a message to the player informing him about being frozen
    return 1;
}

CMD:unfreeze(playerid, params[]) // ZCMD Start
{
    new playerb;
    if(sscanf(params, "u", playerb)) return SendClientMessage(playerid, 0xFFFFFFAA, "USAGE: /unfreeze [playerid]");// SSCANF check if we entered an id or not
    if(!IsPlayerConnected(playerb)) return SendClientMessage(playerid, 0xFFFFFFAA, "Invalid player id"); // Check if the player id we entered is valid
    if(!IsFrozen[playerb]) return SendClientMessage(playerid, 0xFFFFFFAA, "Player is not frozen."); // Check if the player is not frozen
    IsFrozen[playerb] = 0; // Sets the player's frozen variable to 0
    SendClientMessage(playerb, 0xFFFFFFAA, "You have been unfrozen."); // Sends a message to the player informing him about being unfrozen
    return 1;
}
Requires the following includes:
ZCMD - By Zeex (https://sampforum.blast.hk/showthread.php?tid=91354)
SSCANF - By ****** (https://sampforum.blast.hk/showthread.php?tid=120356)
Reply
#9

is that script can be used only for admins? then if normal players type it , message will be wrote as "You are not authorized to use this command".

you correct the script?
if you corrected it . thanks i will give you all REP+ if this works
Reply
#10

You need an admin system, Which saves if player is admin......
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)