how to disable all commands -
kbalor - 22.10.2013
Hi I would like to ask how I disabled all commands on character selection, except /admins or some other commands.
Coz I tried to use a command teleport and I teleported to that place while im in chacter selection and also to avoid getting bugged.
Re: how to disable all commands -
Threshold - 22.10.2013
pawn Code:
new bool:Spawned[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
Spawned[playerid] = false;
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
Spawned[playerid] = false;
return 1;
}
public OnPlayerSpawn(playerid)
{
Spawned[playerid] = true;
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
Spawned[playerid] = false;
return 1;
}
//Commands that you want to be disabled
CMD:mycommand1(playerid, params[])
{
if(Spawned[playerid] == false) return SendClientMessage(playerid, 0xFF0000FF, "You must be spawned to use this command.");
//rest of command
return 1;
}
CMD:mycommand2(playerid, params[])
{
if(Spawned[playerid] == false) return SendClientMessage(playerid, 0xFF0000FF, "You must be spawned to use this command.");
//rest of command
return 1;
}
//etc.
Re: how to disable all commands -
]Rafaellos[ - 22.10.2013
In case of ZCMD
pawn Code:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
if(Login[playerid] == 0)
{
SendClientMessage(playerid, -1, "You have to be logged in.");
return 0;
}
return 1;
}
Re: how to disable all commands -
Wizzy951 - 22.10.2013
There is mine
if(Logged[playerid] == 0) return SendClientMessage(playerid, -1, "You need to login before executing a command!");
Edit: uhm too late.
Re: how to disable all commands -
kbalor - 22.10.2013
Quote:
Originally Posted by BenzoAMG
pawn Code:
new bool:Spawned[MAX_PLAYERS];
public OnPlayerConnect(playerid) { Spawned[playerid] = false; return 1; }
public OnPlayerRequestClass(playerid, classid) { Spawned[playerid] = false; return 1; }
public OnPlayerSpawn(playerid) { Spawned[playerid] = true; return 1; }
public OnPlayerDeath(playerid, killerid, reason) { Spawned[playerid] = false; return 1; }
//Commands that you want to be disabled
CMD:mycommand1(playerid, params[]) { if(Spawned[playerid] == false) return SendClientMessage(playerid, 0xFF0000FF, "You must be spawned to use this command."); //rest of command return 1; }
CMD:mycommand2(playerid, params[]) { if(Spawned[playerid] == false) return SendClientMessage(playerid, 0xFF0000FF, "You must be spawned to use this command."); //rest of command return 1; }
//etc.
|
+rep brother. and mind if I ask if there is any shortcut for this coz I have more than 100+ commands. I just want to except the /admins and some other 2-3 commands.
Re: how to disable all commands -
Threshold - 22.10.2013
Yes, the second poster's code would work in the case of ZCMD. However, this will block pretty much ALL commands. However, let's say for example that you want players to be able to use /admins even if they aren't logged in.
ZCMD:
pawn Code:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
if(strcmp(cmdtext,"/admins",true) != 0)
{
if(Spawned[playerid] == false) return SendClientMessage(playerid, 0xFF0000FF, "You must be spawned to use this command");
}
return 1;
}
STRCMP:
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext,"/admins",true) != 0)
{
if(Spawned[playerid] == false) return SendClientMessage(playerid, 0xFF0000FF, "You must be spawned to use this command");
}
return 1;
}
Re: how to disable all commands -
kbalor - 22.10.2013
]Rafaellos[ and Wizzi: Thanks alot save you save my time.
I use this
Code:
if(pInfo[playerid][Spawned] == 0)
{
SendClientMessage(playerid, -1, "You have to be logged in.");
return 0;
}
I tried Logged but it didn't work. And I remember before the character selection players do login first. So I changed Logged to Spawned and Boom!! It works like a cute charm with butterfly wings.
+rep both
Re: how to disable all commands -
kbalor - 22.10.2013
Quote:
Originally Posted by BenzoAMG
Yes, the second poster's code would work in the case of ZCMD. However, this will block pretty much ALL commands. However, let's say for example that you want players to be able to use /admins even if they aren't logged in.
ZCMD:
pawn Code:
public OnPlayerCommandReceived(playerid, cmdtext[]) { if(strcmp(cmdtext,"/admins",true) != 0) { if(Spawned[playerid] == false) return SendClientMessage(playerid, 0xFF0000FF, "You must be spawned to use this command"); } return 1; }
STRCMP:
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[]) { if(strcmp(cmdtext,"/admins",true) != 0) { if(Spawned[playerid] == false) return SendClientMessage(playerid, 0xFF0000FF, "You must be spawned to use this command"); } return 1; }
|
Wow nice! Anyway as you said it will block all commands. But do you think is there any other way to exempt this /admins command somewhere here?
Code:
if(pInfo[playerid][Spawned] == 0)
{
SendClientMessage(playerid, -1, "You have to be logged in.");
return 0;
}
Re: how to disable all commands -
Threshold - 22.10.2013
There is a quicker way, yes.
pawn Code:
if(pInfo[playerid][Spawned] == 0)
{
if(strcmp(cmdtext,"/admins",true) == 0) return 1;
SendClientMessage(playerid, -1, "You have to be logged in.");
return 0;
}
Lets say you want to unblock /admins, /rules and the /help commands:
pawn Code:
if(pInfo[playerid][Spawned] == 0)
{
if(strcmp(cmdtext,"/admins",true) == 0) return 1;
if(strcmp(cmdtext,"/rules",true) == 0) return 1;
if(strcmp(cmdtext,"/help",true) == 0) return 1;
SendClientMessage(playerid, -1, "You have to be logged in.");
return 0;
}
OR:
pawn Code:
if(pInfo[playerid][Spawned] == 0)
{
if(strcmp(cmdtext,"/admins",true) == 0 || strcmp(cmdtext,"/rules",true) == 0 || strcmp(cmdtext,"/help",true) == 0) return 1;
SendClientMessage(playerid, -1, "You have to be logged in.");
return 0;
}
Re: how to disable all commands -
gotwarzone - 22.10.2013
Quote:
Originally Posted by BenzoAMG
There is a quicker way, yes.
pawn Code:
if(pInfo[playerid][Spawned] == 0) { if(strcmp(cmdtext,"/admins",true) == 0) return 1; SendClientMessage(playerid, -1, "You have to be logged in."); return 0; }
Lets say you want to unblock /admins, /rules and the /help commands:
pawn Code:
if(pInfo[playerid][Spawned] == 0) { if(strcmp(cmdtext,"/admins",true) == 0) return 1; if(strcmp(cmdtext,"/rules",true) == 0) return 1; if(strcmp(cmdtext,"/help",true) == 0) return 1; SendClientMessage(playerid, -1, "You have to be logged in."); return 0; }
OR:
pawn Code:
if(pInfo[playerid][Spawned] == 0) { if(strcmp(cmdtext,"/admins",true) == 0 || strcmp(cmdtext,"/rules",true) == 0 || strcmp(cmdtext,"/help",true) == 0) return 1; SendClientMessage(playerid, -1, "You have to be logged in."); return 0; }
|
Tried and of course it works!

Thank you! You really are helpful. Glad you understand me. With love <3 no homo.