lil question - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: lil question (
/showthread.php?tid=271312)
lil question -
tanush - 23.07.2011
how can i make if players are in jail or in a deathmatch, they cannot use any commands!, admin could use only
Re: lil question -
Shadoww5 - 23.07.2011
PHP код:
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;
}
Re: lil question -
tanush - 24.07.2011
how do i get the min x min y max x max y
Re: lil question -
iPLEOMAX - 24.07.2011
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.");
Re: lil question -
tanush - 24.07.2011
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
Re: lil question -
iPLEOMAX - 24.07.2011
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;
}
Re: lil question -
tanush - 31.07.2011
i use zcmd
Re: lil question -
Kush - 31.07.2011
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!
Re: lil question -
LetsOWN[PL] - 31.07.2011
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