02.05.2015, 18:10
I made a /pay command but i want to see if targetid is in ranger of playerid how can i do that and what includes will i need?
stock IsPlayerCloseToPlayer(playerid, lookupid, Float:distance)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(lookupid, x, y, z);
if(IsPlayerInRangeOfPoint(playerid, distance, x, y, z) && GetPlayerInterior(playerid) == GetPlayerInterior(lookupid) && \
GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(lookupid) && GetPlayerState(playerid) != PLAYER_STATE_SPECTATING &&
GetPlayerState(lookupid) != PLAYER_STATE_SPECTATING) return true;
return false;
}
stock GetDistanceBetweenPlayers(playerid, playerid2) { new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2; new Float:dis; GetPlayerPos(playerid,x1,y1,z1); GetPlayerPos(playerid2,x2,y2,z2); dis = floatsqroot((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1)); return floatround(dis); }
CMD:pay(playerid, params[])
First of all, you need a stock, like so:
Код:
stock GetDistanceBetweenPlayers(playerid, playerid2) { new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2; new Float:dis; GetPlayerPos(playerid,x1,y1,z1); GetPlayerPos(playerid2,x2,y2,z2); dis = floatsqroot((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1)); return floatround(dis); } Create the command, which would be " Код:
CMD:pay(playerid, params[]) Afterwards, we have to create a 1 time variable, which would hold the ID of the player who is being paid. Example: new id; Once you have done everything including both IDs and the initial command itself, measure the distance between both players, via the following: if(GetDistanceBetweenPlayers(playerid, id) < 7) - You can choose whichever range you need. That is pretty much all there is too it. |