commands
#1

How i can make it, if player have "CMD" = 1

that he can type no one command expect /help....

i can put this in each command, but can i do easier?:

pawn Code:
CMD:aaa(playerid, params[])
{
    if(GetPVarInt(playerid, "CMD") == 1)
    {
        SendClientMessage(playerid, -1, "You can only type /help!");
    }
    else
    {
    //my code goes here
    return 1;
}
and i must put that in each command, can it be some how easier?
Reply
#2

i think this is the easiest way because this easier than make
new CMD[MAX_PLAYER]
Reply
#3

pawn Code:
public OnPlayerCommandReceived(playerid,cmdtext[])
{
    if(GetPVarInt(playerid, "CMD") == 1)
    {
        SendClientMessage(playerid, -1, "You can only type /help!");
        return 0;
    }
    return 1;
}
Reply
#4

Just use the function OnPlayerCommandReceived which is included in ZCMD.

pawn Code:
new helped[MAX_PLAYERS];
public OnPlayerCommandReceived(playerid, cmdtext[])
{
    if(strcmp("/help", cmdtext, true) != 0 && !helped[playerid])
    {
        SendClientMessage(playerid, -1, "You must type /help first!");
        return 0;
    }
    return 1;
}
CMD:help(playerid, params[])
{
    if(!helped[playerid]) helped[playerid] = 1;
    //.....
    return 1;
}
public OnPlayerConnect(playerid)
{
    helped[playerid] = 0;
    return 1;
}
Give that a go.
Reply
#5

Quote:
Originally Posted by [HiC]TheKiller
View Post
Just use the function OnPlayerCommandReceived which is included in ZCMD.

pawn Code:
new helped[MAX_PLAYERS];
public OnPlayerCommandReceived(playerid, cmdtext[])
{
    if(strcmp("/help", cmdtext, true) != 0 && !helped[playerid])
    {
        SendClientMessage(playerid, -1, "You must type /help first!");
        return 0;
    }
    return 1;
}
CMD:help(playerid, params[])
{
    if(!helped[playerid]) helped[playerid] = 1;
    //.....
    return 1;
}
public OnPlayerConnect(playerid)
{
    helped[playerid] = 0;
    return 1;
}
Give that a go.
I don't think that will work as he wish.
pawn Code:
new bool:CMD[MAX_PLAYERS];

public OnPlayerCommandReceived(playerid,cmdtext[])
{
    if(CMD[playerid] == false)
    {
        if(!strcmp("/help",cmdtext)) return 1;
        SendClientMessage(playerid,0,"Error");
    }
    return 1;
}

public OnPlayerConnect(playerid)
{
    CMD[playerid] = true;
    return 1;
}
Reply
#6

Quote:
Originally Posted by varthshenon
View Post
I don't think that will work as he wish.
pawn Code:
new bool:CMD[MAX_PLAYERS];

public OnPlayerCommandReceived(playerid,cmdtext[])
{
    if(CMD[playerid] == false)
    {
        if(!strcmp("/help",cmdtext)) return 1;
        SendClientMessage(playerid,0,"Error");
    }
    return 1;
}

public OnPlayerConnect(playerid)
{
    CMD[playerid] = true;
    return 1;
}
I don't see any difference to what you did except the variable name and it was changed to a bool.
Reply
#7

pawn Code:
new helped[MAX_PLAYERS];
public OnPlayerCommandReceived(playerid, cmdtext[])
{
    if(strcmp("/help", cmdtext, true) != 0 && !helped[playerid])//Chek if the command is /help and helped value is 0
    {
        SendClientMessage(playerid, -1, "You must type /help first!");
        return 0;
    }
    return 1;
}
CMD:help(playerid, params[])
{
    if(!helped[playerid]) helped[playerid] = 1;//If player's helped value is 0, change it to 1
    //.....
    return 1;
}
public OnPlayerConnect(playerid)
{
    helped[playerid] = 0;
    return 1;
}

//=====================================================

new bool:CMD[MAX_PLAYERS];

public OnPlayerCommandReceived(playerid,cmdtext[])
{
    if(CMD[playerid] == false)//If CMD is false
    {
        if(!strcmp("/help",cmdtext)) return 1;//If player do /help command, the command still called
        SendClientMessage(playerid,0,"Error");//Send error message
        return 0;//Forgot this
        }
    }
    return 1;
}

public OnPlayerConnect(playerid)
{
    CMD[playerid] = true;
    return 1;
}
See the difference?
Reply
#8

PHP Code:
public OnPlayerCommandPerformed(playeridcmdtext[], success)
{
    if(!
success) return SendClientMessage(playeridCOLOR_RED,"Wrong commands try /cmds to full list of commands");
    return 
1;

i thing thats more easy becose if commands is wrong or dont exit will say wrong cmd... but if commands true it will not say
Reply
#9

Remember that

pawn Code:
if(strcmp("/help", cmdtext, true) != 0)
Is actually checking if the command isn't correct. Your way wouldn't even work, because you are setting CMD[playerid] to true when the player connects. This makes it so regardless if the player had typed /help yet, the player wouldn't get asked to type /help. You also have absolutely no way of setting the command typed to true when the player typed the command.
Reply
#10

Quote:
Originally Posted by doreto
View Post
PHP Code:
public OnPlayerCommandPerformed(playeridcmdtext[], success)
{
    if(!
success) return SendClientMessage(playeridCOLOR_RED,"Wrong commands try /cmds to full list of commands");
    return 
1;

i thing thats more easy becose if commands is wrong or dont exit will say wrong cmd... but if commands true it will not say
You missundsertood him.
OnPlayerCommandPerformaed called if the command already called.
Reply
#11

Quote:
Originally Posted by varthshenon
View Post
pawn Code:
new helped[MAX_PLAYERS];
public OnPlayerCommandReceived(playerid, cmdtext[])
{
    if(strcmp("/help", cmdtext, true) != 0 && !helped[playerid])//Chek if the command is /help and helped value is 0
    {
        SendClientMessage(playerid, -1, "You must type /help first!");
        return 0;
    }
    return 1;
}
CMD:help(playerid, params[])
{
    if(!helped[playerid]) helped[playerid] = 1;//If player's helped value is 0, change it to 1
    //.....
    return 1;
}
public OnPlayerConnect(playerid)
{
    helped[playerid] = 0;
    return 1;
}

//=====================================================

new bool:CMD[MAX_PLAYERS];

public OnPlayerCommandReceived(playerid,cmdtext[])
{
    if(CMD[playerid] == false)//If CMD is false
    {
        if(!strcmp("/help",cmdtext)) return 1;//If player do /help command, the command still called
        SendClientMessage(playerid,0,"Error");//Send error message
        return 0;//Forgot this
        }
    }
    return 1;
}

public OnPlayerConnect(playerid)
{
    CMD[playerid] = true;
    return 1;
}
See the difference?
I noticed one thing, that you failed to write the code inside 'OnPlayerCommandReceived' properly and stop trying to compete against people in scripting. They have their own style intro coding, and you should respect that. TheKiller posted code that should work fine.
Reply
#12

Quote:
Originally Posted by [HiC]TheKiller
View Post
Remember that

pawn Code:
if(strcmp("/help", cmdtext, true) != 0)
Is actually checking if the command isn't correct. Your way wouldn't even work, because you are setting CMD[playerid] to true when the player connects. This makes it so regardless if the player had typed /help yet, the player wouldn't get asked to type /help. You also have absolutely no way of setting the command typed to true when the player typed the command.
I guess I miess read that part.
Also, I just know that he asked that player can't type any command execpt /help if CMD is false.
It can be use for mute command or anything.

Quote:
Originally Posted by Lorenc_
View Post
I noticed one thing, that you failed to write the code inside 'OnPlayerCommandReceived' properly and stop trying to compete against people in scripting. They have their own style intro coding, and you should respect that. TheKiller posted code that should work fine.
It's just the bracket. I forgot to remove that.
Why you said I'm trying to compete against people? I just trying to fix the code.
And also there's nothing tell us that I disrespect TheKiller .
Reply
#13

Quote:
Originally Posted by doreto
View Post
PHP Code:
public OnPlayerCommandPerformed(playeridcmdtext[], success)
{
    if(!
success) return SendClientMessage(playeridCOLOR_RED,"Wrong commands try /cmds to full list of commands");
    return 
1;

i thing thats more easy becose if commands is wrong or dont exit will say wrong cmd... but if commands true it will not say
that dosent help me with my Q, but thanks anyway

@varthshenon i gonna test it now, TY
Reply
#14

sorry for DB, but, it dosent work, i teleport to /maze, then i have CMD = false

and i type /ls and i got teleport, but i dont want to teleport me...., if is CMD = false i want, that if i type anything the result is always 0... i mean that nothing happnes ....
Reply
#15

Quote:
Originally Posted by Speed
View Post
sorry for DB, but, it dosent work, i teleport to /maze, then i have CMD = false

and i type /ls and i got teleport, but i dont want to teleport me...., if is CMD = false i want, that if i type anything the result is always 0... i mean that nothing happnes ....
http://forum.sa-mp.com/showpost.php?...42&postcount=4

Try that maybe?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)