Hi all, I'm trying to combine the drivecar script by smallg and the bb helmet script with the idea that when you enter the ship you get a hud, I have it sort of working as in you can enter the ship and the hud appears. problem is when the show image is used the ship then doesn't move so as usual ive missed something :/
local state = {}
local use_range = {}
local speed = {}
local max_speed = {}
local turn_rate = {}
local accleration = {}
local pressed = 0
function flyship2_init(e)
LoadImages("bbhelmet",0)
SetImagePosition(0,0)
SetImageAlignment(1)
state[e] = "init"
speed[e] = 0
-- Adjust the speed of the vehicle here
max_speed[e] = 250
turn_rate[e] = 30
use_range[e] = 500
accleration[e] = 10
GravityOn(e)
--CollisionOff(e)
end
function flyship2_main(e)
if state[e] == "init" then
if GetPlayerDistance(e) <= use_range[e] then
Prompt("Press E to enter the Ship")
--press enter/return to useship
if GetScancode() == 18 and pressed == 0 then
FreezePlayer()
if g_KeyPressE == 0 then
pressed = 0
end
pressed = 1
PlaySound(e,0)
ShowImage(imagenumber)
PromptDuration("W, S, A, D to Fly. X to brake.",5000)
state[e] = "start"
--GravityOn(e)
end
end
elseif state[e] == "start" then
CollisionOff(e)
FreezePlayer()
if GetInKey() == "a" then
RotateY(e,-turn_rate[e])
GravityOn(e)
elseif GetInKey() == "d" then
RotateY(e, turn_rate[e])
GravityOn(e)
end
-- stop ship test (V1.1) - X TOUCH
if GetScancode() == 45 and pressed == 0 then
speed[e] = 0
--PlaySound(e,)
--PlaySound(e,4)
end
if GetInKey() == "w" then
--if speed[e] < (max_speed[e]/2) then
if speed[e] < (max_speed[e]) then
speed[e] = speed[e] + accleration[e]
GravityOn(e)
PlaySound(e,1)
end
elseif GetInKey() == "s" then
if speed[e] > -(max_speed[e]/2) then
--if speed[e] > -(max_speed[e]) then
speed[e] = speed[e] - accleration[e]
GravityOn(e)
--PlaySound(e,decelerationship)
--PlaySound(e,2)
end
else
if speed[e] > -(max_speed[e] /10) and speed[e] < max_speed[e] /10 then
speed[e] = 0
if GetScancode() == 18 and pressed == 0 then
UnFreezePlayer()
pressed = 1
StopSound(e,0)
StopSound(e,1)
--PlaySound(e,stopship)
--PlaySound(e,3)
CollisionOn(e)
state[e] = "init"
end
end
end
MoveForward(e, speed[e])
UnFreezePlayer()
TransportToIfUsed(e)
GravityOn(e)
--
--if pressed == 0 then
--if GetScancode() == 203 or GetScancode() == 205 then
--pressed = 1
--UnFreezePlayer()
--end
--end
end
if pressed == 1 and GetScancode() ~= 18 then
pressed = 0
end
end
what am i missing guys? (apart from some grey matter)
also ive noticed that you can freely rotate wheras I would like the hud to stay fixed although that's not that important as I could be a helmet I suppose?