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, 07:50 AM   #1
Speed
Huge Clucker
 
Join Date: Jan 2011
Posts: 207
Reputation: 7
Default commands

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?:

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?
Speed is offline  
Old 24/08/2011, 07:52 AM   #2
Horrible
Huge Clucker
 
Horrible's Avatar
 
Join Date: Jun 2011
Location: Indonesia
Posts: 458
Reputation: 83
Default Re: commands

i think this is the easiest way because this easier than make
new CMD[MAX_PLAYER]
__________________
Click to see my works
Horrible is offline  
Old 24/08/2011, 07:52 AM   #3
=WoR=Varth
High-roller
 
=WoR=Varth's Avatar
 
Join Date: Apr 2011
Location: Indonesia
Posts: 2,046
Reputation: 130
Default Re: commands

Code:
public OnPlayerCommandReceived(playerid,cmdtext[])
{
	if(GetPVarInt(playerid, "CMD") == 1)
	{
		SendClientMessage(playerid, -1, "You can only type /help!");
		return 0;
	}
	return 1;
}
__________________
(RETIRED)
=WoR=Varth is offline  
Old 24/08/2011, 07:59 AM   #4
[HiC]TheKiller
High-roller
 
Join Date: Mar 2008
Location: New Zealand
Posts: 3,038
Reputation: 407
Default Re: commands

Just use the function OnPlayerCommandReceived which is included in ZCMD.

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.
__________________
[HiC]TheKiller is offline  
Old 24/08/2011, 08:11 AM   #5
=WoR=Varth
High-roller
 
=WoR=Varth's Avatar
 
Join Date: Apr 2011
Location: Indonesia
Posts: 2,046
Reputation: 130
Default Re: commands

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

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.
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;
}
__________________
(RETIRED)
=WoR=Varth is offline  
Old 24/08/2011, 08:21 AM   #6
[HiC]TheKiller
High-roller
 
Join Date: Mar 2008
Location: New Zealand
Posts: 3,038
Reputation: 407
Default Re: commands

Quote:
Originally Posted by varthshenon View Post
I don't think that will work as he wish.
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.
__________________
[HiC]TheKiller is offline  
Old 24/08/2011, 08:32 AM   #7
=WoR=Varth
High-roller
 
=WoR=Varth's Avatar
 
Join Date: Apr 2011
Location: Indonesia
Posts: 2,046
Reputation: 130
Default Re: commands

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?
__________________
(RETIRED)
=WoR=Varth is offline  
Old 24/08/2011, 08:37 AM   #8
doreto
High-roller
 
doreto's Avatar
 
Join Date: Aug 2010
Posts: 1,717
Reputation: 118
Default Re: commands

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
doreto is offline  
Old 24/08/2011, 08:41 AM   #9
[HiC]TheKiller
High-roller
 
Join Date: Mar 2008
Location: New Zealand
Posts: 3,038
Reputation: 407
Default Re: commands

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.
__________________
[HiC]TheKiller is offline  
Old 24/08/2011, 08:41 AM   #10
=WoR=Varth
High-roller
 
=WoR=Varth's Avatar
 
Join Date: Apr 2011
Location: Indonesia
Posts: 2,046
Reputation: 130
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
You missundsertood him.
OnPlayerCommandPerformaed called if the command already called.
__________________
(RETIRED)
=WoR=Varth 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 01:29 AM.


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