Repair vehicle from behind. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Repair vehicle from behind. (
/showthread.php?tid=538093)
Repair vehicle from behind. -
DownDuckling - 19.09.2014
Hi, I'm trying to make a /repair command that you need to be behind the car to repair it. Sort of like CrazyBob's /vehrepair command. Thx!
Re: Repair vehicle from behind. -
PMH - 19.09.2014
So? this is scripting help section, not a request forum..
Re: Repair vehicle from behind. -
TakeiT - 19.09.2014
Quote:
Originally Posted by PMH
So? this is scripting help section, not a request forum..
|
No need to be a dick, nowhere did he say he was asking for a command, he was asking how to do it.
My guess would be to use GetVehiclePos, which will get the center of the vehicle. Then you'll need to create an object and attach it to near the back with AttachObjectToVehicle. Take the Y parameter (say it's 1) then use if(IsPlayerInRangeOfPoint(playerid, X, Y-1, Z)
{
etc.
Re: Repair vehicle from behind. -
PMH - 19.09.2014
Quote:
Originally Posted by TakeiT
No need to be a dick, nowhere did he say he was asking for a command, he was asking how to do it..
|
Agreed, took it wrong way..
Re: Repair vehicle from behind. -
DownDuckling - 19.09.2014
Is there a function I could use to make it more simple? I saw it on a thread, but I cannot find it now
Re: Repair vehicle from behind. -
PMH - 19.09.2014
for what TakeIT has stated i made this stock function using his idea.. it may work or may not..
pawn Код:
stock IsPlayerNearVehicle(playerid, vehid)
{
new Float:X, Float:Y, Float:Z;
GetVehiclePos(vehid, X, Y, Z);
IsPlayerInRangeOfPoint(playerid, 2, X, Y-2, Z) return 1;
return 0;
}
Re: Repair vehicle from behind. -
TakeiT - 19.09.2014
The IsPlayerInRangeOfPoint should be 2 instead of 10, maybe even 1
Re: Repair vehicle from behind. -
Marricio - 19.09.2014
Quote:
Originally Posted by Joe Staff
You can try this
pawn Код:
stock IsPlayerInFrontVehicle(playerid,vehicleid,Float:radius,Float:vehiclelength) { new Float:x,Float:y,Float:z,Float:a; GetVehiclePos(vehicleid, x, y, z); GetPlayerFacingAngle(vehicleid, a); x += (vehiclelength* floatsin(-a, degrees)); y += (vehiclelength* floatcos(-a, degrees)); return IsPlayerInRangeOfPoint(playerid,radius,x,y,z); }
'vehiclelength' would be the distance between the middle of the car to the front/back of it. (In your case you would set this to a negative number, i.e. -4.0)
'radius' would be the area of the spot inwhich the player must be. (i.e. 3.0)
|
That could help.