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; } |
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."); }
new Freezed[MAX_PLAYERS];
Freezed[playerid] = 1;
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;
}
create a global variable
On Top pawn Код:
pawn Код:
under /unfreeze command pawn Код:
|
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.
|
#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 |
#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;
}