Changing a 3d text message with a command -
Mattjones17 - 09.01.2010
Hi
I am using the following command:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[128], idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/vms", true) == 0)
{
new newvms[256];
newvms = strtok(cmdtext, idx);
Update3DTextLabelText(Text3D:vms, 0xFFFFFFFF, newvms);
return 1;
/* Returning '1' is used to notify the server that the command
has successfully been processed. If you return true here you won't
get that 'SERVER: Unknown Command.', and any conflicts will be
avoided.
*/
}
return 0;
}
it is working fine - however if i put a space in the new string it doesnt work. What needs to be changed?
Re: Changing a 3d text message with a command -
Nero_3D - 09.01.2010
strtok search for the default separator which is a space
so it search for everything after a founded non-separator till the string end or next separator
pawn Код:
if(strcmp(cmdtext, "/vms", true, 4) == 0)
if(cmdtext[4] != ' ' || cmdtext[5] == EOS)
return SendClientMessage(playerid, 0xFFFFFFAA, "Usage: /vms [text]");
else return Update3DTextLabelText(vms, 0xFFFFFFFF, cmdtext[5]);
Re: Changing a 3d text message with a command -
Mattjones17 - 09.01.2010
Thanks
It is also limited to 29 characters. Do you know how this can be fixed?
Cheers
Matt
Re: Changing a 3d text message with a command -
Nero_3D - 09.01.2010
Quote:
Originally Posted by Mattjones17
Thanks
It is also limited to 29 characters. Do you know how this can be fixed?
Cheers
Matt
|
you mean strtok ?
it uses a 30 cell array 29 character and the end of string
because it would be quite useless to use a big array if it only gets a short part of the input
I can advise sscanf, it uses an undefined parameter size
so you can set the size of the arguments you want and the length of the output
sscanf can be found in the wiki
/wiki/sscanf
there is a tutorial, too =>
Fast Commands
It explains, strtok, dcmd, zcmd, sscanf