Disable all Commands Except... -
kbalor - 13.07.2012
How can I disable all commands except.
This /w - weapons menu /v- vehicle menu /stats /pm and so on..
I have here an example where i want to enable those commands.
Code:
CMD:drag(playerid, params[])
{
if(!IsPlayerInAnyVehicle(playerid)){
SetPlayerPos(playerid, -2911.2407,-194.6217,2.7821);
CreateDynamicObject(4247, -3037.851074, -103.473968, 1.177714, 0.000000, 0.000000, 0.000000,1,-1,-1,300.0);//floor
SetPlayerFacingAngle(playerid, 0.0);
SetPlayerInterior(playerid, 0);
new string[128], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(string, sizeof(string), "{6666FF}(/drag) {00CCFF}%s {6666FF}has Teleported to Drag Area",pName);
SendClientMessageToAll(playerid, string);
SetPlayerVirtualWorld(playerid, 1);
}
else{
new veh = GetPlayerVehicleID(playerid);
LinkVehicleToInterior(veh, 0);
SetVehiclePos(veh, -2911.2407,-194.6217,2.7821);
SetVehicleZAngle(veh, 0.0);
SetPlayerPos(playerid, -2911.2407,-194.6217,2.7821);
CreateDynamicObject(4247, -3037.851074, -103.473968, 1.177714, 0.000000, 0.000000, 0.000000,1,-1,-1,300.0);//floor
new string[128], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(string, sizeof(string), "{6666FF}(/drag) {00CCFF}%s {6666FF}has Teleported to Drag Area",pName);
SendClientMessageToAll(playerid, string);
PutPlayerInVehicle(playerid, veh, 0);
SetVehicleVirtualWorld(veh, 1);
SetPlayerVirtualWorld(playerid, 1);
}
return SendClientMessage(playerid, 0xFF0000FF, "You have been teleported to Drag Arena");
}
Re: Disable all Commands Except... -
Roko_foko - 13.07.2012
make a variable that will show if the commands are disabled or not for each player.
pawn Code:
new bool:gCommandsDisabled[MAX_PLAYERS];
and on every command in the beginning put if(gCommandsDisabled[playerid]==false)return SendClientMessage(playerid,0xFF0000,"More luck next time!");
pawn Code:
OnPlayerCommandText(playerid,...)
{
if(strcmp("/suicide",cmdtext)==0)
{
if(gCommandsDisabled[playerid]==true)return SendClientMessage(playerid,0xFF0000FF,"More luck next time!");
//^^^^EDITED, was false, but have to be true
//....
}
to enable just
pawn Code:
gCommandsDisabled[playerid]==false;// EDITED - switched enabling/disabling
to disable
pawn Code:
gCommandsDisabled[playerid]=true;
Re: Disable all Commands Except... -
kbalor - 13.07.2012
Quote:
Originally Posted by Roko_foko
make a variable that will show if the commands are disabled or not.
new bool:gCommandsDisabled[MAX_PLAYERS];
and on every command in the beginning put if(gCommandsDisabled[playerid]==false)return SendClientMessage...
to enable just gCommandsDisabled[playerid]==true;
to disable gCommandsDisabled[playerid]=false;
|
Can you make a demo? so i have a pattern to continue without hesitation.
Re: Disable all Commands Except... -
Roko_foko - 13.07.2012
i have edited my first post
Re: Disable all Commands Except... -
kbalor - 13.07.2012
Quote:
Originally Posted by Roko_foko
i have edited my first post
|
im confused. So I can't use /suicide command everywhere?
Edit: What if i leave /drag and go to other place like /aa, Can suicide automatically enabled in /aa??
Re: Disable all Commands Except... -
Larceny - 13.07.2012
Are you using zcmd, right?
You can use this:
pawn Code:
public OnPlayerCommandReceived(playerid, cmdtext[])// ZCMD's callback.
{
//Example of condition \/-------------Example of command \/
if( IsPlayerLogged(playerid) == 0 && strcmp(cmdtext, "/login", true) != 0)
return SendClientMessage(playerid, -1, "You are not logged."), 0;
//--------------------Example of messange /\
return 1;
}
Re: Disable all Commands Except... -
Roko_foko - 13.07.2012
Quote:
Originally Posted by kbalor
im confused. So I can't use /suicide command everywhere?
Edit: What if i leave /drag and go to other place like /aa, Can suicide automatically enabled in /aa??
|
That depends on scripter(you). If you want to disable the commands after player go to some other place(or after they killed someone, or after they have been prisoned, or any other YOUR reason) via command (or entering check point, or idk... picking pickup) just put
pawn Code:
gCommandsDisabled[playerid]=true;
and they wont be able to use that commands.
for example I don't want player to /suicide after he uses command /teleport, but if really needed player can use command /sorry to enable commands:
pawn Code:
OnPlayerCommandText(playerid,cmdtext[])
{
if(strcmp(cmdtext,"/teleport")==0)
{
SetPlayerPos(playerid,0,1,2);
gCommandsDisabled[playerid]==true;
return 1;
}
if(strcmp("/suicide",cmdtext)==0)
{
if(gCommandsDisabled[playerid]==true)return SendClientMessage(playerid,0xFF0000FF,"More luck next time!");
SetPlayerHealth(playerid,0);
return 1;
}
if(strcmp("/sorry",cmdtext)==0)
{
gCommandsDisabled[playerid]==false;
return 1;
}
}
Re: Disable all Commands Except... -
kbalor - 14.07.2012
Quote:
Originally Posted by Roko_foko
That depends on scripter(you). If you want to disable the commands after player go to some other place(or after they killed someone, or after they have been prisoned, or any other YOUR reason) via command (or entering check point, or idk... picking pickup) just put
pawn Code:
gCommandsDisabled[playerid]=true;
and they wont be able to use that commands.
for example I don't want player to /suicide after he uses command /teleport, but if really needed player can use command /sorry to enable commands:
pawn Code:
OnPlayerCommandText(playerid,cmdtext[]) { if(strcmp(cmdtext,"/teleport")==0) { SetPlayerPos(playerid,0,1,2); gCommandsDisabled[playerid]==true; return 1; } if(strcmp("/suicide",cmdtext)==0) { if(gCommandsDisabled[playerid]==true)return SendClientMessage(playerid,0xFF0000FF,"More luck next time!"); SetPlayerHealth(playerid,0); return 1; } if(strcmp("/sorry",cmdtext)==0) { gCommandsDisabled[playerid]==false; return 1; } }
|
Thanks but i dont want player to type manual if they want to enable or disable their commands even I.
Okay to make it simple.
I only want to disable /t -teleport command in drag. If you can see on my first post.
If player tried to use /t- teleport a DIALOG_STYLE_MSGBOX will show "You can't use teleport while in Drag" "Leave" "Stay"
If player click Leave - He will die and respawn in different spawn place.
If player click stay - Dialog will close and he/she still in drag area.
Re: Disable all Commands Except... -
kbalor - 14.07.2012
Edit: You'll understand now.
Re: Disable all Commands Except... -
Roko_foko - 14.07.2012
pawn Code:
CMD:drag(playerid, params[])
{
if(!IsPlayerInAnyVehicle(playerid)){
SetPlayerPos(playerid, -2911.2407,-194.6217,2.7821);
CreateDynamicObject(4247, -3037.851074, -103.473968, 1.177714, 0.000000, 0.000000, 0.000000,1,-1,-1,300.0);//floor
SetPlayerFacingAngle(playerid, 0.0);
SetPlayerInterior(playerid, 0);
new string[128], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(string, sizeof(string), "{6666FF}(/drag) {00CCFF}%s {6666FF}has Teleported to Drag Area",pName);
SendClientMessageToAll(playerid, string);
SetPlayerVirtualWorld(playerid, 1);
}
else{
new veh = GetPlayerVehicleID(playerid);
LinkVehicleToInterior(veh, 0);
SetVehiclePos(veh, -2911.2407,-194.6217,2.7821);
SetVehicleZAngle(veh, 0.0);
SetPlayerPos(playerid, -2911.2407,-194.6217,2.7821);
CreateDynamicObject(4247, -3037.851074, -103.473968, 1.177714, 0.000000, 0.000000, 0.000000,1,-1,-1,300.0);//floor
new string[128], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(string, sizeof(string), "{6666FF}(/drag) {00CCFF}%s {6666FF}has Teleported to Drag Area",pName);
SendClientMessageToAll(playerid, string);
PutPlayerInVehicle(playerid, veh, 0);
SetVehicleVirtualWorld(veh, 1);
SetPlayerVirtualWorld(playerid, 1);
}
gCommandsDisabled[playerid]==true;//add this <-<-<-<-<-<-<-<-<-<
return SendClientMessage(playerid, 0xFF0000FF, "You have been teleported to Drag Arena");
}
pawn Code:
OnPlayerCommandText(playerid,cmdtext[])
{
if(strcmp(cmdtext,"/t")==0 && cmdtext[2]=='\0')
{
if(gCommandsDisabled[playerid]==true)
{
// Now show him the dialog
return 1:
}
//...
}
so after the command /drag is used, the /t command is not available for player.
Once you want to enable the command, for example: when player dies just put the gCOmmandsDisabled[playerid]=false;
pawn Code:
OnPlayerDeath(//blah blah)
{
gCOmmandsDisabled[playerid]=false;
//rest of the code
}
Re: Disable all Commands Except... -
kbalor - 14.07.2012
Quote:
Originally Posted by Roko_foko
pawn Код:
CMD:drag(playerid, params[]) { if(!IsPlayerInAnyVehicle(playerid)){ SetPlayerPos(playerid, -2911.2407,-194.6217,2.7821); CreateDynamicObject(4247, -3037.851074, -103.473968, 1.177714, 0.000000, 0.000000, 0.000000,1,-1,-1,300.0);//floor SetPlayerFacingAngle(playerid, 0.0); SetPlayerInterior(playerid, 0); new string[128], pName[MAX_PLAYER_NAME]; GetPlayerName(playerid, pName, MAX_PLAYER_NAME); format(string, sizeof(string), "{6666FF}(/drag) {00CCFF}%s {6666FF}has Teleported to Drag Area",pName); SendClientMessageToAll(playerid, string); SetPlayerVirtualWorld(playerid, 1); } else{ new veh = GetPlayerVehicleID(playerid); LinkVehicleToInterior(veh, 0); SetVehiclePos(veh, -2911.2407,-194.6217,2.7821); SetVehicleZAngle(veh, 0.0); SetPlayerPos(playerid, -2911.2407,-194.6217,2.7821); CreateDynamicObject(4247, -3037.851074, -103.473968, 1.177714, 0.000000, 0.000000, 0.000000,1,-1,-1,300.0);//floor new string[128], pName[MAX_PLAYER_NAME]; GetPlayerName(playerid, pName, MAX_PLAYER_NAME); format(string, sizeof(string), "{6666FF}(/drag) {00CCFF}%s {6666FF}has Teleported to Drag Area",pName); SendClientMessageToAll(playerid, string); PutPlayerInVehicle(playerid, veh, 0); SetVehicleVirtualWorld(veh, 1); SetPlayerVirtualWorld(playerid, 1); } gCommandsDisabled[playerid]==true;//add this <-<-<-<-<-<-<-<-<-< return SendClientMessage(playerid, 0xFF0000FF, "You have been teleported to Drag Arena");
}
pawn Код:
OnPlayerCommandText(playerid,cmdtext[]) { if(strcmp(cmdtext,"/t")==0 && cmdtext[2]=='\0') { if(gCommandsDisabled[playerid]==true) { // Now show him the dialog return 1: } //... }
so after the command /drag is used, the /t command is not available for player.
Once you want to enable the command, for example: when player dies just put the gCOmmandsDisabled[playerid]=false;
pawn Код:
OnPlayerDeath(//blah blah) { gCOmmandsDisabled[playerid]=false; //rest of the code }
|
Ohhh! now i clearly understand thanks.
After compiling i got this errors:
Read: The line error is in OnPlayerDeath
Код:
(7814) : error 017: undefined symbol "gCOmmandsDisabled"
(7814) : warning 215: expression has no effect
(7814) : error 001: expected token: ";", but found "]"
(7814) : error 029: invalid expression, assumed zero
(7814) : fatal error 107: too many error messages on one line
Then i try to remove the gCOmmandsDisabled[playerid]=false;. in OnplayerDeath
Now i got this error
Код:
(9449) : warning 203: symbol is never used: "zcmd_OnPlayerCommandText"
Here:
Код:
OnPlayerCommandText(playerid,cmdtext[])
{
if(strcmp(cmdtext,"/t")==0 && cmdtext[2]=='\0')
{
if(gCommandsDisabled[playerid]==true)
{
//Text dialog
return 1:
}
//...
}
Re: Disable all Commands Except... -
Mark™ - 14.07.2012
You forgot this :
pawn Код:
new bool:gCommandsDisabled[MAX_PLAYERS];
Re: Disable all Commands Except... -
Blunt - 14.07.2012
Or simply use this on your command line.
if(PlayerInfo[playerid][pDragged] == 1) return ShowPlayerDialog(DIALOG_ID, DIALOG_MSGBOX, "Message", "Would you like to continue being dragged or leave this position?", "Stay", "Leave");
Re: Disable all Commands Except... -
kbalor - 14.07.2012
Quote:
Originally Posted by Xtreme_playa
You forgot this :
pawn Код:
new bool:gCommandsDisabled[MAX_PLAYERS];
|
Same error:
Код:
(7814) : warning 215: expression has no effect
(7814) : error 001: expected token: ";", but found "]"
(7814) : error 029: invalid expression, assumed zero
(7814) : fatal error 107: too many error messages on one line
Error line:
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
gCOmmandsDisabled[playerid]=false; <------- THis one.
SendDeathMessage(killerid, playerid, reason);
GetPlayerSkin(playerid);
new Batz[45];
format(Batz, sizeof(Batz), "You were killed by %s", GetPName(killerid));
GameTextForPlayer(playerid,Batz, 4000,4);
format(Batz, sizeof(Batz), "You killed %s", GetPName(playerid));
GameTextForPlayer(killerid,Batz, 4000,4);
return 1;
}
i put this code new bool:gCommandsDisabled[MAX_PLAYERS]; in top of the script.
Re: Disable all Commands Except... -
Mark™ - 14.07.2012
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
gCommandsDisabled[playerid]=false; // you made a typo, it's gCommands not gCOmmands
SendDeathMessage(killerid, playerid, reason);
GetPlayerSkin(playerid);
new Batz[45];
format(Batz, sizeof(Batz), "You were killed by %s", GetPName(killerid));
GameTextForPlayer(playerid,Batz, 4000,4);
format(Batz, sizeof(Batz), "You killed %s", GetPName(playerid));
GameTextForPlayer(killerid,Batz, 4000,4);
return 1;
}
Re: Disable all Commands Except... -
kbalor - 14.07.2012
Quote:
Originally Posted by Xtreme_playa
pawn Код:
public OnPlayerDeath(playerid, killerid, reason) { gCommandsDisabled[playerid]=false; // you made a typo, it's gCommands not gCOmmands SendDeathMessage(killerid, playerid, reason); GetPlayerSkin(playerid); new Batz[45]; format(Batz, sizeof(Batz), "You were killed by %s", GetPName(killerid)); GameTextForPlayer(playerid,Batz, 4000,4); format(Batz, sizeof(Batz), "You killed %s", GetPName(playerid)); GameTextForPlayer(killerid,Batz, 4000,4); return 1; }
|
Ooops a mistake didn't see that. +rep And the last error after compiling.
(9450) : warning 203: symbol is never used: "zcmd_OnPlayerCommandText"
LOL but i dont have line 9450.
i think this is the problem
Код:
OnPlayerCommandText(playerid,cmdtext[])
{
if(strcmp(cmdtext,"/t")==0 && cmdtext[2]=='\0')
{
if(gCommandsDisabled[playerid]==true)
{
//Text dialog
return 1:
}
//...
}
Re: Disable all Commands Except... -
Mark™ - 14.07.2012
Press CTRL + F, put zcmd_OnPlayerCommandText in the search box, hit enter and you will locate something like this
pawn Код:
new zcmd_OnPlayerCommandText;
, delete that and re-compile.
Re: Disable all Commands Except... -
kbalor - 14.07.2012
Quote:
Originally Posted by Xtreme_playa
Press CTRL + F, put zcmd_OnPlayerCommandText in the search box, hit enter and you will locate something like this
pawn Код:
new zcmd_OnPlayerCommandText;
, delete that and re-compile.
|
I already did that. And still can't find that line.
Re: Disable all Commands Except... -
Mark™ - 14.07.2012
Quote:
Originally Posted by kbalor
I already did that. And still can't find that line.
|
You must have done something wrong, it always works. Check if you've made any typos again.
Re: Disable all Commands Except... -
Andi_Evandy - 14.07.2012
change
pawn Код:
OnPlayerCommandText(playerid,cmdtext[])
to:
pawn Код:
OnPlayerCommandReceived(playerid,cmdtext[])