17.07.2009, 21:18
Thx yezizhu your script is very good(compact & effective), but I fixed it by creating a custom function wich I'll be able to use at any time for other commands.
I searched the forum and tutorials for 2 days to figure how to put something in front of a player and I've realized that this is something every new scripter will strugle with. So, here's how I did it. Now I should thx every one that helped by sharing info but at the moment I need to sort out the bits of code and where they came from. I will give credits to the people that helped later on.
Put this somewhere at the bottom of your script, make sure it's not in any callback or function ( between two: [])
To spawn something in front, behind, on the left or on the right you can now use the GetXY...OfPlayer() or GetXY...OfVehicle() functions just choose the distance between the player and the spawn point and use these coordinate in the code, like this:
Enjoy!! & keep me posted :P
I searched the forum and tutorials for 2 days to figure how to put something in front of a player and I've realized that this is something every new scripter will strugle with. So, here's how I did it. Now I should thx every one that helped by sharing info but at the moment I need to sort out the bits of code and where they came from. I will give credits to the people that helped later on.
Put this somewhere at the bottom of your script, make sure it's not in any callback or function ( between two: [])
Код:
//GET X Y IN FRONT OR BEHIND PLAYER--------------------------------------------- stock GetXYInFrontOfPlayer(playerid,&Float:x,&Float:y,Float:dis) { new float:pos[3]; new float:A; GetPlayerPos(playerid,pos[0],pos[1],pos[2]); GetPlayerFacingAngle(playerid,A); GetXYInFrontOfPoint(pos[0],pos[1],x,y,A,dis); } stock GetXYBehindPlayer(playerid,&Float:x,&Float:y,Float:dis) { new float:pos[3]; new float:A; GetPlayerPos(playerid,pos[0],pos[1],pos[2]); GetPlayerFacingAngle(playerid,A); GetXYBehindPoint(pos[0],pos[1],x,y,A,dis); } //GET X Y IN FRONT/BEHIND/LEFT/RIGHT OF POINT----------------------------------- stock GetXYInFrontOfPoint(Float:x,Float:y,&Float:x2,&Float:y2,Float:A,Float:distance) { x2 = x + (distance * floatsin(-A,degrees)); y2 = y + (distance * floatcos(-A,degrees)); } stock GetXYBehindPoint(Float:x,Float:y,&Float:x2,&Float:y2,Float:A,Float:distance) { x2 = x - (distance * floatsin(-A,degrees)); y2 = y - (distance * floatcos(-A,degrees)); } stock GetXYLeftOfPoint(Float:x,Float:y,&Float:x2,&Float:y2,Float:A,Float:distance) { x2 = x - (distance * floatsin(-A-90.0,degrees)); y2 = y - (distance * floatcos(-A-90.0,degrees)); } stock GetXYRightOfPoint(Float:x,Float:y,&Float:x2,&Float:y2,Float:A,Float:distance) { x2 = x - (distance * floatsin(-A+90.0,degrees)); y2 = y - (distance * floatcos(-A+90.0,degrees)); } //------------------------------------------------------------------------------ //GET X Y IN FRONT OR BEHIND OF VEHICLE----------------------------------------- stock GetXYInFrontOfVehicle(playerid,&Float:x,&Float:y,Float:dis) { new currentveh; new float:pos[3]; new float:A; currentveh = GetPlayerVehicleID(playerid); GetVehiclePos(currentveh,pos[0],pos[1],pos[2]); GetVehicleZAngle(currentveh,A); GetXYInFrontOfPoint(pos[0],pos[1],x,y,A,dis); } stock GetXYBehindVehicle(playerid,&Float:x,&Float:y,Float:dis) { new currentveh; new float:pos[3]; new float:A; currentveh = GetPlayerVehicleID(playerid); GetVehiclePos(currentveh,pos[0],pos[1],pos[2]); GetVehicleZAngle(currentveh,A); GetXYBehindPoint(pos[0],pos[1],x,y,A,dis); } //------------------------------------------------------------------------------
Код:
{ new currentveh; new float:x, float:y, float:z, float:X, float:Y; currentveh = GetPlayerVehicleID(playerid); GetXYInFrontOfVehicle(playerid,X,Y,400); GetVehiclePos(currentveh,x,y,z); SetPlayerCheckpoint(playerid,X,Y,z,10); return 1; }