SA-MP Forums Archive
Need help with chat system - 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: Need help with chat system (/showthread.php?tid=344033)



Need help with chat system - Tom Kingston - 19.05.2012

Alright,so,as you know from starting a new GM and the Grand Larcette(Not sure if it's this name) ,when you type a message and press ENTER,it sends it to all. I guess over 60% of you readers have played on Roleplay scripts and I need to find a way scripting the chat to be like in RP one-shows the messages only to the people surrounding you.

Thank you from earlier.


Re: Need help with chat system - Pinguinn - 19.05.2012

pawn Код:
public OnPlayerText(playerid, text[]) {
    new Float:x, Float:y, Float:z, msg[128], name[MAX_PLAYER_NAME];
    GetPlayerPos(playerid, x, y, z);
    GetPlayerName(playerid, name, sizeof(name));
    format(msg, sizeof(msg), "%s (%d): %s", name, playerid, text);
    for(new i = 0; i < MAX_PLAYERS; i++) {
        if(IsPlayerInRangeOfPoint(i, [range], x, y, z)) {
            SendClientMessage(i, COLOR_WHITE, msg);
        }      
    }
    return 0;
}
Make sure to change [range]


Re: Need help with chat system - Tom Kingston - 21.05.2012

Uuhm,well for me IDK why the "GetPlayerName" won't work. Could you please see why it is like that and if it needs a file for #include,send it to me. All reputation goes to you btw.


Re: Need help with chat system - ReneG - 21.05.2012

Click, and follow the tutorial in my signature. It covers all the RP chats, and I can assure you all the code posted in there is tested and works 100%.