CapY Posted July 24, 2011 Share Posted July 24, 2011 I have downloaded resource rocket cars from community and i want it to be just for admins. Client: --[[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", "down", 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 = 9999999999999 boost = 1.01--default value 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/100 ) 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 ) setTimer ( restoreFuel, 10, 1 ) addEventHandler ( "onClientRender", getRootElement(), restoreFuelCheck ) end end end end end end end end 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 ) function protectRocket ( ) for i,v in ipairs ( getElementsByType ( "player" ) ) do local playername = getPlayerName ( v ) local accname = getAccountName ( getPlayerAccount ( v ) ) if hasObjectPermissionTo ( v, 'function.kickPlayer' ) then return true else outputChatBox(i,"Access DENIED!!!",255,0,0) end end end end addEventHandler ( "kill", getRootElement(), kill ) removeEventHandler ( "onClientRender", getRootElement(),rocketBoost, getLocalPlayer() Server: addEvent ( "createSmoke", true ) addEvent ( "killSmoke", true ) addEventHandler ( "createSmoke", getRootElement(), function() smokeGenerator = createObject ( 2780, 0, 0, 0 ) setElementAlpha ( smokeGenerator, 0 ) attachElements ( smokeGenerator, getPedOccupiedVehicle ( client ), 0, -3, -1 ) end ) addEventHandler ( "killSmoke", getRootElement(), function() if smokeGenerator then detachElements ( smokeGenerator, getPedOccupiedVehicle ( client ) ) destroyElement ( smokeGenerator ) smokeGenerator = nil end end ) addEventHandler ( "onVehicleStartExit", getRootElement(), function ( player ) if getVehicleController ( source ) == player then if isElementAttached ( smokeGenerator ) then if getElementAttachedTo ( smokeGenerator ) == source then detachElements ( smokeGenerator, source ) destroyElement ( smokeGenerator ) triggerClientEvent ( player, "kill", player, player ) smokeGenerator = nil end end end end ) --[[addEventHandler ( "onPlayerWasted", getRootElement(), function() if isPedInVehicle ( source ) then if getVehicleController ( getPedOccupiedVehicle ( source ) ) == source then if isElementAttached ( smokeGenerator ) then if getElementAttachedTo ( smokeGenerator ) == getPedOccupiedVehicle ( source ) then detachElements ( smokeGenerator, getPedOccupiedVehicle ( source ) ) destroyElement ( smokeGenerator ) triggerClientEvent ( source, "kill", source, source ) smokeGenerator = nil end end end end end )--]] function protectRocket ( ) for i,v in ipairs ( getElementsByType ( "player" ) ) do local playername = getPlayerName ( v ) local accname = getAccountName ( getPlayerAccount ( v ) ) if hasObjectPermissionTo ( v, 'function.kickPlayer' ) then return true else outputChatBox(i,"Access DENIED!!!",255,0,0) end end end end addEventHandler ( 'onResourceStart', resourceRoot, protectRocket ) removeEventHandler ( "onClientRender", getRootElement(),rocketBoost, getLocalPlayer() So anybody can help to fix it ? Link to comment
Kenix Posted July 24, 2011 Share Posted July 24, 2011 Use /debugscript 3 for find errors . Link to comment
CapY Posted July 24, 2011 Author Share Posted July 24, 2011 Lol i want it just for admins , not for everyone , this already gives me errors, i don't know how to make it only for admins. 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