Jump to content

[HELP] : Submarine Script


SycroX

Recommended Posts

:?: how dose this function will be usefull to me

it get the water level . how can if be usefull to me

see the sub marine is a ship

  
CurrentDepth = 0 
  
function MoveSubmarine() 
 local Waterlevel = getWaterLevel() 
 local x, y, z = getElementPosition(theobject) 
 local check = isElementInWater(theobject) 
 local vehiclecheck  = isPedInVehicle ( source ) 
if getKeyState( "arrow_u" ) == true and check == true and vehiclecheck  == true then 
CurrentDepth = CurrentDepth + 1 
setElementPosition(theobject, x, y, z - CurrentDepth) 
elseif getKeyState( "arrow_d" ) == true and check == true and vehiclecheck  == true  then 
CurrentDepth = CurrentDepth - 1 
setElementPosition(theobject, x, y, z - CurrentDepth) 
end 
end 
  

Will make a proper code later on, i'm currently scripting it on my phone.Will fix it once i'm home

Link to comment
:?: how dose this function will be usefull to me

it get the water level . how can if be usefull to me

see the sub marine is a ship

  
CurrentDepth = 0 
  
function MoveSubmarine() 
 local Waterlevel = getWaterLevel() 
 local x, y, z = getElementPosition(theobject) 
 local check = isElementInWater(theobject) 
 local vehiclecheck  = isPedInVehicle ( source ) 
if getKeyState( "arrow_u" ) == true and check == true and vehiclecheck  == true then 
CurrentDepth = CurrentDepth + 1 
setElementPosition(theobject, x, y, z - CurrentDepth) 
elseif getKeyState( "arrow_d" ) == true and check == true and vehiclecheck  == true  then 
CurrentDepth = CurrentDepth - 1 
setElementPosition(theobject, x, y, z - CurrentDepth) 
end 
end 
  

Will make a proper code later on, i'm currently scripting it on my phone.Will fix it once i'm home

your code is wrong

there is something is undefind like source ?

what is this from where you get is i don't see any event

Link to comment

i try to do this code but i shoud give the sub freeze and it dosen't drive will when i press w it go forword and left in the same time

addEventHandler( "onClientKey", root, 
function(button,press)  
local vehicle = getPedOccupiedVehicle(localPlayer) 
local x, y, z = getElementPosition(vehicle) 
local rx, ry, rz = getElementRotation(vehicle) 
if isElementInWater(vehicle) then 
if button == "arrow_d" then 
if press == true and getElementModel(vehicle) == 484 then 
setElementPosition(vehicle, x, y, z - 1) 
setElementFrozen(vehicle, true) 
end 
elseif button == "w" then 
if z > -2 then return end 
setElementPosition(vehicle, x, y+1, z) 
elseif button == "s" then 
if z > -2 then return end 
setElementPosition(vehicle, x, y-1, z) 
elseif button == "a" then 
if z > -2 then return end 
setElementPosition(vehicle, x+1, y, z) 
setElementRotation(vehicle, rx, ry, rz+1) 
elseif button == "d" then 
if z > -2 then return end 
setElementPosition(vehicle, x-1, y, z) 
setElementRotation(vehicle, rx, ry, rz-1) 
elseif button == "arrow_u" then 
if press == true and getElementModel(vehicle) == 484 then 
setElementPosition(vehicle, x, y, z + 1) 
if z >= -2 then 
setElementFrozen(vehicle, false) 
end 
end 
end 
end 
end) 
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...