Jump to content

ElementData problem


top sniper

Recommended Posts

function jajwarp(thePlayer) 
     for _,k in ipairs (getAttachedElements(thePlayer)) do 
          if getElementType( k ) == "player" then 
detachElements(k,thePlayer) 
warpPedIntoVehicle ( k, source,1) 
setElementData(thePlayer,"wasJailed",true) 
end 
end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), jajwarp) 
  
function jajwarps(thePlayer) 
local wasaaa = getElementData(thePlayer,"wasJailed") 
if wasaaa then 
     for _,k in ipairs (getAttachedElements(thePlayer)) do 
          if getElementType( k ) == "player" then 
          removePedFromVehicle ( k )  
attachElements ( k, thePlayer, 0, -1, 0 ) 
    setCameraTarget(k) 
setPedRotation ( k, 90 ) 
end 
end 
end 
end 
addEventHandler ( "onPlayerVehicleExit", getRootElement(), jajwarps) 
     

Link to comment
Guest Guest4401

In onVehicleEnter, source is vehicle and first parameter is thePlayer

But in onPlayerVehicle exit, source is player, and first parametre is theVehicle

Here you are setting elementData of player:

setElementData(thePlayer,"wasJailed",true) 

Here you are getting elementData of vehicle and not the player:

local wasaaa = getElementData(thePlayer,"wasJailed") 

Replacing onPlayerVehicleExit with onVehicleExit would perhaps make your job easier.

Link to comment
In onVehicleEnter, source is vehicle and first parameter is thePlayer

But in onPlayerVehicle exit, source is player, and first parametre is theVehicle

Here you are setting elementData of player:

setElementData(thePlayer,"wasJailed",true) 

Here you are getting elementData of vehicle and not the player:

local wasaaa = getElementData(thePlayer,"wasJailed") 

Replacing onPlayerVehicleExit with onVehicleExit would perhaps make your job easier.

so should be like this

function jajwarp(thePlayer) 
     for _,k in ipairs (getAttachedElements(thePlayer)) do 
          if getElementType( k ) == "player" then 
detachElements(k,thePlayer) 
warpPedIntoVehicle ( k, source,1) 
setElementData(thePlayer,"wasJailed",true) 
end 
end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), jajwarp) 
  
function jajwarps(thePlayer) 
local wasaaa = getElementData(thePlayer,"wasJailed") 
if wasaaa then 
     for _,k in ipairs (getAttachedElements(thePlayer)) do 
          if getElementType( k ) == "player" then 
          removePedFromVehicle ( k ) 
attachElements ( k, thePlayer, 0, -1, 0 ) 
    setCameraTarget(k) 
setPedRotation ( k, 90 ) 
end 
end 
end 
end 
addEventHandler ( "onVehicleExit", getRootElement(), jajwarps) 

Link to comment
In onVehicleEnter, source is vehicle and first parameter is thePlayer

But in onPlayerVehicle exit, source is player, and first parametre is theVehicle

Here you are setting elementData of player:

setElementData(thePlayer,"wasJailed",true) 

Here you are getting elementData of vehicle and not the player:

local wasaaa = getElementData(thePlayer,"wasJailed") 

Replacing onPlayerVehicleExit with onVehicleExit would perhaps make your job easier.

so should be like this

function jajwarp(thePlayer) 
     for _,k in ipairs (getAttachedElements(thePlayer)) do 
          if getElementType( k ) == "player" then 
detachElements(k,thePlayer) 
warpPedIntoVehicle ( k, source,1) 
setElementData(thePlayer,"wasJailed",true) 
end 
end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), jajwarp) 
  
function jajwarps(thePlayer) 
local wasaaa = getElementData(thePlayer,"wasJailed") 
if wasaaa then 
     for _,k in ipairs (getAttachedElements(thePlayer)) do 
          if getElementType( k ) == "player" then 
          removePedFromVehicle ( k ) 
attachElements ( k, thePlayer, 0, -1, 0 ) 
    setCameraTarget(k) 
setPedRotation ( k, 90 ) 
end 
end 
end 
end 
addEventHandler ( "onVehicleExit", getRootElement(), jajwarps) 

Worng !

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...