SA-MP Forums Archive
Player ID after name in chat - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Player ID after name in chat (/showthread.php?tid=613335)



Player ID after name in chat - Fantje - 26.07.2016

How to get the player ID after the playername in the chat?


Re: Player ID after name in chat - K0P - 26.07.2016

show your "public OnPlayetext"


Re: Player ID after name in chat - Fantje - 26.07.2016

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;




Re: Player ID after name in chat - GangstaSunny - 26.07.2016

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



Re: Player ID after name in chat - K0P - 26.07.2016

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
}



Re: Player ID after name in chat - Fantje - 26.07.2016

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?


Re: Player ID after name in chat - Fantje - 26.07.2016

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?];

??


Re: Player ID after name in chat - K0P - 26.07.2016

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


Re: Player ID after name in chat - Fantje - 26.07.2016

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


Re: Player ID after name in chat - K0P - 26.07.2016

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
}