Jump to content

Vehicle Shop With Features


LasHa

Recommended Posts

Hello everyone. Guys i have just done vehicle shop with its f2 features window. I have done everything but small problem. i have added Hide button in f2 and when you are in vehicle it can hide car but i couldn't hide car when i am not in car please guys help :S

Here is code of Picking Car And Hiding Car

Picking Car

  
function pickCar(ownerName,carName) 
if getElementData(ownerName, "gotCar") == "no" then 
local getowner = getAccountName(getPlayerAccount(ownerName)) 
local carModel = getVehicleModelFromName(carName) 
local x,y,z = getElementPosition(ownerName) 
OwnerVehicle = createVehicle(carModel, x, y, z) 
setElementData(OwnerVehicle, "owner", tostring(gayowner)) 
setElementData(ownerName, "gotCar", "yes") 
local carlma = executeSQLQuery("SELECT * FROM carshops WHERE owner=?", getowner) 
else 
outputChatBox("You don't own a car", ownerName, 255, 0, 0) 
end 
end 
addEvent("spawn_dealer_car", true) 
addEventHandler("spawn_dealer_car", getRootElement(), spawn_car_pleaseD) 
  

Hide Car

  
function hideCar (ownerName) 
pedCar = getPedOccupiedVehicle(ownerName) 
getownerAcc = getAccountName(getPlayerAccount(ownerName)) 
if isPedInVehicle(ownerName) == true then 
if getElementData(ownerName, "gotCar") == "yes" and getElementData(pedCar, "owner") == getownerAcc then 
CurrentCar = getPedOccupiedVehicle(ownerName) 
destroyElement(CurrentCar) 
setElementData(ownerName, "gotCar", "no") 
else  
outputChatBox("You can't hide car that you don't have", ownerName, 255, 0, 0) 
end 
else  
outputChatBox("You can't hide, if you are not sit on it", ownerName, 255, 0, 0) 
end 
end 
addEvent("destroy_dealer_car", true) 
addEventHandler("destroy_dealer_car", getRootElement(), destroy_car_pleaseD) 
  
  

Edited by Guest
Link to comment

You add the ID to retrieve it later use without the player.

setElementID ( OwnerVehicle, 'any_there' .. tostring(getowner) ) --    Element with ID 'any_there lashiko721'.  

You hide the car.

function funcHide () 
       destroyElement ( getElementByID ( 'any_there' .. tostring(getownerAcc) ) ) 
addEventHandler( 'onPlayerVehicleExit', getRootElement(), funcHide ) -- You can use your part of code without this. 
  
  

With setElementVisibleTo will not work - 'This does not work with all entities - vehicles, players and objects are exempt.'.

Link to comment
you didn't understand me i don't want to hide car when i exiting it, i want to hide car not only the time when i'm inside i want to hide it everytime when i am just like. 5000 meters next to the car
addEventHandler( 'onPlayerVehicleExit', getRootElement(), funcHide ) -- You can use your part of code without this. 

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