#include <a_samp>
//DEFINE DCMD
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
//DEFINE DCMD
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(say,3, cmdtext);
return 0;
}
dcmd_say(playerid, params[])
{
new text[128],playername[MAX_PLAYER_NAME],string[128], Float:X,Float:Y,Float:Z, textcolor;
if (sscanf(params, "s", text)) SendClientMessage(playerid, 0xF6F600F6, "Usage: \"/say [text]\"");
else
{
GetPlayerName(playerid,playername,sizeof(playername));
format(string, sizeof(string), "%s:%s ",playername,text);
GetPlayerPos(playerid,X,Y,Z);
for(new i; i<MAX_PLAYERS; i++)
{
if(PlayerToPoint(5,i,X,Y,Z))
{
SendClientMessage(i,COLOR,string);
}
}
}
return 1;
}
//==========DEFINE PLAYERTOPOINT==========
PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
if(IsPlayerConnected(playerid))
{
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
tempposx = (oldposx -x);
tempposy = (oldposy -y);
tempposz = (oldposz -z);
if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
return 1;
}
}
return 0;
}
//==========DEFINE SSCANF==========
stock sscanf(string[], format[], {Float,_}:...)
{
new
formatPos = 0,
stringPos = 0,
paramPos = 2,
paramCount = numargs();
while (paramPos < paramCount && string[stringPos])
{
switch (format[formatPos++])
{
case '\0':
{
return 0;
}
case 'i', 'd':
{
new
neg = 1,
num = 0,
ch = string[stringPos];
if (ch == '-')
{
neg = -1;
ch = string[++stringPos];
}
do
{
stringPos++;
if (ch >= '0' && ch <= '9')
{
num = (num * 10) + (ch - '0');
}
else
{
return 1;
}
}
while ((ch = string[stringPos]) && ch != ' ');
setarg(paramPos, 0, num * neg);
}
case 'h', 'x':
{
new
ch,
num = 0;
while ((ch = string[stringPos++]))
{
switch (ch)
{
case 'x', 'X':
{
num = 0;
continue;
}
case '0' .. '9':
{
num = (num << 4) | (ch - '0');
}
case 'a' .. 'f':
{
num = (num << 4) | (ch - ('a' - 10));
}
case 'A' .. 'F':
{
num = (num << 4) | (ch - ('A' - 10));
}
case ' ':
{
break;
}
default:
{
return 1;
}
}
}
setarg(paramPos, 0, num);
}
case 'c':
{
setarg(paramPos, 0, string[stringPos++]);
}
case 'f':
{
new tmp[25];
strmid(tmp, string, stringPos, stringPos+sizeof(tmp)-2);
setarg(paramPos, 0, _:floatstr(tmp));
}
case 's', 'z':
{
new
i = 0,
ch;
if (format[formatPos])
{
while ((ch = string[stringPos++]) && ch != ' ')
{
setarg(paramPos, i++, ch);
}
if (!i) return 1;
}
else
{
while ((ch = string[stringPos++]))
{
setarg(paramPos, i++, ch);
}
}
stringPos--;
setarg(paramPos, i, '\0');
}
default:
{
continue;
}
}
while (string[stringPos] && string[stringPos] != ' ')
{
stringPos++;
}
while (string[stringPos] == ' ')
{
stringPos++;
}
paramPos++;
}
while (format[formatPos] == 'z') formatPos++;
return format[formatPos];
}
Or you can simply use the PlayerToPoint Function. PAWN Code: #include <a_samp> //DEFINE DCMD #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1 //DEFINE DCMD public OnPlayerCommandText(playerid, cmdtext[]) { dcmd(say,3, cmdtext); return 0; } dcmd_say(playerid, params[]) { new text[128],playername[MAX_PLAYER_NAME],string[128], Float:X,Float:Y,Float:Z, textcolor; if (sscanf(params, "s", text)) SendClientMessage(playerid, 0xF6F600F6, "Usage: \"/say [text]\""); else { GetPlayerName(playerid,playername,sizeof(playernam e)); format(string, sizeof(string), "%s:%s ",playername,text); GetPlayerPos(playerid,X,Y,Z); for(new i; i<MAX_PLAYERS; i++) { if(PlayerToPoint(5,i,X,Y,Z)) { SendClientMessage(i,COLOR,string); } } } return 1; } //==========DEFINE PLAYERTOPOINT========== PlayerToPoint(Float:radi, playerid, Float ![]() { if(IsPlayerConnected(playerid)) { new Float ![]() ![]() ![]() new Float:tempposx, Float:tempposy, Float:tempposz; GetPlayerPos(playerid, oldposx, oldposy, oldposz); |
public OnGameModeInit()
{
LimitGlobalChatRadius(20.0);
return 1;
}