SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 24/08/2011, 08:44 AM   #8
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  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] Login/Register using ZCMD SSCANF & Y_INI.( Admin commands + VIP System + VIP Commands! ) Zh3r0 Filterscripts 116 09/01/2015 10:57 AM
Help, no commands will work except for admin commands? MrPlayboy Help Archive 1 05/08/2011 12:07 AM
Transforming zcmd's commands to regular commands nuriel8833 Help Archive 17 08/01/2011 05:41 AM
DCMD Commands not working after adding some ZCMD commands :S [L3th4l] Help Archive 4 20/01/2010 09:57 PM


All times are GMT. The time now is 08:21 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.