isa_Khamdan Posted August 10, 2013 Share Posted August 10, 2013 How can I make this code works for vehicles too , this code works for the players only when they leave the marker but I want it for vehicles too so when the vehicle leave the marker ( destroyed or warped to another place ) it will do the functions so can anyone help me? addEventHandler( "onMarkerLeave", getRootElement( ), function( ) local veh = getPlayerOccupiedVehicle( source ) if veh then local driver = getVehicleController( veh ) if driver == source then if getVehicleModShop( veh ) then unfreezeVehicleInModShop( veh ) setModShopBusy( shop, 0, false ) triggerClientEvent( source, "modShop_moddingConfirmed", source ) end end end end ) Link to comment
tosfera Posted August 10, 2013 Share Posted August 10, 2013 You want to do what? its only working for vehicle's right now. local veh = getPlayerOccupiedVehicle( source ) if veh then or do you want it like; when the vehicle explodes, it stops. When the player gets out of the car, it stops? This function might be the one thats bugging you; onVehicleStartExit -- source: [url=https://wiki.multitheftauto.com/wiki/OnVehicleStartExit]https://wiki.multitheftauto.com/wiki/OnVehicleStartExit[/url] Link to comment
isa_Khamdan Posted August 10, 2013 Author Share Posted August 10, 2013 You want to do what? its only working for vehicle's right now. local veh = getPlayerOccupiedVehicle( source ) if veh then or do you want it like; when the vehicle explodes, it stops. When the player gets out of the car, it stops? This function might be the one thats bugging you; onVehicleStartExit -- source: [url=https://wiki.multitheftauto.com/wiki/OnVehicleStartExit]https://wiki.multitheftauto.com/wiki/OnVehicleStartExit[/url] No I want it that if the vehicle leave the marker in any way ( destroyed , warped or anythings ) Edit : the code works only if the player leaves the marker Link to comment
tosfera Posted August 10, 2013 Share Posted August 10, 2013 okee well you got a few ways to get it out of the marker; onVehicleExplode() -- if it gets blown up onVehicleStartExit() -- if the player gets out of the car You dont got one for warped or destroyed. 'Cause the vehicle can only be destroyed if an admin destroys it. not in another way (oke, spawning millions of new vehicle's...). Link to comment
isa_Khamdan Posted August 10, 2013 Author Share Posted August 10, 2013 okee well you got a few ways to get it out of the marker; onVehicleExplode() -- if it gets blown up onVehicleStartExit() -- if the player gets out of the car You dont got one for warped or destroyed. 'Cause the vehicle can only be destroyed if an admin destroys it. not in another way (oke, spawning millions of new vehicle's...). ok I made it work but what if the player created another car and the old one gone or what if he just used the map and teleported to another place? Link to comment
tosfera Posted August 10, 2013 Share Posted August 10, 2013 Disable the menu to create new vehicle's, also the command plus the way to teleport away! You can do that with this function; isElement You can see if the element is an actual element on that time, for example; the GUI thats openend. Link to comment
isa_Khamdan Posted August 10, 2013 Author Share Posted August 10, 2013 Disable the menu to create new vehicle's, also the command plus the way to teleport away! You can do that with this function; isElement You can see if the element is an actual element on that time, for example; the GUI thats openend. People can use freeroam to do these things ( warp , Create ) is it possible to disable it in the modshop area? Link to comment
tosfera Posted August 10, 2013 Share Posted August 10, 2013 Yes it is, open the freeroam source and search for the bindkey of F1, then look for the function that shows the GUI. Under the Function add this; if ( getPedOccupiedVehicle ( source ) ) then if ( getVehicleModShop( getPedOccupiedVehicle( source ) ) ) then return; end end also for the command; cv. Do the same, find the command with the linked function, add the line under the function and restart freeroam. Link to comment
isa_Khamdan Posted August 10, 2013 Author Share Posted August 10, 2013 Yes it is, open the freeroam source and search for the bindkey of F1, then look for the function that shows the GUI. Under the Function add this; if ( getPedOccupiedVehicle ( source ) ) then if ( getVehicleModShop( getPedOccupiedVehicle( source ) ) ) then return; end end also for the command; cv. Do the same, find the command with the linked function, add the line under the function and restart freeroam. I found another way to do that but I am having a problem how can I cancel the event that open the modshop gui? I made this code but it didn't work addEventHandler( "onMarkerLeave", getRootElement( ), function( ) local veh = getPlayerOccupiedVehicle( source ) if veh then local driver = getVehicleController( veh ) if driver == source then if getVehicleModShop( veh ) then unfreezeVehicleInModShop( veh ) triggerClientEvent( source, "modShop_moddingConfirmed", source ) else cancelEvent () triggerClientEvent( driver, "onClientPlayerEnterModShop", player, vehicle, getPlayerMoney( player ), modShops[ k ].name ) end end end end ) Link to comment
tosfera Posted August 10, 2013 Share Posted August 10, 2013 You can't cancel a triggerClientEvent nor triggerServerEvent. You can only cancel eventHandlers. Link to comment
isa_Khamdan Posted August 10, 2013 Author Share Posted August 10, 2013 You can't cancel a triggerClientEvent nor triggerServerEvent. You can only cancel eventHandlers. So there is no way to cancel client events? Edit what about your way ( the mod shop isn't part of the freeroam resource ) will it work? if ( getPedOccupiedVehicle ( source ) ) then if ( getVehicleModShop( getPedOccupiedVehicle( source ) ) ) then return; end end Link to comment
tosfera Posted August 10, 2013 Share Posted August 10, 2013 If you add it to the right functions on the right places, it will. 100% sure. Link to comment
isa_Khamdan Posted August 10, 2013 Author Share Posted August 10, 2013 If you add it to the right functions on the right places, it will. 100% sure. Like this? addEventHandler('onClientResourceStart', g_ResRoot, function() if ( getPedOccupiedVehicle ( source ) ) then if ( getVehicleModShop( getPedOccupiedVehicle( source ) ) ) then return; end end fadeCamera(true) setTimer(getPlayers, 1000, 1) bindKey('f1', 'down', toggleFRWindow) createWindow(wndMain) hideAllWindows() guiCheckBoxSetSelected(getControl(wndMain, 'Jetpack'), doesPedHaveJetPack(g_Me)) guiCheckBoxSetSelected(getControl(wndMain, 'Falloff'), canPedBeKnockedOffBike(g_Me)) setJetpackMaxHeight ( 9001 ) triggerServerEvent('onLoadedAtClient', g_ResRoot, g_Me) end ) Link to comment
tosfera Posted August 10, 2013 Share Posted August 10, 2013 Nope, find this function: toggleFRWindow There will be something like; function toggleFRWindow() Under that line, add my code. Link to comment
isa_Khamdan Posted August 10, 2013 Author Share Posted August 10, 2013 Nope, find this function: toggleFRWindow There will be something like; function toggleFRWindow() Under that line, add my code. Like this function toggleFRWindow() if ( getPedOccupiedVehicle ( source ) ) then if ( getVehicleModShop( getPedOccupiedVehicle( source ) ) ) then return; end end if isWindowOpen(wndMain) then showCursor(false) hideAllWindows() colorPicker.closeSelect() else showCursor(true) showAllWindows() end end addCommandHandler('fr', toggleFRWindow) Edit : I tested it but it didn't work? Link to comment
tosfera Posted August 10, 2013 Share Posted August 10, 2013 is it a client sided script? if so, change the source in my code to getLocalPlayer() Link to comment
isa_Khamdan Posted August 10, 2013 Author Share Posted August 10, 2013 is it a client sided script? if so, change the source in my code to getLocalPlayer() It is 50p Modshop script Edit : can you give me the code so I can test it? I didn't understand what did you mean about changing the source Link to comment
tosfera Posted August 10, 2013 Share Posted August 10, 2013 function toggleFRWindow() if ( getPedOccupiedVehicle ( getLocalPlayer() ) ) then if ( getVehicleModShop( getPedOccupiedVehicle( getLocalPlayer() ) ) ) then return; end end if isWindowOpen(wndMain) then showCursor(false) hideAllWindows() colorPicker.closeSelect() else showCursor(true) showAllWindows() end end addCommandHandler('fr', toggleFRWindow) try that. Link to comment
isa_Khamdan Posted August 10, 2013 Author Share Posted August 10, 2013 lol now you can't even open freeroam when you are inside the car even if you are not in the modshop 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