23.07.2011, 22:05
how can i make if players are in jail or in a deathmatch, they cannot use any commands!, admin could use only
public OnPlayerCommandText(playerid, cmdtext[])
{
if(IsPlayerInArea(playerid, /*MIN X*/, /*MIN Y*/, /*MAX X*/, /*MAX Y*/) && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "You can't use any command here."); // CHANGE IsPlayerAdmin BY THE ADMIN VARIABLE
// COMMANDS ..
return 0;
}
stock IsPlayerInArea(playerid, Float:Xmin, Float:Ymin, Float:Xmax, Float:Ymax)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
if(x <= Xmin && y <= Ymin && x >= Xmax && y >= Ymax) return 1;
return 0;
}
//On top of your script:
new bool:Jailed[MAX_PLAYERS];
//In your /jail command:
Jailed[theplayerid] = true;
//In /unjail command & OnPlayerDisconnect:
Jailed[theplayerid] = false;
//In OnPlayerDisconnect:
Jailed[playerid] = false;
//On top of all your commands:
if(Jailed[playerid]) return SendClientMessage(playerid, 0xFF0000FF, "You cannot use commands when you are in jail.");
pawn Код:
|
public OnPlayerCommandText(playerid, cmdtext[])
{
if(Jailed[playerid]) return Send......//This top
if(!strcmp("/cmd".....
if(!strcmp("/help".....
if(!strcmp("/wow".....
if(!strcmp("/wtf".....
if(!strcmp("/hehe".....
if(!strcmp("/lol".....
if(!strcmp("/jail".....
return 0;
}
public OnPlayerCommandReceived(playerid, cmdtext[])
{
if(Condition) // Condition: example !IsPlayerAdmin, or something.. Try with enums.
{
SendClientMessage(playerid, COLOR_ERROR, " You can not use commands, because of Condition.");
return 0;
}
return 1;
}