How to get text on player command?? -
sebacol - 13.02.2010
How to get text on player command??
for example someone type this: /command 24
and then pawn will get this 24
Re: How to get text on player command?? -
Universal - 13.02.2010
Код:
if(!strcmp(cmdtext,"/command",8,true))
{
new tmp = cmdtext[9]; // if its string, then leave it, if its integer change to: new tmp = strval(cmdtext[9]);
new string[10]; format(string,10,"Pawn gets: %s",tmp); // if its integer change the %s to %d, else leave it.
return SendClientMessage(playerid,0xFFFFFFFF,string);
}
Re: How to get text on player command?? -
sebacol - 14.02.2010
TNX but how can I now if someone type this: /command 1 blah blah blah blah blah
how to get this num and all that text?
Re: How to get text on player command?? -
Universal - 14.02.2010
Quote:
Originally Posted by sebacol
TNX but how can I now if someone type this: /command 1 blah blah blah blah blah
how to get this num and all that text?
|
You can very simply use DCMD and sscanf, which you can download from
http://solidfiles.com/d/29b0aa68e078...77fd4a7cfd7c76 , put this in your pawno/include folder and on the top of fs/gm type #include <dcmd>
then OnPlayerCommandText(..), add:
Код:
dcmd(command,8,cmdtext);
And after callback OnPlayerCommandText add:
dcmd_command(playerid,params[])
{
new i, tmp[20];
if(sscanf(params,"is",i,tmp))return SendClientMessage(playerid,0xFFFFFFFF," USAGE: /command integer text");
new string[25]; format(string,sizeof(string)," Pawno gets: integer: %d, and string: %s.",i,tmp);
return SendClientMessage(playerid,0xFFFFFFFF,string);
}
Now:
i - integer (number)
s - string (text)
So you should use this command: /command 1 blahblahblah
Re: How to get text on player command?? -
sebacol - 14.02.2010
I added this file into pawno/include
and when I test the script with pawno it says: fatal error 100: cannot read from file: "dcmd"
I am sure that filename is the same and in the right folder
Re: How to get text on player command?? -
adsy - 14.02.2010
he missed the 1 vital line at the top
Код:
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
this is all 1 line
Re: How to get text on player command?? -
Universal - 14.02.2010
Quote:
Originally Posted by adsy
he missed the 1 vital line at the top
Код:
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
this is all 1 line
|
That include which i gave already has dcmd defined, i dont know why it cant read dcmd, check again if everything is correctly done.