SA-MP Forums Archive
My own /ann cmd doesn't work well - 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)
+--- Thread: My own /ann cmd doesn't work well (/showthread.php?tid=371070)



My own /ann cmd doesn't work well - Guitar - 22.08.2012

Hey guys

pawn Код:
CMD:ann(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] <= 2) return SendClientMessage(playerid, COLOR_RED, "Error Occured: This command is only for Admins.");
    new sendername[MAX_PLAYER_NAME], str[256];
    if(sscanf(params,"s", str)) return SendClientMessage(playerid, COLOR_GREEN, "[ADMIN] /ann [Text]");
    GetPlayerName(playerid, sendername, sizeof(sendername));
    format(str, sizeof(str), ""#COL_RED"[ADMIN-ANN]"#COl_WHITE"%s: %s", sendername, str);
    SendClientMessageToAll(COLOR_RED, str);
    GameTextForAll( str, 5000, 3 );
    return 1;
}
This is my /ann cmd, well I want it to send a full message, it doesn't .. It sends like 1/4 of the message

So if I wanna say:

Hello, welcome to the server, please type /help to get more information about the server and script.

It sends:

Hello, welcome to the server, please ty

It doesn't continue it, is there any way to fix this?


Re: My own /ann cmd doesn't work well - Akira297 - 22.08.2012

It's due the the maximum amount of characters for
"GameTextForAll"
and*
"GameTextForPlayer"


Re: My own /ann cmd doesn't work well - Guitar - 22.08.2012

Hm I set the str to 512 xD And it seems to be working, would that effect badly on the server?


Re: My own /ann cmd doesn't work well - Akira297 - 22.08.2012

< Withdraws From Topic, Ima let Ranama do this one, and ima go back to bed xD >


Re: My own /ann cmd doesn't work well - Ranama - 22.08.2012

Quote:
Originally Posted by Guitar
Посмотреть сообщение
Hm I set the str to 512 xD And it seems to be working, would that effect badly on the server?
Not if you just use one variable that is to big, but if you start using it like everywhere, it may be a problem.


Re: My own /ann cmd doesn't work well - Guitar - 22.08.2012

Well, is there any other good way? Because /ann will be used just to help people and give them tips!


Re: My own /ann cmd doesn't work well - Ranama - 22.08.2012

I see the problem, you'll have to set a \ before all the " that you are using in your text becuse otherwise the function think your string ends there. Like this:
format(str, sizeof(str), "\"#COL_RED\"[ADMIN-ANN]\"#COl_WHITE\"%s: %s", sendername, str);


Re: My own /ann cmd doesn't work well - FalconX - 22.08.2012

Quote:
Originally Posted by Ranama
Посмотреть сообщение
I see the problem, you'll have to set a \ before all the " that you are using in your text becuse otherwise the function think your string ends there. Like this:
format(str, sizeof(str), "\"#COL_RED\"[ADMIN-ANN]\"#COl_WHITE\"%s: %s", sendername, str);
pawn Код:
new szStr[ 128 ]; // this is the default value of the chat message..
I believe it's useless using more then 128 value for such reason..


and for GameTextForPlayer/GameTextForAll, if you want to change the colour (or want a next line) of it then you have to use

pawn Код:
// colors ..
~n~ New line
~r~ Red
~g~ Green
~b~ Blue
~w~ White
~y~ Yellow
~p~ Purple
~l~ Black
~h~ Turn text colour lighter (used too much will make your text white, doesnt work on black)

// special text

 ~u~ up arrow (grey)
~d~ down arrow (grey)
~<~ left arrow (grey)
~>~ right arrow (grey)
] displays a * symbol (Only in text styles 3, 4 and 5)
~k~ keyboard key mapping (eg ~k~~VEHICLE_TURRETLEFT~ and ~k~~PED_FIREWEAPON~). Look here for a list of keys
https://sampwiki.blast.hk/wiki/GameTextStyle