Some little questions
#1

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?
Reply
#2

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
Reply
#3

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.
Reply
#4

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

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..?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)