lil question
#1

how can i make if players are in jail or in a deathmatch, they cannot use any commands!, admin could use only
Reply
#2

PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    if(
IsPlayerInArea(playerid/*MIN X*//*MIN Y*//*MAX X*//*MAX Y*/) && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid0xFF0000FF"You can't use any command here."); // CHANGE IsPlayerAdmin BY THE ADMIN VARIABLE
    // COMMANDS ..
    
return 0;
}

stock IsPlayerInArea(playeridFloat:XminFloat:YminFloat:XmaxFloat:Ymax)
{
    new 
Float:xFloat:yFloat:z;
    
GetPlayerPos(playeridxyz);
    if(
<= Xmin && <= Ymin && >= Xmax && >= Ymax) return 1;
    return 
0;

Reply
#3

how do i get the min x min y max x max y
Reply
#4

pawn Код:
//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.");
Reply
#5

Quote:
Originally Posted by iPLEOMAX
Посмотреть сообщение
pawn Код:
//On top of your script:
new bool:Jailed[MAX_PLAYERS];

//In your /jail command:
Jailed[theplayerid] = true;

//In /unjail command & OnPlayerDisconnect:
Jailed[theplayerid] = false;

//On top of all your commands:
if(Jailed[playerid]) return SendClientMessage(playerid, 0xFF0000FF, "You cannot use commands when you are in jail.");
is there another way because i have lots of commands :8
Reply
#6

Which command system do you use? strcmp, dcmd, zcmd or ycmd?

EDIT: I meant that you have to put the code only ONCE on top of all your commands.
Eaxmple:
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;
}
Reply
#7

i use zcmd
Reply
#8

You can also create a variable to determine whether the player is in jail or not and simply use it in each command. If the player is in jail, and the value of the variable is set to 1, then return a message saying you can't use that command!
Reply
#9

pawn Код:
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;
}
Simple.

// For kids: Replace COLOR_ERROR with color you want in 0xRRGGBBAA
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)