14.11.2015, 13:28
(
Last edited by Karan007; 17/11/2015 at 09:18 AM.
)
Hello guys,
this is a tutorial on how to make an /announce command for admins. This is a really easy script to make. I made this tutorial for newbies who don't know how to make this command. Let's start it now!
Scripting.
This specifies the command announce and we are opening braces.
This means if he is not rcon logged in, it will return the following message. We'll split this a bit. "!" this specifies "if not". Splitting - if(!IsPlayerAdmin(playerid)) ; Let's split this bit of code. If that player IS NOT admin;
so we will use the msg as the string ; 25 specifies how many letters should the string contains.
This checks the parameters and if he didn't wrote the parameters correctly, then it will send that "Usage" message.
|----------ADDITIONAL NOTES----------|
i - Integer (Number) - Used as time
i - Integer (Number) - Used as the type
s - String (Letters) - Used for the message
|---------------------------------------|
Now, we will restrict the type 2 that is bugged.
This code checks if he wrote the "ty" as 2,0 or more than 8 and if he did, the server will return the "Error" message.
Now, let's move on to the final code.
This sends all the players the message by the msg we wrote, with the time to stop the message and the type. Returning 1 will execute the command.
|-USING COLORS-|
We can also use colors in them. An example is below.
/announce 5000 4 ~r~ <- Red color ~b~ <- Blue color
|-FULL CODE-|
|-END OF TUTORIAL-|
I made another tutorial |-Click here-| This tutorial contains more detailed in formatting, you guys can check it out for more information about formatting message in dialogs. And it is also useful for gametext.
Credits
Karan007 - Created this tutorial/script
SA-MP Team - Created SA-MP
Y_Less - Sscanf
Zeex - ZCMD
Enjoy
this is a tutorial on how to make an /announce command for admins. This is a really easy script to make. I made this tutorial for newbies who don't know how to make this command. Let's start it now!
Scripting.
PHP Code:
CMD:announce(playerid,params[])
{
PHP Code:
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Error: You are not rcon logged in!")
PHP Code:
new msg[25], ty, time;
PHP Code:
if(sscanf(params, "iis[25]", time, ty, msg)) return SendClientMessage(playerid, -1, "Usage: /announce [Time] [Msg Type] [TEXT]");
|----------ADDITIONAL NOTES----------|
i - Integer (Number) - Used as time
i - Integer (Number) - Used as the type
s - String (Letters) - Used for the message
|---------------------------------------|
Now, we will restrict the type 2 that is bugged.
This code checks if he wrote the "ty" as 2,0 or more than 8 and if he did, the server will return the "Error" message.
PHP Code:
if(ty >= 8 || ty <= 0 || ty == 2) return SendClientMessage(playerid, -1, "Only 1,3,4,5,6,7");
PHP Code:
GameTextForAll(msg, time, ty);
return 1;
}
|-USING COLORS-|
We can also use colors in them. An example is below.
/announce 5000 4 ~r~ <- Red color ~b~ <- Blue color
|-FULL CODE-|
PHP Code:
CMD:announce(playerid,params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Error: You are not rcon logged in!");
new msg[25], ty, time;
if(sscanf(params, "iis[25]", time, ty, msg)) return SendClientMessage(playerid, -1, "Usage: /announce [Time] [Msg Type] [TEXT]");
if(ty >= 8 || ty == 0 || ty == 2) return SendClientMessage(playerid, -1, "Only 1,3,4,5,6,7");
GameTextForAll(msg, time, ty);
return 1;
}
I made another tutorial |-Click here-| This tutorial contains more detailed in formatting, you guys can check it out for more information about formatting message in dialogs. And it is also useful for gametext.
Credits
Karan007 - Created this tutorial/script
SA-MP Team - Created SA-MP
Y_Less - Sscanf
Zeex - ZCMD
Enjoy