LasHa Posted May 18, 2014 Share Posted May 18, 2014 (edited) 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 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 May 20, 2014 by Guest Link to comment
nikitafloy Posted May 18, 2014 Share Posted May 18, 2014 You can specify the element ID, an event when a player comes out of the car and remove the visibility for the player. Link to comment
LasHa Posted May 20, 2014 Author Share Posted May 20, 2014 nikitafloy please show me an example change it please i can't understand like tihs Link to comment
nikitafloy Posted May 21, 2014 Share Posted May 21, 2014 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
LasHa Posted May 21, 2014 Author Share Posted May 21, 2014 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 Link to comment
Chronic Posted May 21, 2014 Share Posted May 21, 2014 Assuming the Picking Car and Hiding Car are in the same script, you could use destroyElement ( OwnerVehicle ) Link to comment
nikitafloy Posted May 22, 2014 Share Posted May 22, 2014 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now