17.11.2011, 09:00
(
Last edited by §с†¶e®РµРe; 30/11/2011 at 10:36 AM.
)
Well,people i have seen a lot of guys searching around for a /announce command or even if they have it it has some problem or something.So today i decided to show you how you can make a FULLY WORKING /announce command in ZCMD and sscanf.
First i will tell you the code then i will explain it....
Now to understand the code
1.
This command checks if the player i rcon admin or not you can change this to normal admins only by seeing what is defined in your admin system.If the player is not rcon admin it send a error.
2.
This code first defines usage and parameters.
3.
This checks if the text exceeds the length of 64 chars. if it does it sends and error.
4.
This checks if the style is 2 because according to GTA:SA style 2 wont disappear from the screen till you respawn so if the style = 2 then it sends an error.
5.
This checks if the style is valid that means between 1-6 or it sends an error.
6.
This checks if the time of the gametext exceeds 20 seconds it sends an error if it does you can change this.
7.
finally if there are no problems it sends a gametext to all.
Please +rep me if you like my work.Thank you.
Have a nice day......
First i will tell you the code then i will explain it....
Code:
CMD:announce(playerid, params[]) { if(IsPlayerAdmin(playerid)) return SendClientMessage(playerid, "You are not allowed to use this command"); new text[64], time, style; if (sscanf(params, "iis[64]", style, time, text)) return SendClientMessage( playerid,"Usage: /announce <style[0-6]> <time in ms> <text>"); if (strlen(text) > 64) return SendClientMessage(playerid,"Message too long please shorten it "); if(style == 2) return SendClientMessage(playerid,"Bug with style 2 don't use it!"); if (style < 0 || style > 6) return SendClientMessage(playerid,0x854900FF,"Invalid style"); if (time > 20*1000) return SendClientMessage(playerid,"No longer than 20 seconds"); GameTextForAll(text, time, style); return true; }
1.
Code:
if(IsPlayerAdmin(playerid)) return SendClientMessage(playerid, "You are not allowed to use this command")
2.
Code:
new text[64], time, style; if (sscanf(params, "iis[64]", style, time, text)) return SendClientMessage( playerid,"Usage: /announce <style[0-6]> <time in ms> <text>");
3.
Code:
if (strlen(text) > 64) return SendClientMessage(playerid,"Message too long please shorten it ");
4.
Code:
if(style == 2) return SendClientMessage(playerid,"Bug with style 2 don't use it!");
5.
Code:
if (style < 0 || style > 6) return SendClientMessage(playerid,0x854900FF,"Invalid style");
6.
Code:
if (time > 20*1000) return SendClientMessage(playerid,"No longer than 20 seconds");
7.
Code:
GameTextForAll(text, time, style);
Please +rep me if you like my work.Thank you.
Have a nice day......