15.03.2017, 04:19
i saw many server makes whisper chat, like /whisper [ID] [message] and this chat only use in range 5m, Can you give me this script with sscanf?
I can give you the needed tools to make it
https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint https://sampwiki.blast.hk/wiki/Control_S...res#for_.28.29 https://sampwiki.blast.hk/wiki/Fast_Commands |
stock GetName(playerid) { new Name[MAX_PLAYER_NAME]; if(IsPlayerConnected(playerid)) { GetPlayerName(playerid, Name, sizeof(Name)); strreplace(Name, '_', ' '); } else { Name = "Disconnected/Nothing"; } return Name; }
#define WHITE 0xFFFFFFFF #define SERVER 0xFF6347FF #define YELLOW 0xFFFF00FF
command(w, playerid, params[]) { new id, string[128], message[128]; if(sscanf(params, "uz", id, message)) { SendClientMessage(playerid, SERVER, "SERVER:{FFFFFF} /w(hisper) [Playerid] [Message]"); } else { if(IsPlayerConnectedEx(id) && GetDistanceBetweenPlayers(playerid, id)) { format(string, sizeof(string), "Whisper sent to %s: %s", GetName(id), message); SendClientMessage(playerid, YELLOW, string); format(string, sizeof(string), "%s whispers: %s", GetName(playerid), message); SendClientMessage(id, YELLOW, string); } else { SendClientMessage(playerid, WHITE, "You're too far away from that player."); } } return 1; }
D:\Server\filterscripts\RP_Commands.pwn(201) : error 017: undefined symbol "strreplace" D:\Server\filterscripts\RP_Commands.pwn(219) : error 017: undefined symbol "IsPlayerConnectedEx" |
CMD:wisper(playerid, params[])
{
new string[128],id,mess[250],giveplayer[25],sendername[25];
if(sscanf(params, "us[250]",id,mess)) return SendClientMessage(playerid, -1, "{FFFFFF}Syntax: {FFFFFF}/w <Name/Playerid> <Message>");
if(id != INVALID_PLAYER_ID)
{
if(GetDistanceBetweenPlayers(playerid,id) > 5) return SendClientMessage(playerid,-1,"{FFFFCC}This player is not near you.");
if(id == playerid) return SendClientMessage(playerid, -1,"{FFB870}You can not send a message to yourself.");
GetPlayerName(playerid, sendername, sizeof(sendername));
GetPlayerName(id, giveplayer, sizeof(giveplayer));
format(string, sizeof(string), "{00DBDB}%s whispers: %s", sendername, mess);
SendClientMessage(id, -1, string);
format(string, sizeof(string), "{00DBDB}Whisper to %s: %s", giveplayer, mess);
SendClientMessage(playerid, -1, string);
return 1;
}
}
alias:wisper("w");
D:\Server\filterscripts\RP_Commands.pwn(192) : error 017: undefined symbol "GetDistanceBetweenPlayers" D:\Server\filterscripts\RP_Commands.pwn(202) : warning 209: function "cmd_w" should return a value |
Enjoy it
PHP код:
|
CMD:whisper(playerid, params[])
{
new string[128],
playerName[MAX_PLAYER_NAME],
target,
Float:x,
Float:y,
Float:z;
if(sscanf(params, "us[128]", target, string))
return SendClientMessage(playerid, -1, "Syntax: /w <Name/Playerid> <Message>");
if(!IsPlayerConnected(target))
return SendClientMessage(playerid, -1, "This player is not connected.");
if(target == playerid)
return SendClientMessage(playerid, 0xFFB870ff, "You can not send a message to yourself.");
GetPlayerPos(playerid, x, y, z);
if(!IsPlayerInRangeOfPoint(target, 3.0, x, y, z))
return SendClientMessage(playerid, 0xFFFFCCff, "This player is not near you.");
GetPlayerName(playerid, playerName, sizeof(playerName));
format(string, sizeof(string), "%s whispers: %s", playerName, string);
SendClientMessage(target, 0x00DBDBff, string);
GetPlayerName(target, playerName, sizeof(playerName));
format(string, sizeof(string), "Whisper to %s: %s", playerName, string);
SendClientMessage(playerid, 0x00DBDBff, string);
return 1;
}