How-To: Make Admin/Team Chats! -
Abagail - 19.02.2014
How-To: Make Admin/Team Chats!
Hello. Today, I'll be showing you how you can make admin chats/team chats, and more! Let's get started. You'll need some basic thing's to do this tutorial, how-ever. Those things can be found below:
**Basic PAWN Scripting Knowledge**
**Pawno/Compiler(Version 0.3x or 0.3z is recommended.)
Alright, so we'll be using some includes as found below:
Code:
#include a_samp // Of-Course!
#include zcmd
#include foreach // If you prefer using the MAX_PLAYERS method feel free to comment this out.
Alright, so now we'll put some defines:
Code:
#define COLOR_CHAT -1 // Replace this with what-ever color you want the chat(color) to be.
Alright, so we'll be using ZCMD for this tutorial. Additonally, I'll be showing you with the CMD: style of ZCMD. Alright, now that we've set everything up let's get started, shall we?
Making a chat for RCON Admins(foreach version):
We'll need to set up our command...
Code:
CMD:achat(playerid, params[])
{
return 1;
}
Now we'll need to check if the player's logged in as an RCON Admin if not it'll show up as an unknown command.
Code:
if(!IsPlayerAdmin(playerid)) return 0;
Now we'll check if the params are null or not.
Code:
if(isnull(params)) return SendClientMessage(playerid, -1, "USAGE: /achat [text]");
Now, we'll be using a string for the actual chat message, so...
NOTE: I'll be using GetPName. You'll need to put the following somewhere in the script.
Code:
stock GetPName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
return name;
}
Then to actually send the message, and finish up the command...
Code:
format(string, sizeof(string), "RCON Admin %s: %s", GetPName(playerid), params);
foreach(Player, i) {
if(IsPlayerAdmin(i)) return SendClientMessage(playerid, COLOR_CHAT, string);
}
return 1;
}
If you've done everything right your script should look like this:
Code:
#include a_samp
#include zcmd
#include foreach
#define COLOR_CHAT -1
CMD:achat(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return 0;
if(isnull(params)) return SendClientMessage(playerid, -1, "USAGE: /achat [text]");
new string[128];
format(string, sizeof(string), "RCON Admin %s: %s", GetPName(playerid), params);
foreach(Player, i) {
if(IsPlayerAdmin(i)) return SendClientMessage(playerid, COLOR_CHAT, string);
}
return 1;
}
stock GetPName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
return name;
}
So, basically if you wanna make it for a certain team just replace IsPlayerAdmin, etc...
If you have any questions, or comments, just reply or PM me!
- Abagail
Re: How-To: Make Admin/Team Chats! -
KurtBart - 21.05.2014
Nice tutorial. I like it
. It gave me no errors.