SA-MP Forums Archive
My question regarding a /whisper command - 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: My question regarding a /whisper command (/showthread.php?tid=487668)



My question regarding a /whisper command - ConnorHunter - 14.01.2014

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;
}



Re: My question regarding a /whisper command - dannyk0ed - 14.01.2014

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"


Re: My question regarding a /whisper command - ConnorHunter - 14.01.2014

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);



Re: My question regarding a /whisper command - Konstantinos - 14.01.2014

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).


Re: My question regarding a /whisper command - ConnorHunter - 14.01.2014

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