Fsfan Posted January 18, 2016 Share Posted January 18, 2016 Hey guys, I'm requesting help for a simple mod, for a bus to spawn somewhere and the objective is to do go to a certain location, get some passengers and then go to another location. After getting to that location the player gets money. I don't quite know how to start because I'm only a beginner at this I hope to build up and make a working bus mod for all with many missions! Thanks, Fsfan Link to comment Share on other sites More sharing options...
Fireboyd78 Posted January 18, 2016 Share Posted January 18, 2016 I have a feeling you're asking someone to explain to you how to write a script from beginning to end. Unfortunately, the best way to learn how to do something is by trial and error. With that said, I would like to donate a Tow Truck script I was working on. It's written for the Lua ScriptHook (not GTALua). I provide the source code in hopes that it will help you understand the very basics of what you need to do. local cl69towing = { name = "CL69 Towing Missions (DEV)", disabled = true, debugName = "cl69towing", debugMode = false,}--[[================Misc. Variables================--]]local tickCount = 0local dbg = { text = "", coords, rot,}--[[================Debug Functions================--]]function draw_debug() if dbg.coords ~= nil then --GRAPHICS.DRAW_LINE(dbg.coords.x, dbg.coords.y, dbg.coords.z, dbg.coords.x, dbg.coords.y, dbg.coords.z + 5.0, 0, 255, 0, 255) UI.SET_TEXT_FONT(0) UI.SET_TEXT_SCALE(0.0, 0.35) UI.SET_TEXT_COLOUR(255, 255, 255, 128) UI.SET_TEXT_CENTRE(false) UI.SET_TEXT_DROPSHADOW(0, 0, 0, 0, 0) UI.SET_TEXT_EDGE(0, 0, 0, 0, 0) UI._SET_TEXT_ENTRY("STRING") UI._ADD_TEXT_COMPONENT_STRING(dbg.text) UI._DRAW_TEXT(0.6925, 0.015) endendfunction update_debug_coords() local pid = PLAYER.PLAYER_PED_ID() dbg.coords = ENTITY.GET_ENTITY_COORDS(pid, true) dbg.rot = ENTITY.GET_ENTITY_ROTATION(pid, false) dbg.text = string.format("POSITION: %.6f, %.6f, %.6f\nROTATION: %.6f, %.6f, %.6f", dbg.coords.x, dbg.coords.y, dbg.coords.z, dbg.rot.x, dbg.rot.y, dbg.rot.z)end--[[================Script Variables================--]]local towTruck = { handle = nil, hash = nil, model = "towtruck2", -- 50's tow truck color = {128, 235, 90}, position = {249.138150, 2600.628000, 44.709800}, rotation = {0.410125, 1.653700, -35.268880},}--[[================Script Functions================--]]function init_towtruck() -- make sure hash is initialized if towTruck.hash == nil then towTruck.hash = GAMEPLAY.GET_HASH_KEY(towTruck.model) end if towTruck.handle == nil then STREAMING.REQUEST_MODEL(towTruck.hash) local pos = towTruck.position local rot = towTruck.rotation local numTicks = 0 local loadFailed = false while not STREAMING.HAS_MODEL_LOADED(towTruck.hash) do if numTicks > 250 then loadFailed = true break else numTicks = numTicks + 1 end end if loadFailed then print "Tow truck failed to spawn!!!" return end -- create towtruck towTruck.handle = VEHICLE.CREATE_VEHICLE(towTruck.hash, pos[1], pos[2], pos[3], 0.0, false, true) -- setup rotation ENTITY.SET_ENTITY_ROTATION(towTruck.handle, rot[1], rot[2], rot[3], 2, true) -- make sure no other tow trucks spawn (we don't want any competition ) VEHICLE.SET_VEHICLE_MODEL_IS_SUPPRESSED(towTruck.hash, true) endendfunction unload_towtruck() if towTruck.handle ~= nil then -- we must assume the hash has not been screwed with VEHICLE.SET_VEHICLE_MODEL_IS_SUPPRESSED(towTruck.hash, false) --STREAMING.SET_MODEL_AS_NO_LONGER_NEEDED(towTruck.hash) ENTITY.SET_VEHICLE_AS_NO_LONGER_NEEDED(towTruck.handle) VEHICLE.DELETE_VEHICLE(towTruck.handle) -- TEMPORARY HACK!!! towTruck.handle = nil towTruck.hash = nil endendfunction cl69towing.log(str) if self.debugMode then print("> ".. self.debugName ..": ".. str) endendfunction cl69towing.unload() unload_towtruck()endfunction cl69towing.init() endfunction cl69towing.tick() if cl69towing.debugMode then update_debug_coords() draw_debug() end if tickCount >= 10 then if get_key_pressed(Keys.NumPad0) then print "Releasing tow truck..." unload_towtruck() elseif get_key_pressed(Keys.NumPad1) then print "Spawning tow truck..." init_towtruck() end tickCount = 0 else tickCount = tickCount + 1 endendreturn cl69towing Link to comment Share on other sites More sharing options...
Fsfan Posted January 19, 2016 Author Share Posted January 19, 2016 Hey, thanks for the reply and the lua script, you are right about the trial and error thing. I'm just a bit impatient on when I'm going to become as good as others LOL! Cheers, Fsfan jedijosh920 1 Link to comment Share on other sites More sharing options...
jedijosh920 Posted January 19, 2016 Share Posted January 19, 2016 Don't use LUA, it's the worst, you can't use many functions/natives. Try using C#. Add me on Skype/Steam: jedijosh920 and I can send you a script or teach you. Link to comment Share on other sites More sharing options...
Fireboyd78 Posted January 20, 2016 Share Posted January 20, 2016 Don't use LUA, it's the worst, you can't use many functions/natives. Try using C#. Add me on Skype/Steam: jedijosh920 and I can send you a script or teach you. Don't diss Lua, man! Blame the script hook guys for not keeping it updated Link to comment Share on other sites More sharing options...
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