04.01.2010, 08:40
Hello and Happy New Year! ![Wink](images/smilies/wink.png)
I have a question about what i made here;
Im checking the xyinfront of a player and if an npc is standing there but now i want the player to check how far the distance is between the npc(other player).
I tried changing the inrangeofpoint part but that made the xyinfrontofme go mad![Sad](images/smilies/sad.gif)
So wich values doe i need to change and how?
Heres what i did;
![Wink](images/smilies/wink.png)
I have a question about what i made here;
Im checking the xyinfront of a player and if an npc is standing there but now i want the player to check how far the distance is between the npc(other player).
I tried changing the inrangeofpoint part but that made the xyinfrontofme go mad
![Sad](images/smilies/sad.gif)
So wich values doe i need to change and how?
Heres what i did;
Code:
new giveid[MAX_PLAYERS]; forward OnplayerCheckNPC(playerid);
Code:
stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance) { new Float:a; GetPlayerPos(playerid, x, y, a); GetPlayerFacingAngle(playerid, a); x += (distance * floatsin(-a, degrees)); y += (distance * floatcos(-a, degrees)); }
Code:
public OnplayerCheckNPC(playerid) { new Float:X, Float:Y, FLoat:Z; GetPlayerPos(playerid,X,Y,Z); GetXYInFrontOfPlayer(playerid, X, Y, 5.0); for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerInRangeOfPoint(i, 5.0, X,Y,Z)) { new keys, updown, leftright; GetPlayerKeys(playerid, keys, updown, leftright); if ((keys & 4) && (keys & 128)) { if (IsPlayerNPC(i)) { SendClientMessageToSkin(68, 0x00FF4096, "you are in front of me"); } } } }