Player ID after name in chat
#1

How to get the player ID after the playername in the chat?
Reply
#2

show your "public OnPlayetext"
Reply
#3

PHP код:
public OnPlayerText(playeridtext[])
{
    
// Mute System
    
if(IsPlayerMuted(playerid))
    {
        new 
string[144];
        
format(stringsizeof(string), "You are muted, %i seconds left."User[playerid][mutedsec]);
        
SendClientMessage(playeridCOLOR_REDstring);
        return 
0;
    }

    
// Admin Chat system
    
if(GetLevel(playerid) >= 1)
    {
        if(
text[0] == '@')
        {
            new 
string[144];
            
format(stringsizeof(string), "[Admin-Chat] %s(%i): "white"%s"GetName(playerid), playeridtext[1]);
            
SendClientMessageToAdmins(COLOR_LIGHTBLUEstring);
            return 
0;
        }
    }
    
    
// VIP Chat system
    
if(IsPlayerVip(playerid) >= 1)
    {
        if(
text[0] == '=')
        {
            new 
string[144];
            
format(stringsizeof(string), "[VIP-Chat] %s(%i): "white"%s"GetName(playerid), playeridtext[1]);
            
SendClientMessageToAdmins(COLOR_YELLOWstring);
            return 
0;
        }
    }

    
// Anti Advert system
     #if defined USE_ANTIADVERT
        
if(IsAdvertisement(text))
        {
            if(
GetLevel(playerid) >= 1)
            {
                new 
string[144];
                
format(stringsizeof(string), "[ALERT] "white"%s(%i) "red"has tried to advertise the IP: "white"%s"GetName(playerid), playeridtext);
                
SendClientMessageToAdmins(COLOR_REDstring);
            }
            
SendClientMessage(playeridCOLOR_RED"Advertising is not allowed, message blocked.");

            
#if defined SAVE_LOGS
                
new logstring[244];
                
format(logstringsizeof(logstring), "%s tried to advertise IP %s"GetName(playerid), text);
                
SaveLog("adverts.txt"logstring);
            
#endif
            
return 0;
        }
    
#endif

    
return 1;

Reply
#4

playerid is the playerid.
Код:
format(string,sizeof(string),"%s %i",PlayerName,playerid);
Reply
#5

Quote:
Originally Posted by GangstaSunny
Посмотреть сообщение
playerid is the playerid.
Код:
format(string,sizeof(string),"%s %i",PlayerName,playerid);
lol where is the text?


Try this

Код:
//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
}
Reply
#6

Quote:
Originally Posted by GangstaSunny
Посмотреть сообщение
playerid is the playerid.
Код:
format(string,sizeof(string),"%s %i",PlayerName,playerid);
error 017: undefined symbol "string"

I know how to fix it but I don't know if it sends my message double?
Reply
#7

Quote:
Originally Posted by K0P
Посмотреть сообщение
lol where is the text?


Try this

format(string, sizeof(string), "%s(%d): %s", GetName(playerid), playerid, text);
error 017: undefined symbol "string"

new string[How many items should I put in here?];

??
Reply
#8

Quote:
Originally Posted by Fantje
Посмотреть сообщение
error 017: undefined symbol "string"

new string[How many items should I put in here?];

??
I updated the post,see new code
Reply
#9

It works but it also send a message without the ID so it will come out double
Reply
#10

Show which filterscripts are you using?

And update the code to this,made a little change:

Код:
//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
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)