Adde Posted August 21, 2013 Share Posted August 21, 2013 Hello I wounder how I can change this function so only 1 car can be spawned and used at the time. Example: spawns a car and can´t spawn a new untill that car is destroyed/blowed/in water. Or make it spawn/hide function spawnCar() if ( not isPedInVehicle ( source ) ) then local x, y, z = getElementPosition ( source ) local car = createVehicle ( 587, x, y, z ) setVehicleColor(car,20,20,20,30,30,30) warpPedIntoVehicle(source, car) setVehicleHeadLightColor(car,0,0,255) addVehicleSirens(car,1,2) setVehicleSirens(car,1,0,0.7,0.35,255,0,255) end end addEvent("vehicleSpawn",true) addEventHandler("vehicleSpawn",getRootElement(),spawnCar) Link to comment
iPrestege Posted August 21, 2013 Share Posted August 21, 2013 Try this : ReturnVehicle = { } function spawnCar ( ) if not isPedInVehicle ( source ) and not ReturnVehicle [ source ] and not isElement ( ReturnVehicle [ source ] ) then local x, y, z = getElementPosition ( source ) ReturnVehicle [ source ] = createVehicle ( 587, x, y, z ) if ReturnVehicle [ source ] and isElement ( ReturnVehicle [ source ] ) then setVehicleColor ( ReturnVehicle [ source ],20,20,20,30,30,30 ) warpPedIntoVehicle ( source,ReturnVehicle [ source ] ) setVehicleHeadLightColor( ReturnVehicle [ source ],0,0,255 ) addVehicleSirens ( ReturnVehicle [ source ],1,2 ) setVehicleSirens ( ReturnVehicle [ source ],1,0,0.7,0.35,255,0,255 ) end end end addEvent("vehicleSpawn",true) addEventHandler("vehicleSpawn",getRootElement(),spawnCar) Link to comment
Adde Posted August 21, 2013 Author Share Posted August 21, 2013 Try this : ReturnVehicle = { } function spawnCar ( ) if not isPedInVehicle ( source ) and not ReturnVehicle [ source ] and not isElement ( ReturnVehicle [ source ] ) then local x, y, z = getElementPosition ( source ) ReturnVehicle [ source ] = createVehicle ( 587, x, y, z ) if ReturnVehicle [ source ] and isElement ( ReturnVehicle [ source ] ) then setVehicleColor ( ReturnVehicle [ source ],20,20,20,30,30,30 ) warpPedIntoVehicle ( source,ReturnVehicle [ source ] ) setVehicleHeadLightColor( ReturnVehicle [ source ],0,0,255 ) addVehicleSirens ( ReturnVehicle [ source ],1,2 ) setVehicleSirens ( ReturnVehicle [ source ],1,0,0.7,0.35,255,0,255 ) end end end addEvent("vehicleSpawn",true) addEventHandler("vehicleSpawn",getRootElement(),spawnCar) It began good. I couldn´t spawn a new when the car was spawned. But I couldn´t spawn when it was blown neither Link to comment
iPrestege Posted August 21, 2013 Share Posted August 21, 2013 ReturnVehicle = { } function spawnCar ( ) if not isPedInVehicle ( source ) and not ReturnVehicle [ source ] and not isElement ( ReturnVehicle [ source ] ) then local x, y, z = getElementPosition ( source ) ReturnVehicle [ source ] = createVehicle ( 587, x, y, z ) if ReturnVehicle [ source ] and isElement ( ReturnVehicle [ source ] ) then setVehicleColor ( ReturnVehicle [ source ],20,20,20,30,30,30 ) warpPedIntoVehicle ( source,ReturnVehicle [ source ] ) setVehicleHeadLightColor( ReturnVehicle [ source ],0,0,255 ) addVehicleSirens ( ReturnVehicle [ source ],1,2 ) setVehicleSirens ( ReturnVehicle [ source ],1,0,0.7,0.35,255,0,255 ) end end end addEvent("vehicleSpawn",true) addEventHandler("vehicleSpawn",getRootElement(),spawnCar) addEventHandler('onVehicleExplode',root, function ( ) if source == ReturnVehicle [ source ] and isElement ( ReturnVehicle [ source ] ) then destroyElement ( ReturnVehicle [ source ] ) ReturnVehicle [ source ] = nil end end ) Link to comment
Adde Posted August 21, 2013 Author Share Posted August 21, 2013 Nah don´t work Same problem Link to comment
Castillo Posted August 21, 2013 Share Posted August 21, 2013 local vehicles = { } function spawnCar ( ) if ( not isPedInVehicle ( source ) ) then if ( isElement ( vehicles [ source ] ) and isElementInWater ( vehicles [ source ] ) or isVehicleBlown ( vehicles [ source ] ) or not isElement ( vehicles [ source ] ) ) then local x, y, z = getElementPosition ( source ) vehicles [ source ] = createVehicle ( 587, x, y, z ) setVehicleColor ( vehicles [ source ], 20, 20, 20, 30, 30, 30 ) warpPedIntoVehicle ( source, vehicles [ source ] ) setVehicleHeadLightColor ( vehicles [ source ], 0, 0, 255 ) addVehicleSirens ( vehicles [ source ], 1, 2 ) setVehicleSirens ( vehicles [ source ], 1, 0, 0.7, 0.35, 255, 0, 255 ) end end end addEvent ( "vehicleSpawn", true ) addEventHandler ( "vehicleSpawn", getRootElement(), spawnCar ) Try that. Link to comment
Adde Posted August 22, 2013 Author Share Posted August 22, 2013 Thanks Castillo, it works. You´re the man ;D Btw, should local account = getPlayerAccount(source) local accName1 = getAccountName ( account ) if isObjectInACLGroup ("user."..accName1, aclGetGroup ( "VIP" ) ) then not be used in client side? Because I am trying to make a GUI available for that ACL group. Link to comment
golanu21 Posted August 22, 2013 Share Posted August 22, 2013 Thanks Castillo, it works. You´re the man ;DBtw, should local account = getPlayerAccount(source) local accName1 = getAccountName ( account ) if isObjectInACLGroup ("user."..accName1, aclGetGroup ( "VIP" ) ) then not be used in client side? Because I am trying to make a GUI available for that ACL group. no, because getPlayerAccount, getAccountName, isObjectInACLGroup... it's avabile just in server side, you need to do a triggerClientEvent.. Link to comment
Adde Posted August 22, 2013 Author Share Posted August 22, 2013 Thanks Castillo, it works. You´re the man ;DBtw, should local account = getPlayerAccount(source) local accName1 = getAccountName ( account ) if isObjectInACLGroup ("user."..accName1, aclGetGroup ( "VIP" ) ) then not be used in client side? Because I am trying to make a GUI available for that ACL group. no, because getPlayerAccount, getAccountName, isObjectInACLGroup... it's avabile just in server side, you need to do a triggerClientEvent.. Oh, okay. Thanks for answearing 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