Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

Needing help with making a script


Fsfan
 Share

Recommended Posts

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

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

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

  • Like 1
Link to comment
Share on other sites

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

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 :p

Link to comment
Share on other sites

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
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.