Jump to content

Changing vehicle


Mefisto_PL

Recommended Posts

Ehh.. I've got a new problem. I made this code and I know that is wrong, because debugscript said that I haven't 3 argument at getElementData. I think that I haven't ID this car or something like that.

function nowyPojazd ( vehicle, thePlayer ) 
local oldVehicle = getElementData ( thePlayer, "vehicle_owner" ) 
    if ( oldVehicle ~= false ) then 
    removeElementData ( oldVehicle, "veh_owner" ) 
    setVehicleLocked ( oldVehicle, false ) 
    end 
    setElementData ( vehicle, "veh_owner", thePlayer ) 
    setElementData ( thePlayer, "vehicle_owner", vehicle ) 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), nowyPojazd ) 

Link to comment

From when "onVehicleStartEnter" return as first element the vehicle ??

vehicle is the source.

function nowyPojazd (  thePlayer ) 
  
local oldVehicle = getElementData ( thePlayer, "vehicle_owner" ) 
    if ( oldVehicle ~= false ) then 
    removeElementData ( oldVehicle, "veh_owner" ) 
    setVehicleLocked ( oldVehicle, false ) 
    end 
    setElementData ( source, "veh_owner", thePlayer ) 
    setElementData ( thePlayer, "vehicle_owner", source ) 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), nowyPojazd ) 

Link to comment

Okay, now 0 errors, but it doesn't making a vehicle owner. ( veh_owner = owner ) ( vehicle_owner = vehicle ) ( pojazd = vehicle ) Full function here:

function wlascicielPojazdu ( thePlayer ) 
local acc = getPlayerAccount ( thePlayer ) 
if (not acc or isGuestAccount ( acc )) then return end 
local accName = getAccountName ( acc ) 
local pojazd = getPedOccupiedVehicle ( thePlayer ) 
    if pojazd and not getElementData ( pojazd, "veh_owner" ) then 
        setElementData ( pojazd, "veh_owner", accName ) 
        setElementData ( thePlayer, "vehicle_owner", pojazd ) 
    end 
    local oldVehicle = getElementData ( thePlayer, "vehicle_owner" ) 
    if ( oldVehicle ~= false ) then 
    removeElementData ( oldVehicle, "veh_owner" ) 
    setVehicleLocked ( oldVehicle, false ) 
    end 
    setElementData ( source, "veh_owner", thePlayer ) 
    setElementData ( thePlayer, "vehicle_owner", source ) 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), wlascicielPojazdu ) 

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