Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local shootingAllowed = true
- local allowJump = true
- local powerUp1 = false
- local powerUp2 = false
- local powerUp3 = false
- local powerUp4 = false
- local powerUp5 = false
- function resStart ( res )
- local keys1,keys2 = getBoundKeys("vehicle_fire"),getBoundKeys("vehicle_secondary_fire")
- if keys1 then
- for keyName, state in pairs(keys1) do
- bindKey(keyName, "down", shoot)
- end
- end
- end
- addEventHandler ( "onClientResourceStart", resourceRoot, resStart )
- function bindJumpTrapKey ( pwrUpType )
- if( source == localPlayer ) then
- if(pwrUpType == "trap") then
- outputChatBox ( "#0FC0FC[Power Up] #33FF33You recieved a #EE9900'Trap' #33FF33 power up! Press 'Right mouse button' to release it!", 255, 255, 255, true )
- bindKey ( "mouse2", "down", releaseTrap )
- elseif (pwrUpType == "jump") then
- bindKey ( "mouse2", "down", jump )
- outputChatBox ( "#0FC0FC[Power Up] #33FF33You recieved a #EE9900'Jump' #33FF33 power up! Press 'Right mouse button' to jump!", 255, 255, 255, true )
- end
- end
- end
- addEvent ( "bindJumpTrap", true )
- addEventHandler ( "bindJumpTrap", getRootElement(), bindJumpTrapKey )
- function unbindJumpKey ( )
- if( source == localPlayer ) then
- unbindKey ( "mouse2", "down", jump )
- end
- end
- function unbindKeys ( typee )
- if( source == localPlayer ) then
- if( typee == "jump" ) then
- unbindKey ( "mouse2", "down", jump )
- elseif ( typee == "trap" ) then
- unbindKey ( "mouse2", "down", releaseTrap )
- end
- end
- end
- addEvent ( "removeBinds", true )
- addEventHandler ( "removeBinds", getRootElement(), unbindKeys )
- function releaseTrap ( )
- unbindKey ( "mouse2", "down", releaseTrap )
- powerUp4 = false
- local x, y, z = getElementPosition ( getPedOccupiedVehicle ( localPlayer ) )
- triggerServerEvent ( "releaseTrap", localPlayer, x, y, z )
- end
- function jump ( )
- if ( allowJump ) then
- allowJump = false
- x,y,z = getElementVelocity( getPedOccupiedVehicle ( localPlayer ) )
- setElementVelocity ( getPedOccupiedVehicle ( localPlayer ), x, y, z + 0.2 )
- setTimer ( allowJumpKey, 2000, 1 )
- end
- end
- function allowJumpKey ( )
- allowJump = true
- end
- function shoot ()
- if shootingAllowed == true then
- shootingAllowed = false
- if ( powerUp1 ) then
- setTimer ( allowShooting, 500, 1 )
- else
- setTimer ( allowShooting, 3000, 1 )
- end
- fire()
- end
- end
- function fire ( )
- vehicle = getPedOccupiedVehicle ( localPlayer )
- if vehicle then
- if(powerUp2) then
- x1, y1, z1 = getPositionOffsetFromElement( vehicle, 1, 3, 0 )
- x2, y2, z2 = getPositionOffsetFromElement( vehicle, -1, 3, 0 )
- createProjectile( vehicle, 19, x1, y1, z1, 1 )
- createProjectile( vehicle, 19, x2, y2, z2, 1 )
- else
- x1, y1, z1 = getPositionOffsetFromElement( vehicle, 0, 3, 0 )
- createProjectile( vehicle, 19, x1, y1, z1, 1 )
- end
- end
- end
- function allowShooting ()
- shootingAllowed = true
- end
- function setPwrUpState ( pwrUp, state )
- if( source == localPlayer ) then
- if ( pwrUp == "pwrUp1" ) then
- powerUp1 = state
- elseif ( pwrUp == "pwrUp2" ) then
- powerUp2 = state
- elseif ( pwrUp == "pwrUp3" ) then
- powerUp3 = state
- elseif ( pwrUp == "pwrUp4" ) then
- powerUp4 = state
- elseif ( pwrUp == "pwrUp5" ) then
- powerUp5 = state
- unbindJumpKey()
- elseif ( pwrUp == "pwrUp6" ) then
- powerUp6 = state
- end
- end
- end
- addEvent ( "setPwrUpState", true )
- addEventHandler ( "setPwrUpState", getRootElement(), setPwrUpState )
- -- For a given element, calculate the absolute positon in the world from the offset (ox,oy,oz)
- function getPositionOffsetFromElement(element,ox,oy,oz)
- local offX,offY,offZ,matrix = 0,0,0,getElementMatrix(element)
- if matrix then
- offX = ox * matrix[1][1] + oy * matrix[2][1] + oz * matrix[3][1] + matrix[4][1]
- offY = ox * matrix[1][2] + oy * matrix[2][2] + oz * matrix[3][2] + matrix[4][2]
- offZ = ox * matrix[1][3] + oy * matrix[2][3] + oz * matrix[3][3] + matrix[4][3]
- end
- return offX, offY, offZ
- end
Advertisement
Add Comment
Please, Sign In to add comment