Thread: commands
View Single Post
Old 24/08/2011, 08:44 AM   #11
Lorenc_
High-roller
 
Lorenc_'s Avatar
 
Join Date: Jan 2010
Location: Australia
Posts: 3,803
Reputation: 1160
Default Re: commands

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.
__________________
Join the best Cops And Robbers in SA-MP, today. svr.sfcnr.com:7777

Lorenc_ is offline