18.06.2012, 12:22
/whisper (sscanf/zcmd)
made by Romel
I create this because i'm boredI made a /whisper too, but i will not copy the code from there
so i will use made from scratch
Requirements:
- Little Experience in scripting
- sscanf which can be found here!
Click here if you are having the sscanf ID 0 bug!
- zcmd which can be found here!
Full Code:
Before i explain each part please don't copy this code first i'm just previewing.
I will explain the /whisper command after this moment (sorry if my english speaking is bad)
pawn Code:
CMD:whisper(playerid, params[])
{
new pname[MAX_PLAYER_NAME], str[128], Float:pPos[3];
if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, -1, "Syntax: /whisper <text>");
GetPlayerName(playerid, pname, sizeof(pname));
GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInRangeOfPoint(i, 10.0, pPos[0], pPos[1], pPos[2]))
{
format(str, sizeof(str), "[Whisper] %s: %s", pname, params);
SendClientMessage(i, -1, str);
}
}
return 1;
}
pawn Code:
new pname[MAX_PLAYER_NAME], str[128], Float:pPos[3];
str will be use to send a whisper message
pPos[3] will be use to get the player position (who use /whisper)
pawn Code:
if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, -1, "Syntax: /whisper <text>");
pawn Code:
GetPlayerName(playerid, pname, sizeof(pname));
GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
like i mention above ppos will be use for getting player pos
Note: In using GetPlayerPos, there must be Float tag in new pPos[3];
pawn Code:
for(new i = 0; i < MAX_PLAYERS; i++)
pawn Code:
if(IsPlayerInRangeOfPoint(i, 10.0, pPos[0], pPos[1], pPos[2]))
pawn Code:
format(str, sizeof(str), "[Whisper] %s: %s", pname, params);
pawn Code:
SendClientMessage(i, -1, str);
Note: -1 is not a invalid color, -1 means COLOR_WHITE, change -1 to your color defines
Finish:
pawn Code:
CMD:whisper(playerid, params[])
{
new pname[MAX_PLAYER_NAME], str[128], Float:pPos[3];
if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, -1, "Syntax: /whisper <text>");
GetPlayerName(playerid, pname, sizeof(pname));
GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInRangeOfPoint(i, 10.0, pPos[0], pPos[1], pPos[2]))
{
format(str, sizeof(str), "[Whisper] %s: %s", pname, params);
SendClientMessage(i, -1, str);
}
}
return 1;
}
Credits to Zeex for zcmd
and Credits to Me for tutorial
Have fun modifying your own made /whisper!