new tmp[256], tmp2[256], Index, aweaponrange;
new ammo, weap, WeapName[32], filestring[75];
new string[128];
tmp = strtok(params,Index);
tmp2 = strtok(params,Index);
aweaponrange = strval(params);
if(isnull(params)) return
SendClientMessage(playerid, LIGHTBLUE2, "Usage: /rangeweapon [WeaponID or WeaponName] [Ammo] [Range]");
if(!strlen(tmp2) || !IsNumeric(tmp2) || strval(tmp2) <= 0 || strval(tmp2) > 99999) ammo = 500; else ammo = strval(tmp2);
if(!IsNumeric(tmp))
weap = GetWeaponIDFromName(tmp);
else weap = strval(tmp);
if(!IsValidWeapon(weap))
return SendClientMessage(playerid,red,"ERROR: Invalid Weapon ID");
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(GetDistanceBetweenPlayers(playerid,i) < 10 && Specing[i] == 0)
{
if(IsPlayerConnected(i))
{
PlayerPlaySound(i,1057,0.0,0.0,0.0);
GivePlayerWeapon(i,weap,ammo);
}
}
}
Show the GetDistanceBetweenPlayers function, you could've gotten the xyz coords of the player and looped through all players to check isplayerinrangeofpoint of that one^
|
public Float:GetDistanceBetweenPlayers(p1,p2){
new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
if (!IsPlayerConnected(p1) || !IsPlayerConnected(p2)){
return -1.00;}
GetPlayerPos(p1,x1,y1,z1);
GetPlayerPos(p2,x2,y2,z2);
return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));}
if(GetDistanceBetweenPlayers(playerid,i) < 10 && Specing[i] == 0) {