how to disable all commands
#1

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.
Reply
#2

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.
Reply
#3

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;
}
Reply
#4

There is mine if(Logged[playerid] == 0) return SendClientMessage(playerid, -1, "You need to login before executing a command!");

Edit: uhm too late.
Reply
#5

Quote:
Originally Posted by BenzoAMG
View Post
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.
Reply
#6

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;
}
Reply
#7

]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
Reply
#8

Quote:
Originally Posted by BenzoAMG
View Post
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;
}
Reply
#9

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;
}
Reply
#10

Quote:
Originally Posted by BenzoAMG
View Post
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)