Jump to content

HELP, Vehicle Parts!


.:HyPeX:.

Recommended Posts

Hello, i'm trying to know when a player is crashed in the rear bumper.. will this work or whats the correct name of rear bumper for a script?

PD: i'm ussing onClientVehicleCollision - https://wiki.multitheftauto.com/wiki/On ... eCollision

  
function PassTheFlag(Attacker, force, bodypart, X, Y, Z, NX, NY, NZ, HitElementForce, model) 
if localplayer == FlagHolder then 
    if bodypart == rearbumper then 
  

PD: how could i know if a vehicle is "turned"? (with the wheels facing the sky)

Link to comment
PD: how could i know if a vehicle is "turned"? (with the wheels facing the sky)

Try this:

local Xr,Yr,Zr = getElementRotation(vehicle) 
  
if Xr > 90 and Xr < 270 and Yr > 90 and Yr < 270 then 
  
end 

Yeah, did that some time ago:

  
FlagCheck = setTimer(FlagDropped, 500, 0) 
function FlagDropped() 
local vehicle = getPedOccupiedVehicle( localplayer ) 
local rx, ry, rz = getElementRotation( vehicle ) 
local x, y, z = getElementPosition( vehicle ) 
if localplayer == FlagHolder then 
if rx > 100 and rx < 260 or ry > 100 and ry < 260 then 
Flag = createMarker ( x, y, z, "checkpoint", 5, 0, 175, 255, 255 ) 
setMarkerColor(Flag, r, g, b, a) 
triggerEvent("OnFlagDrop") 
end 
end 
end 

-----------------

Any bump on the vehicle part problem, someone?

Link to comment
  • Moderators

I found some information about vehicle parts at this function a few months ago.

https://wiki.multitheftauto.com/wiki/ProcessLineOfSight

Not sure if those parts are sharing the same id, but I think they do.

For vehicles, piece represents the vehicle part hit:

0: Frame

2: Trunk

3: Hood

4: Rear

5: Front left door

6: Front right door

7: Rear left door

8: Rear right door

13: Front Left tyre

14: Front Right tyre

15: Back Left tyre

16: Back Right tyre

(Other potential IDs haven't been documented yet and might depend on vehicle model)

Link to comment

Well, to start with, as it says, it is a very high perfomance requieriment thing, and i cant simply call it every time a player crashes if there are 32 players.. it would'be a madness, not mentioning its a headache to make it work xD

Still searching for a better solution..

EDIT//

should this work?

  
function PassTheFlag(Attacker, force, bodypart, X, Y, Z, NX, NY, NZ, HitElementForce, model) 
local vehicle = getPedOccupiedVehicle( localplayer ) 
local lx, ly, lz = getElementPosition( vehicle ) 
local avehicle = getPedOccupiedVehicle( Attacker ) 
local ax, ay, az = getElementPosition( avehicle ) 
local hit, x, y, z, elementHit, nx, ny, nz, mat, light, part, id = processLineOfSight ( ax, ay, az, lx, ly, lz ) 
if localplayer == FlagHolder then 
    if part == 4 then 
    FlagHolder = Attacker 
    local uvehicle = getPedOccupiedVehicle( Attacker ) 
    setVehicleColor( uvehicle, 0, 255, 0 ) 
    local avehicle = getPedOccupiedVehicle( localplayer ) 
    setVehicleColor( avehicle, 255, 0, 0 ) 
    triggerEvent("OnFlagChange", Attacker) 
    outputChatBox("Your flag was stolen by ".. getPlayerName(Attacker), localplayer, 255,255,255, true) 
    else 
    outputChatBox("You were hit by ".. getPlayerName(Attacker) .." be carefull!", localplayer, 255,255,255, true) 
    end 
end     
end 
addEventHandler("OnClientVehicleCollision", getRootElement(), PassTheFlag) 
  

Link to comment
  • Moderators

Nope, some things have to be done serverside.

But this may give you a good start.

addEventHandler("onClientVehicleCollision", root,-- typo OnClientVehicleCollision 
function (Attacker, force, part, X, Y, Z, NX, NY, NZ, HitElementForce, model) 
    if getPedOccupiedVehicle( localPlayer ) == source then 
         
        if avehicle and getElementType(avehicle) == "vehicle" then 
            local Attacker = getVehicleController ( avehicle) 
            --local lx, ly, lz = getElementPosition( vehicle ) 
            --local ax, ay, az = getElementPosition( avehicle ) 
            --local hit, x, y, z, elementHit, nx, ny, nz, mat, light, part, id = processLineOfSight ( ax, ay, az, lx, ly, lz ) 
  
            --if localPlayer == FlagHolder then 
                if part == 4 then 
  
                end 
            --end     
        end 
    end 
end) 
  
  
--[[ should be done serverside 
  
FlagHolder = Attacker 
    setVehicleColor( uvehicle, 0, 255, 0 ) 
  
    setVehicleColor( avehicle, 255, 0, 0 ) 
--triggerEvent("OnFlagChange", Attacker) 
outputChatBox("Your flag was stolen by ".. getPlayerName(Attacker), localPlayer, 255,255,255, true) 
else 
outputChatBox("You were hit by ".. getPlayerName(Attacker) .." be carefull!", localPlayer, 255,255,255, true) 
                 
]] 

Link to comment
  • Moderators
what do you mean much addEventHandler ? there is just 1.

the much referred to the like, it should've been "i dont like that much..."

what mixes me, is the structure

You mean the way I attached the handler to the function?

You can always set it back...

Good luck!! :)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...