Fabio(GNR) Posted September 26, 2010 Share Posted September 26, 2010 Well i edited the rocketcar script by phillyblunt https://community.multitheftauto.com/index.php?p=resources&s=details&id=810, i won't upload it ofcourse, but i could need some help... I have created 2 commands, /tr1 and /tr2 it sets toggle on or off, that sets toggle, in Rocket Car script if you press left shift you activate boost, and stops when released, /tr1 stands for Relase the key to stop, /tr2 to make it toggle (press lshift once, and again to stop) That works, but after it restores fuel, (you have fuel ) the binds in the tr1 and tr2 settings are gone, and i have to bind them again, anyway to automatically restore binds? Sorry if its the wrong place or not allowed to post topics about this, but i will learn something about scripting too thanks for your time. EDIT: will it work with executecommand or something?? Link to comment
dzek (varez) Posted September 26, 2010 Share Posted September 26, 2010 without giving us code - we can't help you, because we just CAN'T see what's wrong.. Link to comment
Fabio(GNR) Posted September 26, 2010 Author Share Posted September 26, 2010 without giving us code - we can't help you, because we just CAN'T see what's wrong.. Ok, i thought it maybe wasnt allowed to copy rresource's script on forum: --[[Version 1.1 Changes 1. When a player leaves his vehicle while using boost the rocket is deactivated, meter closes, and resuming acceleration on a vehicle will not activate rocket automaticly 2. Smoke is now serverside --]] addEvent ( "kill", true ) addEventHandler ( "onClientResourceStart", getResourceRootElement ( getThisResource() ), function() if getLocalPlayer() then bindKey ( "lshift", "up", ignition ) bindKey ( "lshift", "up", kill ) local sx, sy = guiGetScreenSize() fuelGauge = guiCreateProgressBar ( sx/4, sy/24, sx/2, sy/42, false ) guiSetVisible ( fuelGauge, false ) guiProgressBarSetProgress ( fuelGauge, 100 ) outputChatBox ( "Keys bound", 255, 255, 255 ) end end ) function ignition ( player ) if isPedInVehicle ( getLocalPlayer() ) then if getVehicleController ( getPedOccupiedVehicle ( getLocalPlayer() ) ) == getLocalPlayer() then if isVehicleOnGround ( getPedOccupiedVehicle ( getLocalPlayer() ) ) == true then if getAnalogControlState ( "accelerate" ) == 1 then if fuelAmmount > 0 then initiate = addEventHandler ( "onClientRender", getRootElement(), rocketBoost, getLocalPlayer() ) if initiate then guiSetVisible ( fuelGauge, true ) if fuelAmmount > 0 then triggerServerEvent ( "createSmoke", getLocalPlayer() ) smokeGenerator = "true" else if smokeGenerator then triggerServerEvent ( "killSmoke", getLocalPlayer() ) smokeGenerator = nil end end end end end end end end end function kill ( player ) if isPedInVehicle ( getLocalPlayer() ) then if getVehicleController ( getPedOccupiedVehicle ( getLocalPlayer() ) ) == getLocalPlayer() then removeEventHandler ( "onClientRender", getRootElement(), rocketBoost, player ) guiSetVisible ( fuelGauge, false ) if smokeGenerator then triggerServerEvent ( "killSmoke", getLocalPlayer() ) smokeGenerator = nil if guiGetVisible ( fuelGauge ) == true then guiSetVisible ( fuelGauge, false ) end end end end end fuelAmmount = 1300 boost = 1.03--default value is 1.01 subtractor = 3--default value function rocketBoost ( player ) if isPedInVehicle ( getLocalPlayer() ) then if getVehicleController ( getPedOccupiedVehicle ( getLocalPlayer() ) ) == getLocalPlayer() then if isVehicleOnGround ( getPedOccupiedVehicle ( getLocalPlayer() ) ) == true then if getAnalogControlState ( "accelerate" ) == 1 then if fuelAmmount > 0 then if dankSetting == "low" then boost = 1.01 subtractor = 3 elseif dankSetting == "medium" then boost = 1.03 subtractor = 6 elseif dankSetting == "high" then boost = 1.05 subtractor = 9 end local velX, velY, velZ = getElementVelocity ( getPedOccupiedVehicle ( getLocalPlayer() ) ) injectFuel = setElementVelocity ( getPedOccupiedVehicle ( getLocalPlayer() ), velX * boost, velY * boost, velZ ) fuelAmmount = fuelAmmount - subtractor guiProgressBarSetProgress ( fuelGauge, fuelAmmount/10 ) else local x, y = guiGetScreenSize() dxDrawText ( "Rocket Fuel Tank Empty", x/4, y/4 ) if smokeGenerator then triggerServerEvent ( "killSmoke", getLocalPlayer() ) smokeGenerator = nil end if getKeyState ( "lshift" ) == true then if fuelAmmount <= 0 then removeEventHandler ( "onClientRender", getRootElement(),rocketBoost, getLocalPlayer() ) unbindKey ( "lshift", "down", ignition ) unbindKey ( "lshift", "up", ignition ) setTimer ( restoreFuel, 1000, 1 ) addEventHandler ( "onClientRender", getRootElement(), restoreFuelCheck ) end end end end end end end end function restoreFuel() fuelAmmount = 1000 guiProgressBarSetProgress ( fuelGauge, 100 ) bindKey ( "lshift", "up", ignition ) bindKey ( "lshift", "both", ignition ) outputChatBox ( "Fuel #00FF00Restored", 255, 255, 255, true ) end function restoreFuelCheck() if fuelAmmount < 1000 then local x, y = guiGetScreenSize() dxDrawText ( "Restoring Rocket Fuel...", x/2.3, y/23, x, y, tocolor ( 255, 0, 0, 255 ), 1.5, "default", "left", "top", false, false, true ) elseif fuelAmmount == 1000 then removeEventHandler ( "onClientRender", getRootElement(), restoreFuelCheck ) end end function rockettoggle1 () unbindKey ( "lshift", "down", kill ) bindKey ( "lshift", "up", kill ) unbindKey ( "lshift", "up", ignition ) bindKey ( "lshift", "down", ignition ) end function rockettoggle2 () unbindKey ( "lshift", "up", kill ) bindKey ( "lshift", "down", kill ) unbindKey ( "lshift", "down", ignition ) bindKey ( "lshift", "up", ignition ) end addCommandHandler ( "tr1",rockettoggle1 ) addCommandHandler ( "tr2",rockettoggle2 ) addCommandHandler ( "rocket", function ( player, number ) if number == "1" then dankSetting = "low" outputChatBox ( "Rocket velocity set to #00FF00low", 255, 255, 255, true ) elseif number == "2" then dankSetting = "medium" outputChatBox ( "Rocket velocity set to #00FF00medium", 255, 255, 255, true ) elseif number == "3" then dankSetting = "high" outputChatBox ( "Rocket velocity set to #00FF00high", 255, 255, 255, true ) elseif number == nil then outputChatBox ( "You must specify either 1 2 or 3", 255, 255, 255 ) else outputChatBox ( "Invalid Number; use 1 2 or 3", 255, 255, 255 ) end end ) addEventHandler ( "onClientPlayerVehicleExit", getRootElement(), function() if getAnalogControlState ( "accelerate" ) == 1 then removeEventHandler ( "onClientRender", getRootElement(), rocketBoost, player ) guiSetVisible ( fuelGauge, false ) if smokeGenerator then triggerServerEvent ( "killSmoke", getLocalPlayer() ) smokeGenerator = nil end end end ) addEventHandler ( "kill", getRootElement(), kill ) Link to comment
dzek (varez) Posted September 26, 2010 Share Posted September 26, 2010 you made this so complicated o_O just save in global variable which way you are using, and restore it on fuel refill Link to comment
Fabio(GNR) Posted September 26, 2010 Author Share Posted September 26, 2010 you made this so complicated o_Ojust save in global variable which way you are using, and restore it on fuel refill Uhm i did not create the script, but thats not what your saying i'll have to search on wiki for global variable thanks for the info, ill report back if i done it EDIT: can't find anything on wiki about global variable Link to comment
dzek (varez) Posted September 26, 2010 Share Posted September 26, 2010 global variable is just NOT local variable just define your variable in the beginning of script and change the value anywhere in the script Link to comment
Fabio(GNR) Posted September 26, 2010 Author Share Posted September 26, 2010 global variable is just NOT local variable just define your variable in the beginning of script and change the value anywhere in the script Sorry, i don't get it, i never used Global/Local variables Sorry for late response Link to comment
dzek (varez) Posted September 26, 2010 Share Posted September 26, 2010 just search for "global variable lua" on google, and you will find lua language manual Link to comment
Fabio(GNR) Posted September 26, 2010 Author Share Posted September 26, 2010 just search for "global variable lua" on google, and you will find lua language manual Ok reading now So if i paste this on front of my code: tr1 = togglerocket1 print(tr1) --> togglerocket1 it will recognize it? I don't get it this is what i found: http://www.lua.org/pil/1.2.html but, it's really hard for a noobie like me EDIT: maybe i should drop this mess, and make the fuel something like 100000000 And when its down make an outputbox command that will say: please re-enter settings idk, That would be ok too, thanks for your idea tough, but i really don't get it... Please explain me, if you have the time otherwise i'll use the 10000000 fuel idea Link to comment
jkub Posted October 2, 2010 Share Posted October 2, 2010 I am phillyblunt the creator of the rocket cars script. I will try to help you. The default global variable I used in this seems to be fuelAmmount. Try a command that makes you able to restore fuel. For example addCommandHandler ( "fuel", function ( cmd, fuel ) if fuel then if tonumber(fuel) then fuelAmmount = tonumber(fuel) end end end ) I am not entirely sure on what you are wanting to accomplish, but this should be a simple way to restore fuel. Link to comment
Fabio(GNR) Posted October 2, 2010 Author Share Posted October 2, 2010 I am phillyblunt the creator of the rocket cars script. I will try to help you.The default global variable I used in this seems to be fuelAmmount. Try a command that makes you able to restore fuel. For example addCommandHandler ( "fuel", function ( cmd, fuel ) if fuel then if tonumber(fuel) then fuelAmmount = tonumber(fuel) end end end ) I am not entirely sure on what you are wanting to accomplish, but this should be a simple way to restore fuel. Thanks, but i found a other way Thanks for uploading it and the help 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