Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Criminal Enterprises
      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

[LUA] All .ASI crashes when function is called


MrRobinson
 Share

Recommended Posts

hey there, so I'm making a mod in LUA for the first time (bored of C++ and C#) and Its going good, however I'm stuck at 2 hurdles.

 

Number one is the biggest. All my ASI's crash when it is suppose to call the function. You get the to the coordinates and you're supposed to press 'Y' and it runs the function however as soon as I press 'Y' it crashes the LUA.asi and LUA_SDK.asi and then crashes the came because of it.

 

Number two...I want a random function selector like The Red House mod. Where you go to a place and it offers you a mission, you walk away and then go back to get a different offer, I want that...Heres my code

local W2FIB = {}local playerPed = PLAYER.PLAYER_PED_ID()local playerGroup = PED.GET_PED_GROUP_INDEX(playerPed)function W2FIB.unload()end----------Ticks----------ConstantBase = falseTickTick = falseCaseTick = falseHostageCaseAccept = falseDrugCaseAccept = falseHostageTickBlip = falseHostageTakerTickBlip = falseSpawnTakerTick = falseTakerFinalTick = falseSWATSpawnTick = falseSWATSpawnFinal = falseSpawnTruckTick = false-----------------------------------Blips----------function FIBHQ()	if not(ConstantBase)then		ConstantBlip = UI.ADD_BLIP_FOR_COORD(150.126, -754.591, 262.865)		UI.SET_BLIP_SPRITE(ConstantBlip, 40)		UI.SET_BLIP_COLOUR(ConstantBlip, 3)		UI.SET_BLIP_SCALE(ConstantBlip, 1)		ConstantBase = true	endendfunction FIBCaseCollect()	if not(CaseTick)then		CaseBlip = UI.ADD_BLIP_FOR_COORD(112.821, -736.594, 242.152)		UI.SET_BLIP_SPRITE(CaseBlip, 106)		UI.SET_BLIP_COLOUR(CaseBlip, 3)		UI.SET_BLIP_SCALE(CaseBlip, 1)		CaseTick = true	endendfunction HostageBlip()	if not(HostageTickBlip)then		TheHostigeBlip = UI.ADD_BLIP_FOR_COORD(-110.071, -13.765, 70.520)		UI.SET_BLIP_SPRITE(TheHostigeBlip, 428)		UI.SET_BLIP_COLOUR(TheHostigeBlip, 3)		UI.SET_BLIP_SCALE(TheHostigeBlip, 0.75)		HostageTickBlip = true		endendfunction HostageTakerBlip()	if not(HostageTakerTickBlip)then		TheHostigeTakerBlip = UI.ADD_BLIP_FOR_COORD(-110.071, -13.765, 70.520)		UI.SET_BLIP_SPRITE(HostageTakerTickBlip, 84)		UI.SET_BLIP_COLOUR(HostageTakerTickBlip, 1)		UI.SET_BLIP_SCALE(HostageTakerTickBlip, 0.75)		HostageTakerTickBlip = true		endend-----------------------------------PedestrianSpawning----------function SpawnSWATteam()		if not(SWATSpawnTick)then	local SwatTeam = {}	local spawnX = {67.399, 65.725, 62.076}	local spawnY = {-731.750, -736.325, -744.586}	local spawnZ = {44.256, 44.221, 44.220}	local spawnH = {0,0,0}	local numberOfSWAT = 3		SwatID = GAMEPLAY.GET_HASH_KEY("s_m_y_swat_01")	STREAMING.REQUEST_MODEL(SwatID)	while(not STREAMING.HAS_MODEL_LOADED(SwatID)) do				wait(50)	end	if not(SWATSpawnFinal)then		for i = 1, numberOfSWAT do			swatPed[i] = PED.CREATE_PED(1, SwatID, spawnX[i], spawnY[i], spawnZ[i], spawnH[i], true, true)			PED.SET_PED_CAN_SWITCH_WEAPON(swatPed[i], true)			WEAPON.GIVE_DELAYED_WEAPON_TO_PED(swatPed[i], GAMEPLAY.GET_HASH_KEY("WEAPON_CARBINERIFLE"), 1000, false)			PED.SET_PED_RELATIONSHIP_GROUP_HASH(swatPed[i], GAMEPLAY.GET_HASH_KEY("player"))			PED.SET_PED_AS_GROUP_MEMBER(swatPed[i], playerGroup)			PED.SET_PED_COMBAT_RANGE(swatPed[i], 2)			PED.SET_PED_COMBAT_ABILITY(swatPed[i], 2)			ENTITY.SET_ENTITY_INVINCIBLE(swatPed[i], true)			PED.SET_PED_NEVER_LEAVES_GROUP(swatPed[i], true)			print(i)			wait(10)		end		STREAMING.SET_MODEL_AS_NO_LONGER_NEEDED(SwatID)		SWATSpawnTick = true		SWATSpawnFinal = true	endendend	function SpawnHostageTaker()		if not(SpawnTakerTick)then		TakerID = GAMEPLAY.GET_HASH_KEY("u_m_y_tatto_01")		STREAMING.REQUEST_MODEL(TakerID)		while(not STREAMING.HAS_MODEL_LOADED(TakerID)) do					wait(50)		end		if not(TakerFinalTick)then			takerPed = PED.CREATE_PED(1, TakerID, -110.617, -6.475, 70.520, 90, true, true)			PED.SET_PED_CAN_SWITCH_WEAPON(takerPed, true)			WEAPON.GIVE_DELAYED_WEAPON_TO_PED(takerPed, GAMEPLAY.GET_HASH_KEY("WEAPON_PUMPSHOTGUN"), 1000, false)			PED.SET_PED_RELATIONSHIP_GROUP_HASH(takerPed, GAMEPLAY.GET_HASH_KEY("prisoner"))			PED.SET_PED_COMBAT_RANGE(takerPed, 1)			PED.SET_PED_COMBAT_ABILITY(takerPed, 1)			PED.SET_PED_TO_LOAD_COVER(takerPed, true)			PED.SET_PED_CAN_COWER_IN_COVER(takerPed, false)			PED.SET_PED_CAN_PEEK_IN_COVER(takerPed, true)						print(i)			wait(10)		end		STREAMING.SET_MODEL_AS_NO_LONGER_NEEDED(TakerID)		SpawnTakerTick = true		TakerFinalTick = true	endendfunction SpawnHostage()	if not(SpawnHostageTick)then		hostagePed = PED.CREATE_RANDOM_PED(-110.071, -13.765, 70.520)		PED.SET_ENABLE_HANDCUFFS(hostagePed, true)		PED.SET_PED_DUCKING(hostagePed, true)		PED.SET_PED_RELATIONSHIP_GROUP_HASH(hostagePed, GAMEPLAY.GET_HASH_KEY("civmale"))	endend------------------------------------------------VehicleSpawning----------function SpawnSWATtruck()	if not(SpawnTruckTick)then		SWATTruck = VEHICLE.CREATE_VEHICLE(GAMEPLAY.GET_HASH_KEY("riot"), 48.742, -728.914, 44.313, 180, true, true)		ENTITY.SET_ENTITY_INVINCIBLE(SWATTruck, true)		SpawnTruckTick = true	endend----------TickityBo----------function W2FIB.tick()	local playerPed = PLAYER.PLAYER_PED_ID()	local player = PLAYER.GET_PLAYER_PED(playerPed)	local location = ENTITY.GET_ENTITY_COORDS(playerPed, nil)			if not(TickTick)then		FIBHQ()		FIBCaseCollect()		TickTick = true	end		if(GAMEPLAY.GET_DISTANCE_BETWEEN_COORDS(150.126, -754.591, 262.865, location.x, location.y, location.z, true ) < 1 )then		notify("Go to the first elevator and then get out when it reaches the top")	end	if(GAMEPLAY.GET_DISTANCE_BETWEEN_COORDS(112.821, -736.594, 242.152, location.x, location.y, location.z, true ) < 1 ) then		HostageAccept()	endend---------------------------------------CaseAccept----------function HostageAccept()		if not(HostageCaseAccept)then		notify("~r~Hostage situation")		notify("Press [Y] to accept the case")		if(get_key_pressed(Keys.Y))then			HostageStart()			HostageCaseAccept = true		end	endend--function DrugBustAccept()	--if not(DrugCaseAccept)then		--notify("~r~Drug Bust")		--notify("Press [Y] to accept the case")		--if(get_key_pressed(89))then			--DrugBustStart()			--DrugCaseAccept = true		--end	--end--end---------------------------------------CaseStarters----------function HostageStart()	local playerPed = PLAYER.PLAYER_PED_ID()	local player = PLAYER.GET_PLAYER_PED(playerPed)	local location = ENTITY.GET_ENTITY_COORDS(playerPed, nil)	if not(HostageStartTick)then		wait(500)		notify("Alright suit up")		wait(500)		PLAYER.SET_PLAYER_MODEL(player, GAMEPLAY.GET_HASH_KEY("s_m_y_swat_01"))		notify("Alright, hostige is in an apartment building up in Vinewood.")		wait(500)		notify("The hostage taker is believed to have designed his apartment for this occasion")		wait(500)		notify("It has bullet proof glass so a sniper take down is out of the question")		wait(500)		notify("He has got cover behind the kitchen counter and is aiming at the door")		wait(500)		notify("He has a pump action shotgun so be careful when breaching...")		wait(500)		notify("Good luck")		HostageBlip()		HostageTakerBlip()		HostageStartTick = true	end		if not(SpawningTime)then			SpawnHostage()			SpawnHostageTaker()			SpawnSWATteam()			SpawnSWATtruck()			notify("Your team and truck are downstairs, again, good luck")			SpawningTime = true		end		if((GAMEPLAY.GET_DISTANCE_BETWEEN_COORDS(-110.071, -13.765, 70.520, location.x, location.y, location.z, true ) < 1 ) and (PED._IS_PED_DEAD(takerPed, 1 == true)))then			AI.TASK_ENTER_VEHICLE(swatPed, SWATTruck, 60000, 1, 5, 1, 1)			AI.TASK_ENTER_VEHICLE(swatPed, SWATTruck, 60000, 2, 5, 1, 1)			AI.TASK_ENTER_VEHICLE(swatPed, SWATTruck, 60000, 3, 5, 1, 1)			AI.TASK_VEHICLE_DRIVE_TO_COORD(swatPed, SWATTruck, 48.742, -728.914, 44.313, 40, 1, ENTITY.GET_ENTITY_MODEL(vehicleHandle), 0xC00AB, -1, -1)			PED.SET_ENABLE_HANDCUFFS(hostagePed, false)			PED.SET_PED_DUCKING(hostagePed, false)			AI.TASK_GO_STRAIGHT_TO_COORD(hostagePed, -1641.175, 1979.533, 117.987, 5, 60000, 0, 1)			notify("Nice work, return back to HQ and collect a new case")			AUDIO.PLAY_MISSION_COMPLETE_AUDIO("MICHAEL_BIG_01")			wait(60000)			PED.SET_PED_AS_NO_LONGER_NEEDED(hostagePed)		endend				return W2FIB
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.