SA-MP Forums Archive
over nick the player id - 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: over nick the player id (/showthread.php?tid=294104)



PlayerID near player nick - V4at - 31.10.2011

How to make PlayerID near player nick in chat?


Re : over nick the player id - V4at - 31.10.2011

Help me!


Re: over nick the player id - Scenario - 31.10.2011

SendPlayerMessage I believe.


Re: over nick the player id - knackworst - 31.10.2011

pawn Код:
new
                szStr[128],
                szPName[MAX_PLAYER_NAME];
            GetPlayerName(playerid, szPName, MAX_PLAYER_NAME);
            format(szStr, sizeof(szStr), "{4169FF}%s:{FFFFFF} %s", szPName, text[0]);

            for(new i; i < MAX_PLAYERS; i++)//if you use foreach use that, if you don't - then you should start.
                if(IsPlayerConnected(i))
                    SendClientMessageToAll(COLOR_WHITE,szStr);
under OnPlayerText

EDIT: forgot, u can now choose what should be displayed by changeing whatever u want...

f.e
pawn Код:
format(szStr, sizeof(szStr), "{4169FF}%s(%i):{FFFFFF} %s", szPName, playerid,text[0]);



Re : over nick the player id - V4at - 31.10.2011

Thanks


Re: over nick the player id - Psymetrix - 31.10.2011

Quote:
Originally Posted by knackworst
Посмотреть сообщение
pawn Код:
new
                szStr[128],
                szPName[MAX_PLAYER_NAME];
            GetPlayerName(playerid, szPName, MAX_PLAYER_NAME);
            format(szStr, sizeof(szStr), "{4169FF}%s:{FFFFFF} %s", szPName, text[0]);

            for(new i; i < MAX_PLAYERS; i++)//if you use foreach use that, if you don't - then you should start.
                if(IsPlayerConnected(i))
                    SendClientMessageToAll(COLOR_WHITE,szStr);
Your code will send a message to all players each time it finds a connected player causing the chat to be flooded.

pawn Код:
public OnPlayerText(playerid, text[]) {

    new
        cString[128],
        pName[MAX_PLAYER_NAME]
    ;
   
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    format(cString, sizeof(cString), "%s(%d): %s", pName, playerid, text);
    SendClientMessageToAll(-1, cString);
   
    return 0;
}



Re: over nick the player id - knackworst - 31.10.2011

I don't believe so, it's copied from my GM, where it works...


Re : over nick the player id - V4at - 31.10.2011

It works, but how do the player's nick color is not white?


Re: over nick the player id - Psymetrix - 31.10.2011

Quote:
Originally Posted by knackworst
Посмотреть сообщение
I don't believe so, it's copied from my GM, where it works...
Have you tested your GM with more than one person on it?

pawn Код:
public OnPlayerText(playerid, text[]) {

    new
        cString[128],
        pName[MAX_PLAYER_NAME]
    ;
   
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    format(cString, sizeof(cString), "%s(%d){FFFFFF}: %s", pName, playerid, text);
    SendClientMessageToAll(GetPlayerColor(playerid), cString);
   
    return 0;
}
Please follow THIS to get it working correctly.


Re: over nick the player id - knackworst - 31.10.2011

pawn Код:
public OnPlayerText(playerid, text[]) {

    new
        cString[128],
        pName[MAX_PLAYER_NAME]
    ;
   
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    format(cString, sizeof(cString), "%s(%d): {FFFFFF}%s", pName, playerid, text);
    SendClientMessageToAll(GetPlayerColor(playerid), cString);
   
    return 0;
}
to get the real chat effect...