04.05.2010, 17:58
Hi!
I need: If the player type a command , an object(a droid) will follow the player. I need if the object will behind the player.
I have tryed to create it but it doesn't works ,because it isn't behind the player.
Please help me!
This is the code:
And here is the GetXYBehindPlayer function:
I need: If the player type a command , an object(a droid) will follow the player. I need if the object will behind the player.
I have tryed to create it but it doesn't works ,because it isn't behind the player.
Please help me!
This is the code:
Код:
stock AttachPlayerDroid(playerid,droidid)//its same that objectid { new Float:X,Float:Y,Float:X1,Float:Y1,Float:Z1,Float:a; GetXYBehindPlayer(playerid, X, Y, 7); GetPlayerPos(playerid,X1,Y1,Z1); GetPlayerFacingAngle(playerid,a); if(GetPlayerVehicleID(playerid)) { GetVehicleZAngle(GetPlayerVehicleID(playerid), a); } new Float:x,Float:y,Float:x1,Float:y1; x = X-X1; y = Y-Y1; if(x < 0) { x1 -= x; }else{ x1 =x; } if(y < 0) { y1 -= y; }else{ y1 = y; } AttachObjectToPlayer(droidid,playerid,x1,y1,0,0,0,a+180); }
Код:
stock GetXYBehindPlayer(playerid, &Float:x2, &Float:y2, Float:distance) { new Float:a; GetPlayerPos(playerid, x2, y2, a); GetPlayerFacingAngle(playerid, a); if(GetPlayerVehicleID(playerid)) { GetVehicleZAngle(GetPlayerVehicleID(playerid), a); } x2 += (distance * floatsin(-a+180, degrees)); y2 += (distance * floatcos(-a+180, degrees)); }