[SOLVED]Weird thing with text length - 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: [SOLVED]Weird thing with text length (
/showthread.php?tid=124476)
[SOLVED]Weird thing with text length -
Rzzr - 30.01.2010
I have an announce command:
pawn Код:
dcmd_announce(playerid, params[])
{
new message;
new string[128];
new string2[128];
if(PlayerInfo[playerid][AdminLevel] < LEVEL_ANNOUNCE) ErrorMessage(playerid, "Error: You don't have a high enough admin level!");
else if (sscanf(params, "s", message)) ErrorMessage(playerid, "Usage: '/announce [text]'");
else
{
format(string, sizeof(string), "~n~~w~%s", message);
GameTextForAll(string, 4000, 3);
format(string2, sizeof(string2), "Administrator %s has announced this: %s", PlayerName(playerid), message);
printf(string2);
}
return 1;
}
But there's something weird.
When I announce anything that's longer then 2 symbols, it gives me SERVER: Unknown Command, but it does announce the text anyways.
Do you know what's wrong?
Re: Weird thing with text length -
ray187 - 30.01.2010
"message" is not an array as it should be. -> change it to new message[128].
I`d also suggest not to create two strings (string and string2) as you did but use string two times:
Код:
dcmd_announce(playerid, params[])
{
new message[128];
new string[128];
if(PlayerInfo[playerid][AdminLevel] < LEVEL_ANNOUNCE) ErrorMessage(playerid, "Error: You don't have a high enough admin level!");
else if (sscanf(params, "s", message)) ErrorMessage(playerid, "Usage: '/announce [text]'");
else
{
format(string, sizeof(string), "~n~~w~%s", message);
GameTextForAll(string, 4000, 3);
format(string, sizeof(string), "Administrator %s has announced this: %s", PlayerName(playerid), message);
printf(string);
}
return 1;
}
Re: Weird thing with text length -
Kinetic - 30.01.2010
Quote:
Originally Posted by ray187
|
you might wanna do this instead
Re: Weird thing with text length -
ray187 - 30.01.2010
Oh well.. it`s late :P
Re: Weird thing with text length -
Rzzr - 30.01.2010
Thanks guys! it works