Fireman job help - 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: Fireman job help (
/showthread.php?tid=602176)
Fireman job help -
StreetboyBalkan - 03.03.2016
I need a help in creating fireman job.I want to detect when player is aiming fire object with firetruck,but i can't find the working code..
Код:
if(HOLDING(KEY_FIRE) && GetVehicleModel(GetPlayerVehicleID(playerid)) == 407) {
new Float: fAimingCoords[3];
GetPlayerCameraPos(playerid, fAimingCoords[0], fAimingCoords[1], fAimingCoords[2]);
new Float: pos[3];
GetDynamicObjectPos(vatra[0], pos[0], pos[1], pos[2]);
if(IsPointInRangeOfPoint(pos[0], pos[1], pos[2], fAimingCoords[0], fAimingCoords[1], fAimingCoords[2], 3.0))
{
DestroyDynamicObject(vatra[0]);
}
}
stock IsPointInRangeOfPoint(Float:x, Float:y, Float:z, Float:x2, Float:y2, Float:z2, Float:range)
{
x2 -= x;
y2 -= y;
z2 -= z;
return ((x2 * x2) + (y2 * y2) + (z2 * z2)) < (range * range);
}
Re: Fireman job help -
Vince - 03.03.2016
The HOLDING macro is often used wrongly. What is usually desired is PRESSED and RELEASED. OnPlayerKeyStateChange is only called when a key
changes. You can press and then hold KEY_FIRE for an eternity but it will still only register a press when you first press it and a release when you release it. Only if you press an
additional while still holding KEY_FIRE will it register as holding.
You will need to set a timer when they first press the key and it and kill the timer when they release it. Alternatively, set and unset a variable and use OnPlayerUpdate if you require faster interaction.
Re: Fireman job help -
StreetboyBalkan - 04.03.2016
Okay,but that's not the problem,i get wrong aiming coords,i need to know if there is some other method to get aiming coords from firetruck...
Re: Fireman job help -
StreetboyBalkan - 05.03.2016
BUMP !
Re: Fireman job help -
StreetboyBalkan - 09.03.2016
Anybody knows?
Re: Fireman job help -
AbyssMorgan - 09.03.2016
tested, it works
PHP код:
public OnPlayerKeyStateChange(playerid,newkeys,oldkeys){
if(HOLDING(KEY_FIRE) && GetVehicleModel(GetPlayerVehicleID(playerid)) == 407) {
new Float:fAimingCoords[5],Float:NewCoords[3],Float:pos[3];
GetVehiclePos(GetPlayerVehicleID(playerid),fAimingCoords[0],fAimingCoords[1],fAimingCoords[2]);
GetPlayerCameraRotation(playerid,fAimingCoords[3],fAimingCoords[4]);
GetPointInFront3D(fAimingCoords[0],fAimingCoords[1],fAimingCoords[2],fAimingCoords[3],fAimingCoords[4],10.0,NewCoords[0],NewCoords[1],NewCoords[2]);
//Here you can do loops searching fire
GetDynamicObjectPos(vatra[0],pos[0],pos[1],pos[2]);
if(IsPointNearly2Points3D(pos[0],pos[1],pos[2],fAimingCoords[0],fAimingCoords[1],fAimingCoords[2],NewCoords[0],NewCoords[1],NewCoords[2],3.0)){
DestroyDynamicObject(vatra[0]);
}
}
return 1;
}
Include:
3DTryg.inc
Re: Fireman job help -
StreetboyBalkan - 10.03.2016
Thank you man,it works!! REP+