07.08.2009, 22:55
Hello
I have decided to check out dcmd and I have got two questions about it.
1. Is it possible to add two commands which do the same thing? Like normally you do:
But is i possible to do something like that with dcmd?
2. Another thing is about commands with more than one parameter. For example I would like to do command /give which would have options something and somethingelse and it would affect selected player id (/give [option] [playerid])
Normally you would do something like that:
As you can see, when I write only '/give something' it shows me different message as when I write only '/give.' If I use sscanf with dcmd and I write only '/give something' it will still show me the first message until I fill out all the parameters.
So how could I make that when I fill up only one parameter it will already show me the message I choose?
Thanks for help
I have decided to check out dcmd and I have got two questions about it.
1. Is it possible to add two commands which do the same thing? Like normally you do:
Код:
if(strcmp(cmd, "/something", true) == 0 || strcmp(cmd, "/somethingelse", true) == 0)
2. Another thing is about commands with more than one parameter. For example I would like to do command /give which would have options something and somethingelse and it would affect selected player id (/give [option] [playerid])
Normally you would do something like that:
pawn Код:
if(strcmp(cmd, "/give", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new x_nr[256];
x_nr = strtok(cmdtext, idx);
if(!strlen(x_nr)) {
SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[USAGE:] /give [item] [playerid]");
SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[ITEM:] something, somethingelse");
return 1;
}
if(strcmp(x_nr,"something",true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[USAGE:] /give something [playerid]");
return 1;
}
giveplayerid = ReturnUser(tmp);
if(IsPlayerConnected(giveplayerid))
{
// and other stuff
So how could I make that when I fill up only one parameter it will already show me the message I choose?
Thanks for help