SA-MP Forums Archive
Some little questions - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Some little questions (/showthread.php?tid=274059)



Some little questions - Wesley221 - 04.08.2011

Hey guys,
I got a few questions, which are quite simple IMO.
I've seen that alot of people using in commands 'params'. I know that theres 'cmdtext' aswell, but what i dont know is the difference.
Example:
pawn Код:
COMMAND:blabla(playerid, cmdtext)
COMMAND:blabla(playerid, cmdtext[])
COMMAND:blabla(playerid, params)
COMMAND:blabla(playerid, params[])
What is the difference between those?


Re: Some little questions - Calgon - 04.08.2011

You can't use 'cmdtext' in zcmd commands, you can only use params. And you need to use the square parenthesis to allocate a string to your command, failure to add the '[]' after params will result in your command only parsing an integer as your command parameters. cmdtext is the string/variable used in OnPlayerCommandText but zcmd manipulates the string and parses a newly created/formatted string to contain the command parameters.

In short:
pawn Код:
COMMAND:blabla(playerid, cmdtext) // no
COMMAND:blabla(playerid, cmdtext[]) // no
COMMAND:blabla(playerid, params) // no
COMMAND:blabla(playerid, params[]) // yes



Re: Some little questions - PinkFloydLover - 04.08.2011

params is very useful, as it is used to check what is typed after the command, cmdtext can be used the same way by typing the length of the command:

pawn Код:
if(cmdtext[5]) return //something
pawn Код:
if(strcmp(params,"hello") == 0) return SendClientMessage(playerid,-1,"The message you typed after the command was 'hello'"
These are commonly only used with 1 parameter command, then other scripting methods take place.


Re: Some little questions - Toreno - 04.08.2011

Also, when including zcmd in your gamemode/filterscript, OnPlayerCommandText must be deleted, otherwise, all of your commands will be unkonwn to the server.


Re: Some little questions - Wesley221 - 04.08.2011

Quote:
Originally Posted by Calg00ne
Посмотреть сообщение
You can't use 'cmdtext' in zcmd commands, you can only use params. And you need to use the square parenthesis to allocate a string to your command, failure to add the '[]' after params will result in your command only parsing an integer as your command parameters. cmdtext is the string/variable used in OnPlayerCommandText but zcmd manipulates the string and parses a newly created/formatted string to contain the command parameters.

In short:
pawn Код:
COMMAND:blabla(playerid, cmdtext) // no
COMMAND:blabla(playerid, cmdtext[]) // no
COMMAND:blabla(playerid, params) // no
COMMAND:blabla(playerid, params[]) // yes
Thanks, this is what i was looking for I always used the cmdtext[], and never had problems with it. Just wanted to know

Quote:
Originally Posted by PinkFloydLover
Посмотреть сообщение
params is very useful, as it is used to check what is typed after the command, cmdtext can be used the same way by typing the length of the command:

pawn Код:
if(cmdtext[5]) return //something
pawn Код:
if(strcmp(params,"hello") == 0) return SendClientMessage(playerid,-1,"The message you typed after the command was 'hello'"
These are commonly only used with 1 parameter command, then other scripting methods take place.
Thanks aswell, good to know

Quote:
Originally Posted by EliranPesahov
Посмотреть сообщение
Also, when including zcmd in your gamemode/filterscript, OnPlayerCommandText must be deleted, otherwise, all of your commands will be unkonwn to the server.
If you use ZCMD in a FS, and in a GM you use OnPlayerCommandText, does it still affect the OnPlayerCommandText in the GM, or..?