SA-MP Forums Archive
Object hit a player giving 2 reps - 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: Object hit a player giving 2 reps (/showthread.php?tid=510860)



Object hit a player giving 2 reps - iBots - 02.05.2014

Hey,i am making a system,but i need help,i want to make an object,when i click on Z it throws a ball ,how can i make the ball keep moving forward till it hit a player,and when it hit a player it grts destroyed,like when i click on Z it makes an object and moves it forward with the same float Z,just moves forward and destroys when it hit a player,how to detect if it hits a player?
Giving 2 reps


Re: Object hit a player giving 2 reps - Aerotactics - 02.05.2014

Well...
1) get the player's coords
2) create a ball object at those coords that moves towards the direction you are facing
3) create a timer that checks the area around the ball, if another player is in that area the ball disappears

It sounds difficult, but I think you get the point.


Re: Object hit a player giving 2 reps - iBots - 03.05.2014

how could i get the direction i am facing ,i mean how to let it move forward?


Re: Object hit a player giving 2 reps - Rapgangsta - 03.05.2014

GetXYInFrontOfPlayer(playerid, &Float, &Float:y, Float:distance)
{
new Float:a;
GetPlayerPos(playerid, x, y, a);
GetPlayerFacingAngle(playerid, a);
if (GetPlayerVehicleID(playerid))
{
GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
}
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
}