MrRobinson Posted June 27, 2015 Share Posted June 27, 2015 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 More sharing options...
MrRobinson Posted June 27, 2015 Author Share Posted June 27, 2015 Anyone? Link to comment Share on other sites More sharing options...
MrRobinson Posted June 27, 2015 Author Share Posted June 27, 2015 These are the errors I get and 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