[CODE] Communication Commands
#1

Can someone give me a tutorial on how to make a chat command sort of thing, i.e. when someone is in range he/she can then get the message but if there out of range they cant, also somthing like a private message system if there in range like a whisper sort of thing. Then also a phone so I can text or call people.
Reply
#2

Well, I can provide the simple concept of range. If you want someone to see the command/text you displace, you can use this stock.
pawn Код:
stock PlayerToPlayer(playerid,targetid,Float:distance)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid,x,y,z);
    if(IsPlayerInRangeOfPoint(targetid,distance,x,y,z))
    {
        return true;
    }
    return false;
}
The parameters are self explanatory (hopefully you understand them). And example could be as followed:

pawn Код:
public OnPlayerText(playerid, text[])
{
    new pname[24], string[128];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PlayerToPlayer(playerid,i,7))
        {
            strreplace(pname, '_', ' ');
            format(string, sizeof(string), "%s says: %s", pname, text);
            SendClientMessage(i, COLOR_WHITE, string);
        }
    }
    return 0;
}
Above states that when a player sends text (just text, no command) it will loop through every player to check if they are near him. If they are, they continue on, if not, no text will be sent you them. Hope I explained it well enough.
Reply
#3

Yeah this works thanks but when I talk it still sends a message (under pname says: ) to everyone, how do i get rid of default message sending to all?
Reply
#4

Under OnPlayerText instead of return 1; it's return 0;
That will get rid of the default SAMP chat.
Reply
#5

oh cool thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)