News: Welcome back to Bullworth! If you haven't already, you will need to reset your password..


Author Topic: Custom Mission Scripting - The Basic's  (Read 8748 times)

0 Members and 4 Guests are viewing this topic.

Offline AlphaTech

  • LostInSpace
  • Sr. Member
  • ***
  • Posts: 758
  • Gender: Male
  • The name's AlphaTECH, whatca need help with?! :)
    • View Profile
Custom Mission Scripting - The Basic's
« on: July 28, 2015, 01:18:43 PM »
Well we all know how I made a custom mission script as a source to use for making missions right? Well I will be doing a little Step by step tutorial on setting certain things to work and how to use some props and other types of things ingame. I will explain how to make a regular test mission and how to make a long actual mission. Now here some things we would need in creating a mission, Notepad++ and the Compiler plus img.tool

You can also run your script threw Stimecycle.lur to get it working like a real mission by pressing buttons and having the Stimecylce run your script. This will cover only basic thing's and will be split into many discussions since their is a lot going on when running a mission.

The very first thing is a test mission or test script to see if  everything you have running is working correctly. We would start by doing this,

Code: [Select]
MissionSetup = function()
-- (0) is the area code for the main map, all area codes are placed here.
AreaTransitionXYZ(0, X, Y, Z)

PedSetUniqueModelStatus(2, -1)

SoundPlayInteractiveStream("MS_BikeFunLow.rsm", 0.5)
SoundSetMidIntensityStream("MS_BikeFunMid.rsm", 0.60000002384186)
SoundSetHighIntensityStream("MS_BikeFunHigh.rsm", 0.60000002384186)

TestPed = PedCreateXYZ(PedID,X,Y,Z)

PedSetAmbiet(TestPed,true)

MissionObjective()

end

MissionObjective = function()
  local x,y = X,Y (Created by Daboss, can be used to make a certain instance.)
  local r1 = x + 3.5
  local r2 = y + 3.5
  local r3 = x - 3.5
  local r4 = y - 3.5
  repeat
    Wait(0)
  until PedInRectangle(gPlayer,r1,r2,r3,r4)

TextPrintString("You're playing hide and seek find the Ped!",4,1)
Wait(3000)
TestBlip = BlipAddXYZ(X,Y,Z,0) (0 is the small Yellow X appearing on the map) (The blip's location should always be the same as the objective location not any wear else. If you script the blip in another location you may mess up player's in finding certain things.)
TextPrintString("Follow the X on the map to go to the location!",4,1)
Wait(3000)
MissionObjectiveFinal()
end

MissionObjectiveFinal = function()
  local x,y = X,Y
  local r1 = x + 3.5
  local r2 = y + 3.5
  local r3 = x - 3.5
  local r4 = y - 3.5
  repeat
    Wait(0)
  until PedInRectangle(gPlayer,r1,r2,r3,r4)

BlipRemove(TestBlip)

TextPrintString("Great you've completed the test mission!",4,1)
Wait(3000)

SoundPlayMissionEndMusic(true, 8)
MissionSucceed(true, false, false)
CameraSetWidescreen(true) 
Wait(4000)
CameraFade(500, 0)
AreaTransitionXYZ(14, -501.4, 316.11, 31.5)
Wait(500)
CameraAllowChange(true)
SoundSetAudioFocusPlayer()
CameraReturnToPlayer()
CameraReset()
CameraSetWidescreen(false)
PlayerSetControl(1)

end

F_PlayerFail = function()
if PedIsDead(gPlayer) then
SoundPlayMissionEndMusic(true, 6)
MissionFail(true, false, false)
Wait(4000)
CameraSetWidescreen(true)
CameraFade(700, 0)
AreaTransitionXYZ(14, -501.4, 316.11, 31.5)
Wait(500)
CameraAllowChange(true)
SoundSetAudioFocusPlayer()
CameraReturnToPlayer()
CameraReset()
CameraSetWidescreen(false)
PlayerSetControl(1)
end

F_LoadAnim = function()
  LoadAnimationGroup("Cheer_Cool2")
  LoadAnimationGroup("NPC_Adult")
  LoadAnimationGroup("TSGate")
  LoadAnimationGroup("SCgrdoor")
  LoadAnimationGroup("Sbarels1")
  LoadAnimationGroup("Area_School")
  LoadAnimationGroup("Px_Rail")
  LoadAnimationGroup("DO_Grap")
  LoadAnimationGroup("1_07_SaveBucky")
  LoadAnimationGroup("TSGate")
  LoadAnimationGroup("F_Nerds")
  LoadAnimationGroup("Hang_Jock")
  LoadAnimationGroup("NPC_AggroTaunt")
  LoadAnimationGroup("Hang_Talking")
  LoadAnimationGroup("1_07_Sk8Board")
  Load("Act/Conv/1_07.act")
  LoadActionTree("Act/Props/SBarels1.act")
  LoadActionTree("Act/Props/barrelLad.act")
  LoadActionTree("Act/Conv/1_03.act")
  LoadActionTree("Act/Anim/1_03_Davis.act")
end

F_CleanUpAnim = function() (Not necessary to use the mission will work either way.)
  UnLoadAnimationGroup("Cheer_Cool2")
  UnLoadAnimationGroup("NPC_Adult")
  UnLoadAnimationGroup("TSGate")
  UnLoadAnimationGroup("SCgrdoor")
  UnLoadAnimationGroup("Sbarels1")
  UnLoadAnimationGroup("Area_School")
  UnLoadAnimationGroup("Px_Rail")
  UnLoadAnimationGroup("DO_Grap")
  UnLoadAnimationGroup("1_07_SaveBucky")
  UnLoadAnimationGroup("TSGate")
  UnLoadAnimationGroup("F_Nerds")
  UnLoadAnimationGroup("Hang_Jock")
  UnLoadAnimationGroup("NPC_AggroTaunt")
  UnLoadAnimationGroup("Hang_Talking")
  UnLoadAnimationGroup("1_07_Sk8Board")
  collectgarbage()
end

main = function()
F_LoadAnim()
F_PlayerFail()
repeat
Wait(0)
until not Alive

Okay so this is a basic setup for a test mission, as you can see I created objectives and set the player to find and do certain things. Their were no enemies introduced in this mission because this is just a test mission in finding and returning a ped.

Next is setting up enemies for the player as an objective it is similar to the very first test mission but Rock-Star separated these test missions so I will be doing the same.

Code: [Select]
MissionSetup = function()
-- (0) is the area code for the main map, all area codes are placed here.
AreaTransitionXYZ(0, X, Y, Z)

PedSetUniqueModelStatus(10, -1) (This set's the ped's free roam model to de-spawn so their are no duplicates.
PedSetUniqueModelStatus(11, -1)
PedSetUniqueModelStatus(12, -1)
PedSetUniqueModelStatus(13, -1)

SoundPlayInteractiveStream("MS_BikeFunLow.rsm", 0.5)
SoundSetMidIntensityStream("MS_BikeFunMid.rsm", 0.60000002384186)
SoundSetHighIntensityStream("MS_BikeFunHigh.rsm", 0.60000002384186)

TestPed = PedCreateXYZ(PedID,X,Y,Z)
TestPed2 = PedCreateXYZ(PedID,X,Y,Z)
TestPed3 = PedCreateXYZ(PedID,X,Y,Z)
TestPed4 = PedCreateXYZ(PedID,X,Y,Z)

PedSetAmbiet(TestPed,true)
PedSetAmbiet(TestPed2,true)
PedSetAmbiet(TestPed3,true)
PedSetAmbiet(TestPed4,true)
MissionObjective()

end

MissionObjective = function()
  local x,y = X,Y (Created by Daboss, can be used to make a certain instance.)
  local r1 = x + 3.5
  local r2 = y + 3.5
  local r3 = x - 3.5
  local r4 = y - 3.5
  repeat
    Wait(0)
  until PedInRectangle(gPlayer,r1,r2,r3,r4)

TextPrintString("Find the enemies and defeat them!",4,1)
Wait(3000)
TestBlip = BlipAddXYZ(X,Y,Z,0) (0 is the small Yellow X appearing on the map) (The blip's location should always be the same as the objective location not any wear else. If you script the blip in another location you may mess up player's in finding certain things.)
TextPrintString("Follow the X on the map to go to the location!",4,1)
Wait(3000)
MissionObjective2()
end

MissionObjective2 = function()
  local x,y = X,Y
  local r1 = x + 3.5
  local r2 = y + 3.5
  local r3 = x - 3.5
  local r4 = y - 3.5
  repeat
    Wait(0)
  until PedInRectangle(gPlayer,r1,r2,r3,r4)

BlipRemove(TestBlip)

TextPrintString("Their they are defeat them!",4,1)
Wait(3000)

gTestBlip = AddBlipForChar(TestPed, 2, 26, 4)
gTestBlip2 = AddBlipForChar(TestPed2, 2, 26, 4)
gTestBlip3 = AddBlipForChar(TestPed3, 2, 26, 4)
gTestBlip4 = AddBlipForChar(TestPed4, 2, 26, 4)

PedSetPedToTypeAttitude(TestPed, 13, 0) (Makes the Ped aggressive with the Player and will attack on sight)
PedSetPedToTypeAttitude(TestPed2, 13, 0)
PedSetPedToTypeAttitude(TestPed3, 13, 0)
PedSetPedToTypeAttitude(TestPed4, 13, 0)

PedAttackPlayer(TestPed,gPlayer,3) (Makes the attack on-sight but the ped won't be able to fight the Player if you have 100% with that clique.
PedAttackPlayer(TestPed2, gPlayer,3)
PedAttackPlayer(TestPed3, gPlayer,3)
PedAttackPlayer(TestPed4, gPlayer,3)

end

F_EnemiesDefeated = function()
if PedIsDead(TestPed) and PedIsDead(TestPed2) and PedIsDead(TestPed3) and PedIsDead(TestPed4) then

TextPrintString("You've defeated the test enemies perfect :D!",4,1)
Wait(3000)

SoundPlayMissionEndMusic(true, 8)
MissionSucceed(true, false, false)
CameraSetWidescreen(true) 
Wait(4000)
CameraFade(500, 0)
AreaTransitionXYZ(14, -501.4, 316.11, 31.5)
Wait(500)
CameraAllowChange(true)
SoundSetAudioFocusPlayer()
CameraReturnToPlayer()
CameraReset()
CameraSetWidescreen(false)
PlayerSetControl(1)
end

F_PlayerFail = function()
if PedIsDead(gPlayer) then
SoundPlayMissionEndMusic(true, 6)
MissionFail(true, false, false)
Wait(4000)
CameraSetWidescreen(true)
CameraFade(700, 0)
AreaTransitionXYZ(14, -501.4, 316.11, 31.5)
Wait(500)
CameraAllowChange(true)
SoundSetAudioFocusPlayer()
CameraReturnToPlayer()
CameraReset()
CameraSetWidescreen(false)
PlayerSetControl(1)
end

F_LoadAnim = function()
  LoadAnimationGroup("Cheer_Cool2")
  LoadAnimationGroup("NPC_Adult")
  LoadAnimationGroup("TSGate")
  LoadAnimationGroup("SCgrdoor")
  LoadAnimationGroup("Sbarels1")
  LoadAnimationGroup("Area_School")
  LoadAnimationGroup("Px_Rail")
  LoadAnimationGroup("DO_Grap")
  LoadAnimationGroup("1_07_SaveBucky")
  LoadAnimationGroup("TSGate")
  LoadAnimationGroup("F_Nerds")
  LoadAnimationGroup("Hang_Jock")
  LoadAnimationGroup("NPC_AggroTaunt")
  LoadAnimationGroup("Hang_Talking")
  LoadAnimationGroup("1_07_Sk8Board")
  Load("Act/Conv/1_07.act")
  LoadActionTree("Act/Props/SBarels1.act")
  LoadActionTree("Act/Props/barrelLad.act")
  LoadActionTree("Act/Conv/1_03.act")
  LoadActionTree("Act/Anim/1_03_Davis.act")
end

F_CleanUpAnim = function() (Not necessary to use the mission will work either way.)
  UnLoadAnimationGroup("Cheer_Cool2")
  UnLoadAnimationGroup("NPC_Adult")
  UnLoadAnimationGroup("TSGate")
  UnLoadAnimationGroup("SCgrdoor")
  UnLoadAnimationGroup("Sbarels1")
  UnLoadAnimationGroup("Area_School")
  UnLoadAnimationGroup("Px_Rail")
  UnLoadAnimationGroup("DO_Grap")
  UnLoadAnimationGroup("1_07_SaveBucky")
  UnLoadAnimationGroup("TSGate")
  UnLoadAnimationGroup("F_Nerds")
  UnLoadAnimationGroup("Hang_Jock")
  UnLoadAnimationGroup("NPC_AggroTaunt")
  UnLoadAnimationGroup("Hang_Talking")
  UnLoadAnimationGroup("1_07_Sk8Board")
  collectgarbage()
end

main = function()
F_LoadAnim()
F_EnemiesDefeated()
F_PlayerFail()
repeat
Wait(0)
until not Alive

Next is creating a test boss fight which is fairly easy you could chose to make the boss do certain animations when the condition is right or you can set anything you want it is up to you but we all know during boss missions the boss ped is always given a set of objectives to do so I will be explaining how to do this.

Code: [Select]
MissionSetup = function()
-- (0) is the area code for the main map, all area codes are placed here.
AreaTransitionXYZ(0, X, Y, Z)

PedSetUniqueModelStatus(10, -1) (This set's the ped's free roam model to de-spawn so their are no duplicates.

SoundPlayInteractiveStream("MS_BikeFunLow.rsm", 0.5)
SoundSetMidIntensityStream("MS_BikeFunMid.rsm", 0.60000002384186)
SoundSetHighIntensityStream("MS_BikeFunHigh.rsm", 0.60000002384186)

TestBossPed = PedCreateXYZ(PedID,X,Y,Z)

MissionObjective()

end

MissionObjective = function()
  local x,y = X,Y (Created by Daboss, can be used to make a certain instance.)
  local r1 = x + 3.5
  local r2 = y + 3.5
  local r3 = x - 3.5
  local r4 = y - 3.5
  repeat
    Wait(0)
  until PedInRectangle(gPlayer,r1,r2,r3,r4)

TextPrintString("Follow TestBoss!",4,1)
Wait(3000)
TestBlip = BlipAddXYZ(X,Y,Z,0) (0 is the small Yellow X appearing on the map) (The blip's location should always be the same as the objective location not any wear else. If you script the blip in another location you may mess up player's in finding certain things.)
TextPrintString("Follow the X on the map to go to the location!",4,1)
Wait(3000)
MissionObjective2()
end

MissionObjective2 = function()
  local x,y = X,Y
  local r1 = x + 3.5
  local r2 = y + 3.5
  local r3 = x - 3.5
  local r4 = y - 3.5
  repeat
    Wait(0)
  until PedInRectangle(gPlayer,r1,r2,r3,r4)

BlipRemove(TestBlip)
TestWeaponBlip = BlipAddXYZ(X,Y,Z,BLIP FLOAT, BLIP TYPE)
PickupCreateXYZ(WEAPONID, X,Y,Z, "WEAPONNAME")
TextPrintString("Pickup the weapon!",4,1)
Wait(3000)
gTestBossBlip = AddBlipForChar(TestBossPed, 2, 26, 4)

PedSetPedToTypeAttitude(TestBossPed, 13, 0) (Makes the Ped aggressive with the Player and will attack on sight)

PedAttackPlayer(TestBossPed,gPlayer,3) (Makes the attack on-sight but the ped won't be able to fight the Player if you have 100% with that clique.
CertainInstance = false
end

TestBossFight1 = function()
if CertainInstance == false and PedIsValid(Gplayer) and PedHasWeapon(Gplayer,WEAPONID) then
BlipRemove(TestWeaponBlip)
SoundPlayInteractiveStreamLocked("MUSIX.rsm", MUSIC_DEFAULT_VOLUME) (I'll add a list of musix when I am on P.C. with my files on it.)
TextPrintString("Use your weapon to combat the TestBoss!",4,1)
Wait(3000)
PedSetInvulnerable(TestBossPed,true)true/false
PedShowHealthBar(TestBossPed, true, "TestBossPed", true)
bHealthBarShown = true
CertainInstance = true
CertainInstance2 = false
end
if PedHasWeapon(gPlayer,WEAPONID) and CertainInstance2 == false then
PedSetWeapon(gPlayer,WEAPONID)
PedSetInvulnerable(TestBossPed,false)true/false
PedSetPedToTypeAttitude(TestBossPed, FACTION, HATRED)--(This is your peds agression, Table your agression also)
PedAttackPlayer(TestBossPed,ATTACKNUBMER)--(Makes the peds attack from a distance.)(Table Also)
TextPrintString("TestBossPed: Come on hurt me you prick!",4,1)
Wait(4000)
CertainInstance2 = true
CertainInstance3 = false
end
if PedGetHealth(TestBossPed,HEALTH) and CertainInstance3 == false and PedIsValid(TestBossPed) then
PedSetInvulnerable(TestBossPed,true)true/false
PedStop(TestBossPed)
PedClearObjectives(TestBossPed)
PedAddPedToIgnoreList(TestBossPed, gPlayer)(Ped Goes here who their facing of course.)
PedIgnoreAttacks(TestBossPed, true)(true/false vice verse)
PedMoveToXYZ(TestBossPed,SPEED,X,Y,Z)
TextPrintString("TestBossPed : You will never catch me dorkwad hahaha!",4,1)
CertainInstance3 = true
CertainInstance4 = false
end
end


TestBossFight2 = function()
if PedIsValid(TestBossPed) and CertainInstance4 = false then
PlayerSetControl(0)(0/1)(0 is no control/1 is control.)
CameraSetFOV(40)(Random Number,40 is close and 60 is far away camera angles.)
CameraSetWidescreen(true)true/false
CameraFollowPed(TestBossPed)
TextPrintString("TestBossPed : You're gonna get wrecked prepare to bully edition!",3,2)
Wait(4000)
PedStop(TestBossPed)
PedClearObjectives(TestBossPed)
PedAddPedToIgnoreList(TestBossPed, gPlayer)(Ped Goes here who their facing of course.)
PedIgnoreAttacks(TestBossPed, true)(true/false vice verse)
Wait(4000)
CameraSetWidescreen(false)true/false
PedRemovePedFromIgnoreList(TestBossPed, gPlayer)
PedIgnoreAttacks(TestBossPed, false)
PedSetInvulnerable(TestBossPed,false)true/false
PedSetPedToTypeAttitude(TestBossPed, 13, 0)--(This is your peds agression, Table your agression also)
PedAttackPlayer(TestBossPed,3)--(Makes the peds attack from a distance.)(Table Also)
PedSetHealth(TestBossPed, 850)
PedFaceObjectNow(TestBossPed, gPlayer, 3)
SoundPlayScriptedSpeechEvent(TestBossPed, "FIGHT_INITIATE", 0, "large")
TextPrintString("Defeat TestBossPed!", 4, 1)
PedShowHealthBar(TestBossPed, true, "TestBossPed", true)
bHealthBarShown = true
end
end

BossDefeated = function()
if PedIsDead(TestBossPed) then

TextPrintString("You've the boss PERFECT :D!",4,1)
Wait(3000)

SoundPlayMissionEndMusic(true, 8)
MissionSucceed(true, false, false)
CameraSetWidescreen(true) 
Wait(4000)
CameraFade(500, 0)
AreaTransitionXYZ(14, -501.4, 316.11, 31.5)
Wait(500)
CameraAllowChange(true)
SoundSetAudioFocusPlayer()
CameraReturnToPlayer()
CameraReset()
CameraSetWidescreen(false)
PlayerSetControl(1)
end
end

F_PlayerFail = function()
if PedIsDead(gPlayer) then
SoundPlayMissionEndMusic(true, 6)
MissionFail(true, false, false)
Wait(4000)
CameraSetWidescreen(true)
CameraFade(700, 0)
AreaTransitionXYZ(14, -501.4, 316.11, 31.5)
Wait(500)
CameraAllowChange(true)
SoundSetAudioFocusPlayer()
CameraReturnToPlayer()
CameraReset()
CameraSetWidescreen(false)
PlayerSetControl(1)
end

F_LoadAnim = function()
  LoadAnimationGroup("Cheer_Cool2")
  LoadAnimationGroup("NPC_Adult")
  LoadAnimationGroup("TSGate")
  LoadAnimationGroup("SCgrdoor")
  LoadAnimationGroup("Sbarels1")
  LoadAnimationGroup("Area_School")
  LoadAnimationGroup("Px_Rail")
  LoadAnimationGroup("DO_Grap")
  LoadAnimationGroup("1_07_SaveBucky")
  LoadAnimationGroup("TSGate")
  LoadAnimationGroup("F_Nerds")
  LoadAnimationGroup("Hang_Jock")
  LoadAnimationGroup("NPC_AggroTaunt")
  LoadAnimationGroup("Hang_Talking")
  LoadAnimationGroup("1_07_Sk8Board")
  Load("Act/Conv/1_07.act")
  LoadActionTree("Act/Props/SBarels1.act")
  LoadActionTree("Act/Props/barrelLad.act")
  LoadActionTree("Act/Conv/1_03.act")
  LoadActionTree("Act/Anim/1_03_Davis.act")
end

F_CleanUpAnim = function() (Not necessary to use the mission will work either way.)
  UnLoadAnimationGroup("Cheer_Cool2")
  UnLoadAnimationGroup("NPC_Adult")
  UnLoadAnimationGroup("TSGate")
  UnLoadAnimationGroup("SCgrdoor")
  UnLoadAnimationGroup("Sbarels1")
  UnLoadAnimationGroup("Area_School")
  UnLoadAnimationGroup("Px_Rail")
  UnLoadAnimationGroup("DO_Grap")
  UnLoadAnimationGroup("1_07_SaveBucky")
  UnLoadAnimationGroup("TSGate")
  UnLoadAnimationGroup("F_Nerds")
  UnLoadAnimationGroup("Hang_Jock")
  UnLoadAnimationGroup("NPC_AggroTaunt")
  UnLoadAnimationGroup("Hang_Talking")
  UnLoadAnimationGroup("1_07_Sk8Board")
  collectgarbage()
end

main = function()
F_LoadAnim()
TestBossFight1()
TestBossFight2()
BossDefeated()
F_PlayerFail()
repeat
Wait(0)
until not Alive

Okay so that is the end of it how you make a boss in your mission script by setting different things for the ped to do as a boss it will give the player different objectives and certain things to do like following or picking up certain weapons.

Next is making a full mission either doing different objectives or a Boss Mission they're completely different from one another. Just like in the original game Boss Missions and Normal Missions were separate from each other we would usually fight a boss at the end of the chapter for the most part. So here is my step by step on how to script a full mission.

Code: [Select]
MissionSetup = function()
-- (0) is the area code for the main map, all area codes are placed here.
AreaTransitionXYZ(0, X, Y, Z)

PedSetUniqueModelStatus(2, -1)

SoundPlayInteractiveStream("MS_BikeFunLow.rsm", 0.5)
SoundSetMidIntensityStream("MS_BikeFunMid.rsm", 0.60000002384186)
SoundSetHighIntensityStream("MS_BikeFunHigh.rsm", 0.60000002384186)

TestPed = PedCreateXYZ(PedID,X,Y,Z)

PedSetAmbiet(TestPed,true)

MissionObjective()

end

MissionObjective = function()
  local x,y = X,Y (Created by Daboss, can be used to make a certain instance.)
  local r1 = x + 3.5
  local r2 = y + 3.5
  local r3 = x - 3.5
  local r4 = y - 3.5
  repeat
    Wait(0)
  until PedInRectangle(gPlayer,r1,r2,r3,r4)

TextPrintString("You're playing hide and seek find the Ped!",4,1)
Wait(3000)
TestBlip = BlipAddXYZ(X,Y,Z,0) (0 is the small Yellow X appearing on the map) (The blip's location should always be the same as the objective location not any wear else. If you script the blip in another location you may mess up player's in finding certain things.)
TextPrintString("Follow the X on the map to go to the location!",4,1)
Wait(3000)
MissionObjectiveFinal()
end

MissionObjectiveFinal = function()
  local x,y = X,Y
  local r1 = x + 3.5
  local r2 = y + 3.5
  local r3 = x - 3.5
  local r4 = y - 3.5
  repeat
    Wait(0)
  until PedInRectangle(gPlayer,r1,r2,r3,r4)

BlipRemove(TestBlip)

TextPrintString("Great you've completed the test mission!",4,1)
Wait(3000)

SoundPlayMissionEndMusic(true, 8)
MissionSucceed(true, false, false)
CameraSetWidescreen(true) 
Wait(4000)
CameraFade(500, 0)
AreaTransitionXYZ(14, -501.4, 316.11, 31.5)
Wait(500)
CameraAllowChange(true)
SoundSetAudioFocusPlayer()
CameraReturnToPlayer()
CameraReset()
CameraSetWidescreen(false)
PlayerSetControl(1)

end

F_PlayerFail = function()
if PedIsDead(gPlayer) then
SoundPlayMissionEndMusic(true, 6)
MissionFail(true, false, false)
Wait(4000)
CameraSetWidescreen(true)
CameraFade(700, 0)
AreaTransitionXYZ(14, -501.4, 316.11, 31.5)
Wait(500)
CameraAllowChange(true)
SoundSetAudioFocusPlayer()
CameraReturnToPlayer()
CameraReset()
CameraSetWidescreen(false)
PlayerSetControl(1)
end

F_LoadAnim = function()
  LoadAnimationGroup("Cheer_Cool2")
  LoadAnimationGroup("NPC_Adult")
  LoadAnimationGroup("TSGate")
  LoadAnimationGroup("SCgrdoor")
  LoadAnimationGroup("Sbarels1")
  LoadAnimationGroup("Area_School")
  LoadAnimationGroup("Px_Rail")
  LoadAnimationGroup("DO_Grap")
  LoadAnimationGroup("1_07_SaveBucky")
  LoadAnimationGroup("TSGate")
  LoadAnimationGroup("F_Nerds")
  LoadAnimationGroup("Hang_Jock")
  LoadAnimationGroup("NPC_AggroTaunt")
  LoadAnimationGroup("Hang_Talking")
  LoadAnimationGroup("1_07_Sk8Board")
  Load("Act/Conv/1_07.act")
  LoadActionTree("Act/Props/SBarels1.act")
  LoadActionTree("Act/Props/barrelLad.act")
  LoadActionTree("Act/Conv/1_03.act")
  LoadActionTree("Act/Anim/1_03_Davis.act")
end

F_CleanUpAnim = function() (Not necessary to use the mission will work either way.)
  UnLoadAnimationGroup("Cheer_Cool2")
  UnLoadAnimationGroup("NPC_Adult")
  UnLoadAnimationGroup("TSGate")
  UnLoadAnimationGroup("SCgrdoor")
  UnLoadAnimationGroup("Sbarels1")
  UnLoadAnimationGroup("Area_School")
  UnLoadAnimationGroup("Px_Rail")
  UnLoadAnimationGroup("DO_Grap")
  UnLoadAnimationGroup("1_07_SaveBucky")
  UnLoadAnimationGroup("TSGate")
  UnLoadAnimationGroup("F_Nerds")
  UnLoadAnimationGroup("Hang_Jock")
  UnLoadAnimationGroup("NPC_AggroTaunt")
  UnLoadAnimationGroup("Hang_Talking")
  UnLoadAnimationGroup("1_07_Sk8Board")
  collectgarbage()
end

main = function()
F_LoadAnim()
F_PlayerFail()
repeat
Wait(0)
until not Alive

Okay so this is a basic setup for a test mission, as you can see I created objectives and set the player to find and do certain things. Their were no enemies introduced in this mission because this is just a test mission in finding and returning a ped.

Next is setting up enemies for the player as an objective it is similar to the very first test mission but Rock-Star separated these test missions so I will be doing the same. I will also show how to make your very own cut scene I am not that good at CamerSetXYZ though but I will update it soon enough with the function.

Code: [Select]
MissionSetup = function()
-- (0) is the area code for the main map, all area codes are placed here.
AreaTransitionXYZ(0, X, Y, Z)

TestPed = PedCreateXYZ(PedID,X,Y,Z)
TestPed2 = PedCreateXYZ(PedID,X,Y,Z)
TestPed3 = PedCreateXYZ(PedID,X,Y,Z)
CameraSetWideScreen(true)(Always use this to set the cut-scene to widescreen like in normal missions.)
SoundDisableSpeech_ActionTree()(Use this so your ped's wont ramble during your cut-scenes.)
PedMoveToXYZ(TestPed,SPEED,X,Y,Z)
PedMoveToXYZ(TestPed2,SPEED,X,Y,Z)
  local x,y = X,Y
  local r1 = x + 3.5
  local r2 = y + 3.5
  local r3 = x - 3.5
  local r4 = y - 3.5
  repeat
    Wait(0)
  until PedInRectangle(TestPed,r1,r2,r3,r4)
PedStop(TestPed)
PedStop(TestPed2)

CameraSetFOV(60)

TextPrintString("TestPed : So looking forward to that brick huh dude?",4,1)
Wait(4000)
TextPrintString("TestPed2 : Sure enough I just hope those smug cops don't show up!",4,1)
Wait(4000)
PedFaceObjectNow(TestPed,TestPed3, 3,Only number I know I am laughing out loud at your hysterical statement! .)
PedFaceObjectNow(TestPed2,TestPed3, 3,Only number I know I am laughing out loud at your hysterical statement! .)
PedMoveToXYZ(TestPed3,SPEED,X,Y,Z)
  local x,y = X,Y
  local r1 = x + 3.5
  local r2 = y + 3.5
  local r3 = x - 3.5
  local r4 = y - 3.5
  repeat
    Wait(0)
  until PedInRectangle(TestPed3,r1,r2,r3,r4)
PedStop(TestPed3)

CameraFollowPed(TestPed3)

TextPrintString("TestPed : Their he is, hopefully he has the stuff!",4,1)
Wait(4000)
TextPrintString("TestPed2 : Cool, this is awesome where gonna make so much money!",4,1)
Wait(4000)
TextPrintString("TestPed3 : I got the stuff so where's the money!",4,1)
Wait(4000)
TextPrintString("TestPed2 : Right here nice doin business with you chump!",4,1)
Wait(2000)
CameraSetWidescreen(false)
CameraFollowPed(TestPed)
PlayerSetControl(1)
CameraReset()
CameraReturnToPlayer()
TextPrintString("Take the drugs to your drug lord without getting busted by cops.",4,1)
Wait(4000)
TestBlip = BlipAddXYZ(X,Y,Z, BLIP TYPE)
CopIsAround = false
MissionObjective()
end

TurnAnyCopToBuster = function()
if PedIsValid(TestPed) and CopIsAround == false then
PedFindAmbientPedOfModelID(MODELID)
PedFindAmbientPedOfModelID(MODELID)
PedFindAmbientPedOfModelID(MODELID)
PedFindAmbientPedOfModelID(MODELID)
PedFindAmbientPedOfModelID(MODELID)
PedFindAmbientPedOfModelID(MODELID)
Disablepunishmentsystem = false
PedSetPunishmentPoints(400)
PedSetPedToTypeAttitude(COP1, 13, 0) (Makes the Ped aggressive with the Player and will attack on sight)
PedSetPedToTypeAttitude(COP2, 13, 0)
PedSetPedToTypeAttitude(COP3, 13, 0)
PedSetPedToTypeAttitude(COP4, 13, 0)
PedSetPedToTypeAttitude(COP5, 13, 0)
PedSetPedToTypeAttitude(COP6, 13, 0)
CopIsAround = true
end
end

MissionObjective = function()
  local x,y = X,Y (Created by Daboss, can be used to make a certain instance.)
  local r1 = x + 3.5
  local r2 = y + 3.5
  local r3 = x - 3.5
  local r4 = y - 3.5
  repeat
    Wait(0)
  until PedInRectangle(gPlayer,r1,r2,r3,r4)

BlipRemove(TestBlip)


TestPed5 = PedCreateXYZ(PedID,X,Y,Z)
TestPed6 = PedCreateXYZ(PedID,X,Y,Z)
TestPed7 = PedCreateXYZ(PedID,X,Y,Z)
TestPed8 = PedCreateXYZ(PedID,X,Y,Z)

CameraSetWidescreen(true)
CameraFollowPed(TestPed5)

TextPrintString("TestPed5 : What the hell do you think you're doing sellin on are turf get those bastard's!",4,1)
Wait(5000)
gTestBlip2 = AddBlipForChar(TestPed6, 2, 26, 4)
gTestBlip3 = AddBlipForChar(TestPed7, 2, 26, 4)
gTestBlip4 = AddBlipForChar(TestPed8, 2, 26, 4)

PedSetPedToTypeAttitude(TestPed6, 13, 0) (Makes the Ped aggressive with the Player and will attack on sight)
PedSetPedToTypeAttitude(TestPed7, 13, 0)
PedSetPedToTypeAttitude(TestPed8, 13, 0)

PedAttackPlayer(TestPed6,gPlayer,3) (Makes the attack on-sight but the ped won't be able to fight the Player if you have 100% with that clique.
PedAttackPlayer(TestPed7, gPlayer,3)
PedAttackPlayer(TestPed8, gPlayer,3)
Wait(3000)
TextPrintString("Defeat the drug dealers before they steal your drugs!",4,1)
Wait(4000)
PedMoveToXYZ(TestPed5,SPEED,X,Y,Z)
end

F_DrugDealersRekt = function()
if PedIsDead(TestPed6) and PedIsDead(TestPed7) and PedIsDead(TestPed8) then
TextPrintString("Follow the last drug dealer to his turf!",4,1)
Wait(4000)
TestBlip = BlipAddXYZ(BLIP,X,Y,Z)
TestPed9 = PedCreateXYZ(PedID,X,Y,Z)
TestPed10 = PedCreateXYZ(PedID,X,Y,Z)
TestPed11 = PedCreateXYZ(PedID,X,Y,Z)
TestPed12 = PedCreateXYZ(PedID,X,Y,Z)

gTestBlip2 = AddBlipForChar(TestPed9, 2, 26, 4)
gTestBlip3 = AddBlipForChar(TestPed10, 2, 26, 4)
gTestBlip4 = AddBlipForChar(TestPed11, 2, 26, 4)
gTestBlip4 = AddBlipForChar(TestPed12, 2, 26, 4)

PedSetPedToTypeAttitude(TestPed9, 13, 0) (Makes the Ped aggressive with the Player and will attack on sight)
PedSetPedToTypeAttitude(TestPed10, 13, 0)
PedSetPedToTypeAttitude(TestPed11, 13, 0)
PedSetPedToTypeAttitude(TestPed12, 13, 0)


PedAttackPlayer(TestPed9,gPlayer,3) (Makes the attack on-sight but the ped won't be able to fight the Player if you have 100% with that clique.
PedAttackPlayer(TestPed10, gPlayer,3)
PedAttackPlayer(TestPed11, gPlayer,3)
PedAttackPlayer(TestPed12, gPlayer,3)

TextPrintString("TestPed5 : Boy's take care of those two pricks and defeat them!",4,1)
MissionObjective2()
end
end



MissionObjective2 = function()

  local x,y = X,Y
  local r1 = x + 3.5
  local r2 = y + 3.5
  local r3 = x - 3.5
  local r4 = y - 3.5
  repeat
    Wait(0)
  until PedInRectangle(gPlayer,r1,r2,r3,r4)

BlipRemove(TestBlip)
TextPrintString("Take'em out you damn slacker's what the fuck do I pay you for!",4,1)
Wait(4000)
VehicleCreateXYZ(VEHICLEID,X,Y,Z)
VehicleCreateXYZ(VEHICLEID2,X,Y,Z)
end

F_EnemiesDefeated = function()
if PedIsDead(TestPed9) and PedIsDead(TestPed10) and PedIsDead(TestPed11) and PedIsDead(TestPed12) then
TextPrintString("TestPed5 : Guess I gotta do the shit myself, prepare to get wasted you pricks!",4,1)
Wait(5000)
CertainInstance = false
end
if CertainInstance == false and PedIsValid(TestPed5) and PedHasWeapon(TestPed5,WEAPONID) then
TextPrintString("TestPed5 : Can't do shit against my Super Spud Gun prepare to get rekt!",4,1)
Wait(4000)
TextPrintString("Use the drug dealers car's as a barrier to protect yourselves!",4,1)
CertainInstance = true
CertainInstance2 = false
end
if CertainInstance2 == false and PedIsValid(TestPed5) then
TextPrintString("TestPed5 : Using the car as a barrier huh? Fuck you assholes hahaha!",4,1)
Wait(4000)
PedSetActionNode(ACTIONNODE)
CertainInstance2 = true
CertainInstance3 = false
end
if CertainInstance3 == false and PedIsValid(TestPed2) and PedHasWeapon(TestPed2,WEAPONID) then
TextPrintString("TestPed2 : Eat this you dumb fuck, didn't see it coming huh?!",4,1)
Wait(3000)
PedMoveToXYZ(TestPed2,SPEED,X,Y,Z)
Wait(1500)
PedSetActionNode(ACTIONNODE)
Wait(1000)
PedSetHealth(TestPed5,0)

TestBlip = BlipAddXYZ(Blip,X,Y,Z)
TextPrintString("Go to your drug lord he's waiting for you!",4,1)
Wait(3000)
DrugLord = PedCreateXYZ(PedID,X,Y,Z)
MissionObjective3()
end
end

MissionObjective3 = function()
  local x,y = X,Y
  local r1 = x + 3.5
  local r2 = y + 3.5
  local r3 = x - 3.5
  local r4 = y - 3.5
  repeat
    Wait(0)
  until PedInRectangle(gPlayer,r1,r2,r3,r4)

BlipRemove(TestBlip)

CameraSetWideScreen(true)(Always use this to set the cut-scene to widescreen like in normal missions.)
SoundDisableSpeech_ActionTree()(Use this so your ped's wont ramble during your cut-scenes.)
PedMoveToXYZ(TestPed,SPEED,X,Y,Z)
PedMoveToXYZ(TestPed2,SPEED,X,Y,Z)
  local x,y = X,Y
  local r1 = x + 3.5
  local r2 = y + 3.5
  local r3 = x - 3.5
  local r4 = y - 3.5
  repeat
    Wait(0)
  until PedInRectangle(TestPed,r1,r2,r3,r4)
PedStop(TestPed)
PedStop(TestPed2)

CameraSetFOV(60)

TextPrintString("DrugLord : Alright you got the shit, thanks here's your cut!",4,1)
Wait(3000)
TextPrintString("DrugLord: Next time be on time or I'll take your life and the drugs!",4,1)
Wait(10000)
SoundPlayMissionEndMusic(true, 8)
MissionSucceed(true, false, false)
CameraSetWidescreen(true) 
Wait(4000)
CameraFade(500, 0)
AreaTransitionXYZ(14, -501.4, 316.11, 31.5)
Wait(500)
CameraAllowChange(true)
SoundSetAudioFocusPlayer()
CameraReturnToPlayer()
CameraReset()
CameraSetWidescreen(false)
PlayerSetControl(1)
end

F_PlayerFail = function()
if PedIsDead(gPlayer) then
SoundPlayMissionEndMusic(true, 6)
MissionFail(true, false, false)
Wait(4000)
CameraSetWidescreen(true)
CameraFade(700, 0)
AreaTransitionXYZ(14, -501.4, 316.11, 31.5)
Wait(500)
CameraAllowChange(true)
SoundSetAudioFocusPlayer()
CameraReturnToPlayer()
CameraReset()
CameraSetWidescreen(false)
PlayerSetControl(1)
end
end

F_LoadAnim = function()
  LoadAnimationGroup("Cheer_Cool2")
  LoadAnimationGroup("NPC_Adult")
  LoadAnimationGroup("TSGate")
  LoadAnimationGroup("SCgrdoor")
  LoadAnimationGroup("Sbarels1")
  LoadAnimationGroup("Area_School")
  LoadAnimationGroup("Px_Rail")
  LoadAnimationGroup("DO_Grap")
  LoadAnimationGroup("1_07_SaveBucky")
  LoadAnimationGroup("TSGate")
  LoadAnimationGroup("F_Nerds")
  LoadAnimationGroup("Hang_Jock")
  LoadAnimationGroup("NPC_AggroTaunt")
  LoadAnimationGroup("Hang_Talking")
  LoadAnimationGroup("1_07_Sk8Board")
  Load("Act/Conv/1_07.act")
  LoadActionTree("Act/Props/SBarels1.act")
  LoadActionTree("Act/Props/barrelLad.act")
  LoadActionTree("Act/Conv/1_03.act")
  LoadActionTree("Act/Anim/1_03_Davis.act")
end

F_CleanUpAnim = function() (Not necessary to use the mission will work either way.)
  UnLoadAnimationGroup("Cheer_Cool2")
  UnLoadAnimationGroup("NPC_Adult")
  UnLoadAnimationGroup("TSGate")
  UnLoadAnimationGroup("SCgrdoor")
  UnLoadAnimationGroup("Sbarels1")
  UnLoadAnimationGroup("Area_School")
  UnLoadAnimationGroup("Px_Rail")
  UnLoadAnimationGroup("DO_Grap")
  UnLoadAnimationGroup("1_07_SaveBucky")
  UnLoadAnimationGroup("TSGate")
  UnLoadAnimationGroup("F_Nerds")
  UnLoadAnimationGroup("Hang_Jock")
  UnLoadAnimationGroup("NPC_AggroTaunt")
  UnLoadAnimationGroup("Hang_Talking")
  UnLoadAnimationGroup("1_07_Sk8Board")
  collectgarbage()
end

main = function()
F_LoadAnim()
TurnAnyCopToBuster()
F_DrugDealersRekt()
F_EnemiesDefeated()
F_PlayerFail()
repeat
Wait(0)
until not Alive

Okay so that was a complete mission I would want someone to script this one I am laughing out loud at your hysterical statement!  seems awesome! Okay next we will focus on creating a full boss mission that is a little harder in scripting that but you can do this just pay attention and follow every step on where everything goes and how everything works.
Updated 7/29/2015  8) ( ͡° ͜ʖ ͡°)( ͡° ͜ʖ ͡°)( ͡° ͜ʖ ͡°)( ͡° ͜ʖ ͡°)
--AlphaTech
« Last Edit: March 09, 2016, 02:37:09 PM by AlphaTech »

Offline denizthebest

  • Jr. Member
  • **
  • Posts: 85
  • Half way there.
    • View Profile
Re: Custom Mission Scripting - The Basic's
« Reply #1 on: July 28, 2015, 01:48:36 PM »
Good job alpha.

Offline AlphaTech

  • LostInSpace
  • Sr. Member
  • ***
  • Posts: 758
  • Gender: Male
  • The name's AlphaTECH, whatca need help with?! :)
    • View Profile
Re: Custom Mission Scripting - The Basic's
« Reply #2 on: July 28, 2015, 01:55:10 PM »
Good job alpha.

Thanks finally starting to make a tutorial for scripting a mission and setting up certain things.

Offline denizthebest

  • Jr. Member
  • **
  • Posts: 85
  • Half way there.
    • View Profile
Re: Custom Mission Scripting - The Basic's
« Reply #3 on: July 28, 2015, 05:45:27 PM »
Good job alpha.

Thanks finally starting to make a tutorial for scripting a mission and setting up certain things.
i have one question how do you make  camera move to certain area is it MoveCameraXYZ() ?

Offline AlphaTech

  • LostInSpace
  • Sr. Member
  • ***
  • Posts: 758
  • Gender: Male
  • The name's AlphaTECH, whatca need help with?! :)
    • View Profile
Re: Custom Mission Scripting - The Basic's
« Reply #4 on: July 28, 2015, 06:40:00 PM »
It's something with camercascroll or something like that.

Offline denizthebest

  • Jr. Member
  • **
  • Posts: 85
  • Half way there.
    • View Profile
Re: Custom Mission Scripting - The Basic's
« Reply #5 on: July 28, 2015, 06:52:41 PM »
Ok thanks

Offline AlphaTech

  • LostInSpace
  • Sr. Member
  • ***
  • Posts: 758
  • Gender: Male
  • The name's AlphaTECH, whatca need help with?! :)
    • View Profile
Re: Custom Mission Scripting - The Basic's
« Reply #6 on: July 28, 2015, 11:06:36 PM »
I will explain all of this sooner or later, how some functions work and how to setup camera's.

Offline UltimateGamer9

  • Full Member
  • ***
  • Posts: 190
  • Gender: Male
    • View Profile
Re: Custom Mission Scripting - The Basic's
« Reply #7 on: July 28, 2015, 11:24:06 PM »
hmm might be good for newbies

Offline DaBOSS54320

  • Hero Member
  • ****
  • Posts: 3,398
  • Gender: Female
    • View Profile
Re: Custom Mission Scripting - The Basic's
« Reply #8 on: July 29, 2015, 02:34:32 AM »
Good job, I hope this helps people. I haz some suggestions and corrections though for you/anyone following the tutorial:

-You misspelled PedSetAmbient.
-Using PedIsInAreaXYZ(ped,x,y,z,range) may be easier than the rectangle thing.
-You don't need to use l_70_64... I guess that's not a problem really as it is still a very valid variable name but that name is pretty cryptic and may make your script harder to work with.

Offline denizthebest

  • Jr. Member
  • **
  • Posts: 85
  • Half way there.
    • View Profile
Re: Custom Mission Scripting - The Basic's
« Reply #9 on: July 29, 2015, 05:45:18 AM »
İ already finished my mission just correcting few thing in it bugs and etc.but im not going to release it because im working on a better idea.

Offline AlphaTech

  • LostInSpace
  • Sr. Member
  • ***
  • Posts: 758
  • Gender: Male
  • The name's AlphaTECH, whatca need help with?! :)
    • View Profile
Re: Custom Mission Scripting - The Basic's
« Reply #10 on: July 29, 2015, 09:42:10 AM »
Good job, I hope this helps people. I haz some suggestions and corrections though for you/anyone following the tutorial:

-You misspelled PedSetAmbient.
-Using PedIsInAreaXYZ(ped,x,y,z,range) may be easier than the rectangle thing.
-You don't need to use l_70_64... I guess that's not a problem really as it is still a very valid variable name but that name is pretty cryptic and may make your script harder to work with.

Heh I knew it was something but yeah I will get to fixing most of it and updating it. I've been mostly busy lately but I can at least script some stuff. Also my variable is just one I often use as default to number them. I guess I will change the false to another name.
Also I have a question, How to return true/false like in some scripts?
« Last Edit: August 03, 2015, 01:11:24 PM by AlphaTech »

Offline AlphaTech

  • LostInSpace
  • Sr. Member
  • ***
  • Posts: 758
  • Gender: Male
  • The name's AlphaTECH, whatca need help with?! :)
    • View Profile
Re: Custom Mission Scripting - The Basic's
« Reply #11 on: July 29, 2015, 09:43:42 AM »
İ already finished my mission just correcting few thing in it bugs and etc.but im not going to release it because im working on a better idea.

What's the point in making it if you don't release it. I wanna see all missions I enjoy playing and helping fix them.

Offline AlphaTech

  • LostInSpace
  • Sr. Member
  • ***
  • Posts: 758
  • Gender: Male
  • The name's AlphaTECH, whatca need help with?! :)
    • View Profile
Re: Custom Mission Scripting - The Basic's
« Reply #12 on: July 29, 2015, 09:55:30 AM »
hmm might be good for newbies

Heh aren't you kind of a newbie also? Trust me i'm still a newbie I don't consider newbies is all because we all learn new things daily about modding.

Offline UltimateGamer9

  • Full Member
  • ***
  • Posts: 190
  • Gender: Male
    • View Profile
Re: Custom Mission Scripting - The Basic's
« Reply #13 on: July 29, 2015, 10:00:47 AM »
hmm might be good for newbies

Heh aren't you kind of a newbie also? Trust me i'm still a newbie I don't consider newbies is all because we all learn new things daily about modding.
no i just made a fight in the hole i show u in mod showroom section

Offline UltimateGamer9

  • Full Member
  • ***
  • Posts: 190
  • Gender: Male
    • View Profile
Re: Custom Mission Scripting - The Basic's
« Reply #14 on: July 29, 2015, 10:01:16 AM »
but trust me im not really that great