26.07.2016, 18:18
How to get the player ID after the playername in the chat?
public OnPlayerText(playerid, text[])
{
// Mute System
if(IsPlayerMuted(playerid))
{
new string[144];
format(string, sizeof(string), "You are muted, %i seconds left.", User[playerid][mutedsec]);
SendClientMessage(playerid, COLOR_RED, string);
return 0;
}
// Admin Chat system
if(GetLevel(playerid) >= 1)
{
if(text[0] == '@')
{
new string[144];
format(string, sizeof(string), "[Admin-Chat] %s(%i): "white"%s", GetName(playerid), playerid, text[1]);
SendClientMessageToAdmins(COLOR_LIGHTBLUE, string);
return 0;
}
}
// VIP Chat system
if(IsPlayerVip(playerid) >= 1)
{
if(text[0] == '=')
{
new string[144];
format(string, sizeof(string), "[VIP-Chat] %s(%i): "white"%s", GetName(playerid), playerid, text[1]);
SendClientMessageToAdmins(COLOR_YELLOW, string);
return 0;
}
}
// Anti Advert system
#if defined USE_ANTIADVERT
if(IsAdvertisement(text))
{
if(GetLevel(playerid) >= 1)
{
new string[144];
format(string, sizeof(string), "[ALERT] "white"%s(%i) "red"has tried to advertise the IP: "white"%s", GetName(playerid), playerid, text);
SendClientMessageToAdmins(COLOR_RED, string);
}
SendClientMessage(playerid, COLOR_RED, "Advertising is not allowed, message blocked.");
#if defined SAVE_LOGS
new logstring[244];
format(logstring, sizeof(logstring), "%s tried to advertise IP %s", GetName(playerid), text);
SaveLog("adverts.txt", logstring);
#endif
return 0;
}
#endif
return 1;
}
format(string,sizeof(string),"%s %i",PlayerName,playerid);
playerid is the playerid.
Код:
format(string,sizeof(string),"%s %i",PlayerName,playerid); |
//Includes name color too >> if(IsPlayerMuted(playerid)) { new string[150]; format(string, sizeof(string), "{%06x}%s(%d): %s", GetPlayerColor(playerid) >>> 8, GetName(playerid), playerid, text); SendCLientMessageToAll(0xFFFFFFFF, string); return 0; //Prevents dubble message }
//Includes name color too >> if(!IsPlayerMuted(playerid)) { new string[150]; format(string, sizeof(string), "{%06x}%s(%d): %s", GetPlayerColor(playerid) >>> 8, GetName(playerid), playerid, text); SendCLientMessageToAll(0xFFFFFFFF, string); return 0; //Prevents dubble message }