My question regarding a /whisper command
#1

So, I was thinking what I needed to script and in the back of my mind I remembered I needed a whisper command. I would like to know if the system I thought of would work and if it does, is there anyway I can improve it.

pawn Код:
CMD:whisper(playerid, params[])
{
    new tid, message[128], recieved[128];
    if(PlayerInfo[playerid][pAdmin] < 1)
    {
        new Float:x, Float:y, Float:z;
        GetPlayerPos(tid, x, y, x);
        if(sscanf(params, "ds", tid, message)) return SendClientMessage(playerid, COLOR_WHITE, "SYNTAX: /(w)hisper [playerid] [message]");
        if(IsPlayerInRangeOfPoint(playerid, 7, x, y, z)) return SendClientMessage(playerid, COLOR_WHITE, "You are not near that person!");
        else
        {
            format(message, sizeof(message), "You whispered to %s [%i]: %s", GetPlayerNameEx(tid), tid, message);
            SCM(playerid, COLOR_YELLOW, message);
            format(recieved, sizeof(recieved), "Whisper from %s [%i]: %s", GetPlayerNameEx(playerid), playerid, message);
            SCM(tid, COLOR_YELLOW, recieved);
        }
    }
    else
    {
        if(sscanf(params, "ds", tid, message)) return SendClientMessage(playerid, COLOR_WHITE, "SYNTAX: /(w)hisper [playerid] [message]");
        format(message, sizeof(message), "You whispered to %s [%i]: %s", GetPlayerNameEx(tid), tid, message);
        SCM(playerid, COLOR_YELLOW, message);
        format(recieved, sizeof(recieved), "Whisper from %s [%i]: %s", GetPlayerNameEx(playerid), playerid, message);
        SCM(tid, COLOR_YELLOW, recieved);
    }
    return 1;
}
Reply
#2

if(IsPlayerInRangeOfPoint(playerid, 7, x, y, z)) return SendClientMessage(playerid, COLOR_WHITE, "You are not near that person!");

change that to something closer, like 2.
and add like a Chatbubble to say above their head like "Player has whispered to player"
Reply
#3

Alright, sounds good. Thanks for the tip, I'll add that.

EDIT:

pawn Код:
format(string, sizeof(string), "%s turns towards %s, whispering something to them", GetPlayerNameEx(playerid), GetPlayerNameEx(tid));
SetPlayerChatBubble(playerid, string, COLOR_PURPLE, 10.0, 1000);
Reply
#4

pawn Код:
GetPlayerPos(tid, x, y, x);
if(sscanf(params, "ds", tid, message)) return SendClientMessage(playerid, COLOR_WHITE, "SYNTAX: /(w)hisper [playerid] [message]");
tid will be always 0. Use sscanf BEFORE.

pawn Код:
format(message, sizeof(message), "You whispered to %s [%i]: %s", GetPlayerNameEx(tid), tid, message);
SCM(playerid, COLOR_YELLOW, message);
Format recieved string because it will then send something like that:
pawn Код:
Whisper from ConnorHunter [1]: You whispered to dannyk0ed [0]: a message.
Sames goes in the else statement (not admins).
Reply
#5

Oh wow, completely looked over that, edited and adjusted. Thanks.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)