SA-MP Forums

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

 
 
Thread Tools Display Modes
Old 24/08/2011, 09:44 AM   #11
Lorenc_
High-roller
 
Lorenc_'s Avatar
 
Join Date: Jan 2010
Location: Australia
Posts: 4,279
Reputation: 1115
Default Re: commands

Quote:
Originally Posted by varthshenon View Post
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.irresistiblegaming.com:7777
Lorenc_ is offline  
Old 24/08/2011, 09:52 AM   #12
=WoR=Varth
High-roller
 
=WoR=Varth's Avatar
 
Join Date: Apr 2011
Location: Indonesia
Posts: 2,025
Reputation: 130
Default Re: commands

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

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 .
__________________
(RETIRED)
=WoR=Varth is offline  
Old 24/08/2011, 10:19 AM   #13
Speed
Huge Clucker
 
Join Date: Jan 2011
Posts: 207
Reputation: 7
Default Re: commands

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
Speed is offline  
Old 24/08/2011, 10:26 AM   #14
Speed
Huge Clucker
 
Join Date: Jan 2011
Posts: 207
Reputation: 7
Default Re: commands

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 ....
Speed is offline  
Old 24/08/2011, 10:37 AM   #15
[HiC]TheKiller
High-roller
 
Join Date: Mar 2008
Location: New Zealand
Posts: 3,031
Reputation: 409
Default Re: commands

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?
__________________
[HiC]TheKiller 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 11:57 AM
Help, no commands will work except for admin commands? MrPlayboy Help Archive 1 05/08/2011 01:07 AM
Transforming zcmd's commands to regular commands nuriel8833 Help Archive 17 08/01/2011 06:41 AM
DCMD Commands not working after adding some ZCMD commands :S [L3th4l] Help Archive 4 20/01/2010 10:57 PM


All times are GMT. The time now is 01:40 AM.


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