How to prohibit players from using commands [Pawn.CMD]
#1

How do I prohibit the player from using commands except admin in PawnCMD?
I tried code like this:

PHP код:
flags:sendtols(CMD_HELPER CMD_ADMIN);
CMD:sendtols(playeridparams[])
{
    new 
id;
    if(
sscanf(params,"u"id)) return SCM(playeridCOLOR_WHITE"USAGE: /sendtols [playerid/PartOfName]");
    if(
id != INVALID_PLAYER_ID)
    {
        
pInfo[playerid][pInterior] = 0;
        
SetPlayerInterior(id0);
        
SetPlayerVirtualWorld(id0);
           
SetPlayerPos(id1529.6, -1691.213.3);
           
SCM(idCOLOR_WHITE"   You have been teleported !");
    }
    else return 
SCM(playeridCOLOR_WHITE"Invalid player specified !");
    return 
1;
}
public 
OnPlayerCommandReceived(playeridcmd[], params[], flags)
{
    
printf("[Pawn.CMD] [%s]: %s %s"GetNameEx(playerid), cmdparams);
    if((
flags CMD_ADMIN) && pInfo[playerid][pAdmin] != 5)
    {
        
SCM(playeridCOLOR_WHITE"You don't have permission to use this command");
        return 
0;
    }
    if((
flags CMD_HELPER) && pInfo[playerid][pAdmin] != 3)
    {
        
SCM(playeridCOLOR_WHITE"You don't have permission to use this command");
        return 
0;
    }
    if((
flags CMD_USER) && pInfo[playerid][pAdmin] >= 0)
    {
        return 
1;
    }
    return 
1;
}
public 
OnPlayerCommandPerformed(playeridcmd[], params[], resultflags)
{
    if(
result == -1)
    {
        
SCM(playeridCOLOR_LIGHTGREEN"ERROR: Command not found! Use /help");
    }
    return 
1;

But in that code, all players can still use it. Can you help me?
Reply
#2

There is a better way to do this:

pawn Код:
if((flags & CMD_ADMIN) && pInfo[playerid][pAdmin] != 5 || flags & (CMD_HELPER) || pInfo[playerid][pAdmin] != 3) return SCM(playerid, COLOR_WHITE, "You don't have permission to use this command");
Placing that code in OnPlayerCommandReceived will prevent EVERYONE from using commands. All commands.

Just add the code above in a single command which you want to restrict and leave OnPlayerCommandReceived blank.
Reply
#3

check PAWN.CMD official page you will get it
Reply
#4

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
There is a better way to do this:

pawn Код:
if((flags & CMD_ADMIN) && pInfo[playerid][pAdmin] != 5 || flags & (CMD_HELPER) || pInfo[playerid][pAdmin] != 3) return SCM(playerid, COLOR_WHITE, "You don't have permission to use this command");
Placing that code in OnPlayerCommandReceived will prevent EVERYONE from using commands. All commands.

Just add the code above in a single command which you want to restrict and leave OnPlayerCommandReceived blank.
So it will be like this?

PHP код:
flags:sendtols(CMD_HELPER CMD_ADMIN);
CMD:sendtols(playeridparams[])
{
    if((
flags CMD_ADMIN) && pInfo[playerid][pAdmin] != || flags & (CMD_HELPER) || pInfo[playerid][pAdmin] != 3) return SCM(playeridCOLOR_WHITE"You don't have permission to use this command");
    new 
id;
    if(
sscanf(params,"u"id)) return SCM(playeridCOLOR_WHITE"USAGE: /sendtols [playerid/PartOfName]");
    if(
id != INVALID_PLAYER_ID)
    {
        
pInfo[playerid][pInterior] = 0;
        
SetPlayerInterior(id0);
        
SetPlayerVirtualWorld(id0);
           
SetPlayerPos(id1529.6, -1691.213.3);
           
SCM(idCOLOR_WHITE"   You have been teleported !");
    }
    else return 
SCM(playeridCOLOR_WHITE"Invalid player specified !");
    return 
1;

Quote:
Originally Posted by CaptainBoi
Посмотреть сообщение
check PAWN.CMD official page you will get it
Haha, I still don't understand, so I ask here xD
Reply
#5

Exactly. And i suggest you to switch to I-ZCMD, better and simple.
Reply
#6

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
Exactly. And i suggest you to switch to I-ZCMD, better and simple.
I tried using Pawn.CMD, because I was interested in the 21ms response speed
Reply
#7

You shouldn't care about the "21 ms response speed" if your commands are scripted in the most optimized way they should.

Ex: Using less size for cells, instead of doing:

pawn Код:
new string[256];
Just for showing a message like: "%s has connected to the server", you can reduce it to 50 cells.

Reduce your strings size and your code will work more smoothly than before.

Also I-CMD is the improved version of ZCMD, which supports aliases too:

pawn Код:
CMD:shout(playerid,params[])
{
     return cmd_s(playerid,params);
}
And IMHO, you don't need all that useless "flag" checks before and after the command:

pawn Код:
flags:sendtols(CMD_HELPER | CMD_ADMIN);
Useless.
Reply
#8

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
You shouldn't care about the "21 ms response speed" if your commands are scripted in the most optimized way they should.

Ex: Using less size for cells, instead of doing:

pawn Код:
new string[256];
Just for showing a message like: "%s has connected to the server", you can reduce it to 50 cells.

Reduce your strings size and your code will work more smoothly than before.

Also I-CMD is the improved version of ZCMD, which supports aliases too:

pawn Код:
CMD:shout(playerid,params[])
{
     return cmd_s(playerid,params);
}
And IMHO, you don't need all that useless "flag" checks before and after the command:

pawn Код:
flags:sendtols(CMD_HELPER | CMD_ADMIN);
Useless.
Ohh... okay, I see.. thanks bro! I will use I-ZCMD from now
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)