function main() Wait(500) LoadAllAnim(true) while true do for i, Ped in { PedFindInAreaXYZ(0, 0, 0, 999999) }, nil, nil do if PedIsValid(Ped) and Ped ~= gPlayer and PedIsFemale(Ped) and not PedIsModel(Ped, 39) then PedSetEmotionTowardsPed(Ped, gPlayer, 4) PedSetFlag(Ped, 84, true) end end if PedHasWeapon(gPlayer, 327) and IsButtonPressed(12, 0) and not PedIsValid(PedGetGrappleTargetPed(gPlayer)) then ExecuteActionNode(gPlayer, "/Global/BOSS_Darby/Special/Throw", "Act/Anim/BOSS_Darby.act") while PedIsPlaying(gPlayer, "/Global/BOSS_Darby/Special/Throw", true) do Wait(0) end end if not PlayerIsInAnyVehicle() then local Weapons_Pack = { "320", "420", "396" } for WEAPON_NUMBER, WEAPONS in ipairs(Weapons_Pack) do if not PlayerHasItem(WEAPONS) then GiveWeaponToPlayer(WEAPONS, 100) end end end if IsButtonPressed(15, 0) and PedIsValid(PedGetGrappleTargetPed(gPlayer)) and (PedIsPlaying(gPlayer, "/Global/Actions/Grapples/Front/Grapples/Hold_Idle/GrappleLoco/GrappleRotate", true) or PedIsPlaying(gPlayer, "/Global/Actions/Grapples/Front/Grapples/GrappleMoves/GrappleStrikes/Punch_Hold_Idle", true)) then local size = table.getn local Grapple = { { "/Global/Actions/Grapples/GrappleReversals/StandingReversals/Sprawl/GIVE", "Act/Globals.act" }, { "/Global/Actions/Grapples/Front/Grapples/GrappleMoves/Backbreaker", "Act/Globals.act" }, { "/Global/Actions/Grapples/Front/Grapples/GrappleOpps/Melee/Greaser/GrabKnees/GV", "Globals/G_Melee_A.act" }, { "/Global/Actions/Grapples/Front/Grapples/GrappleMoves/PowerBomb/Give", "Act/Globals.act" }, { "/Global/G_Johnny/Offense/Special/SpecialActions/Grapples/Dash", "Act/Anim/G_Johnny.act" }, { "/Global/Actions/Grapples/Front/Grapples/GrappleMoves/BearHug", "Act/Globals.act" }, { "/Global/J_Damon/Offense/SpecialStart/StartRun", "Act/Anim/J_Damon.act" }, { "/Global/Actions/Grapples/Front/Grapples/GrappleMoves/Adult_Takedown/Give", "Act/Globals.act" }, { "/Global/Actions/Grapples/Front/Grapples/GrappleMoves/BodySlam", "Act/Globals.act" }, { "/Global/Actions/Grapples/Front/Grapples/GrappleMoves/TandemGrapple", "Globals/BOSS_Russell.act" } } local Grapples = math.random(1, size(Grapple)) PedSetAITree(gPlayer, "/Global/DarbyAI", "Act/AI_DARBY_2_B.act") PedSetActionNode(gPlayer, Grapple[Grapples][1], Grapple[Grapples][2]) PedSetAITree(gPlayer, "/Global/PlayerAI", "AI/AI/PlayerAI.act") end if IsButtonPressed(15, 0) and not PedIsValid(PedGetGrappleTargetPed(gPlayer)) then local size1 = table.getn local Evade = { { "/Global/P_Striker_B/Defense/Evade/EvadeBack/EvadeBack", "Act/Anim/P_Striker_B.act" }, { "/Global/BOSS_Russell/Defense/Evade/EvadeInterrupt/EvadeInterrupt", "Act/Anim/BOSS_Russell.act" }, { "/Global/Nemesis/Defense/Evade/Back", "Act/Anim/Nemesis.act" }, { "/Global/P_Grappler_A/Defense/Evade/EvadeBack/Evade", "Act/Anim/P_Grappler_A.act" }, { "/Global/BOSS_Darby/Offense/NonCombatActions/Hopback", "Act/Anim/BOSS_Darby.act" } } local Evades = math.random(1, size1(Evade)) PedSetActionNode(gPlayer, Evade[Evades][1], Evade[Evades][2]) if PedIsPlaying(gPlayer, "/Global/Nemesis/Defense/Evade/Back", true) then Wait(250) PedSetAITree(gPlayer, "/Global/DarbyAI", "Act/AI_DARBY_2_B.act") PedSetActionNode(gPlayer, "/Global/P_Striker_A/Defense/Evade/EvadeCounter/LightAttacks/EvadeBackPunch", "Act/Anim/P_Striker_A.act") PedSetAITree(gPlayer, "/Global/PlayerAI", "AI/AI/PlayerAI.act") elseif PedIsPlaying(gPlayer, "/Global/P_Striker_B/Defense/Evade/EvadeBack/EvadeBack", true) then Wait(325) PedSetAITree(gPlayer, "/Global/DarbyAI", "Act/AI_DARBY_2_B.act") PedSetActionNode(gPlayer, "/Global/P_Striker_B/Offense/Short/Grapples/HeavyAttacks/Catch_Throw", "Act/Anim/P_Striker_B.act") PedSetAITree(gPlayer, "/Global/PlayerAI", "AI/AI/PlayerAI.act") elseif PedIsPlaying(gPlayer, "/Global/P_Grappler_A/Defense/Evade/EvadeBack/Evade", true) then Wait(325) PedSetAITree(gPlayer, "/Global/DarbyAI", "Act/AI_DARBY_2_B.act") PedSetActionNode(gPlayer, "/Global/P_Grappler_A/Offense/Short/Strikes/LightAttacks/LeftJabHead/LeftJabBody", "Act/Anim/P_Grappler_A.act") PedSetAITree(gPlayer, "/Global/PlayerAI", "AI/AI/PlayerAI.act") end end if IsButtonPressed(9, 0) and IsButtonPressed(6, 0) and not PedIsValid(PedGetGrappleTargetPed(gPlayer)) then local size2 = table.getn local Punch = { { "/Global/BOSS_Russell/Offense/Special/Invincible/BarserkGrapple", "Act/Anim/BOSS_Russell.act" }, { "/Global/J_Melee_A/Offense/Medium/Strikes/Unblockable", "Act/Anim/J_Melee_A.act" }, { "/Global/BOSS_Darby/Offense/Short/Grapples/HeavyAttacks/Catch_Throw", "Act/Anim/BOSS_Darby.act" }, { "/Global/G_Johnny/Offense/Special/SpecialActions/LightAttacks", "Act/Anim/G_Johnny.act" }, { "/Global/J_Mascot/Offense/Special/Mascot/Mascot/SpecialChoose/Headbutt/Invincible/Headbutt", "Act/Anim/J_Mascot.act" }, { "/Global/DO_Striker_A/Offense/Medium/HeavyAttacks", "Act/Anim/DO_Striker_A.act" }, { "/Global/Crazy_Basic/Offense/Medium", "Act/Anim/Crazy_Basic.act" }, { "/Global/BOSS_Darby/Special/Throw", "Act/Anim/BOSS_Darby.act" } } local Punches = math.random(1, size2(Punch)) PedSetActionNode(gPlayer, Punch[Punches][1], Punch[Punches][2]) end if IsButtonPressed(8, 0) and IsButtonPressed(6, 0) and not PedIsValid(PedGetGrappleTargetPed(gPlayer)) then local size3 = table.getn local Punch1 = { { "/Global/1_11X1/Animations/GaryIdleInBed", "Act/Conv/1_11X1.act" }, { "/Global/404Conv/Nerds/Dance1", "Act/Conv/4_04.act" }, { "/Global/4_05/NIS/Mascot/MascotPool", "Act/Conv/4_05.act" }, { "/Global/3_04/3_04_Anim/JohnnyShove/GIVE", "Act/Conv/3_04.act" }, { "/Global/4_B2/Defensive/IntoPose", "Act/Conv/4_B2.act" }, { "/Global/2_S05/Anims/Drink", "Act/Conv/2_S05.act" }, { "/Global/2_B/DrbyVault/PlayAnim", "Act/Conv/2_B.act" } } local Punches1 = math.random(1, size3(Punch1)) PedSetActionNode(gPlayer, Punch1[Punches1][1], Punch1[Punches1][2]) end if IsButtonPressed(3, 0) and not PedIsValid(PedGetGrappleTargetPed(gPlayer)) then PedSetActionTree(gPlayer, "/Global/Player", "Act/Anim/Player.act") end local TroubleMeter = PlayerGetPunishmentPoints() if TroubleMeter > 199 then PlayerSetPunishmentPoints(1) end PED_Recruit() Wait(0) end end function PED_Recruit() local target = PedGetTargetPed() if IsButtonPressed(2, 0) and PedIsValid(target) and not PedHasAllyLeader(target) then PedRecruitAlly(PedGetLastRecruited(), target) end end function PedGetLastRecruited() local PlayerAlly = PedGetAllyFollower(gPlayer) if not PedHasAlly(gPlayer) then return gPlayer elseif PedHasAlly(gPlayer) and not PedHasAllyFollower(PlayerAlly) then return PedGetAllyFollower(gPlayer) elseif PedHasAlly(gPlayer) and PedHasAllyFollower(PlayerAlly) then LastRecruited = PedGetAllyFollower(gPlayer) repeat LastRecruited = PedGetAllyFollower(LastRecruited) Wait(0) until not PedHasAllyFollower(LastRecruited) return LastRecruited end end function LoadAllAnim(Load) LoadAnimationGroup("3_04WrongPtTown") LoadAnimationGroup("4_04_FunhouseFun") LoadAnimationGroup("Authority") LoadAnimationGroup("Boxing") LoadAnimationGroup("B_Striker") LoadAnimationGroup("CV_Female") LoadAnimationGroup("CV_Male") LoadAnimationGroup("DO_Edgar") LoadAnimationGroup("DO_Grap") LoadAnimationGroup("DO_StrikeCombo") LoadAnimationGroup("DO_Striker") LoadAnimationGroup("Earnest") LoadAnimationGroup("F_Adult") LoadAnimationGroup("F_BULLY") LoadAnimationGroup("F_Crazy") LoadAnimationGroup("F_Douts") LoadAnimationGroup("F_Girls") LoadAnimationGroup("F_Greas") LoadAnimationGroup("F_Jocks") LoadAnimationGroup("F_Nerds") LoadAnimationGroup("F_OldPeds") LoadAnimationGroup("F_Pref") LoadAnimationGroup("F_Preps") LoadAnimationGroup("G_Grappler") LoadAnimationGroup("G_Johnny") LoadAnimationGroup("G_Striker") LoadAnimationGroup("Grap") LoadAnimationGroup("J_Damon") LoadAnimationGroup("J_Grappler") LoadAnimationGroup("J_Melee") LoadAnimationGroup("J_Ranged") LoadAnimationGroup("J_Striker") LoadAnimationGroup("KissAdult") LoadAnimationGroup("LE_Orderly") LoadAnimationGroup("Nemesis") LoadAnimationGroup("NIS_6_02") LoadAnimationGroup("NPC_Mascot") LoadAnimationGroup("N_Ranged") LoadAnimationGroup("N_Striker") LoadAnimationGroup("N_Striker_A") LoadAnimationGroup("N_Striker_B") LoadAnimationGroup("P_Grappler") LoadAnimationGroup("P_Striker") LoadAnimationGroup("PunchBag") LoadAnimationGroup("Qped") LoadAnimationGroup("Rat_Ped") LoadAnimationGroup("Russell") LoadAnimationGroup("Russell_Pbomb") LoadAnimationGroup("Straf_Dout") LoadAnimationGroup("Straf_Fat") LoadAnimationGroup("Straf_Female") LoadAnimationGroup("Straf_Male") LoadAnimationGroup("Straf_Nerd") LoadAnimationGroup("Straf_Prep") LoadAnimationGroup("Straf_Savage") LoadAnimationGroup("Straf_Wrest") LoadAnimationGroup("TE_Female") collectgarbage() end function F_AttendedClass() if IsMissionCompleated("3_08") and not IsMissionCompleated("3_08_PostDummy") then return end SetSkippedClass(false) PlayerSetPunishmentPoints(0) end function F_MissedClass() if IsMissionCompleated("3_08") and not IsMissionCompleated("3_08_PostDummy") then return end SetSkippedClass(true) StatAddToInt(166) end function F_AttendedCurfew() if not PedInConversation(gPlayer) and not MissionActive() then TextPrintString("You got home in time for curfew", 4) end end function F_MissedCurfew() if not PedInConversation(gPlayer) and not MissionActive() then TextPrint("TM_TIRED5", 4, 2) end end function F_StartClass() if IsMissionCompleated("3_08") and not IsMissionCompleated("3_08_PostDummy") then return end F_RingSchoolBell() local l_6_0 = PlayerGetPunishmentPoints() + GetSkippingPunishment() end function F_EndClass() if IsMissionCompleated("3_08") and not IsMissionCompleated("3_08_PostDummy") then return end F_RingSchoolBell() end function F_StartMorning() F_UpdateTimeCycle() end function F_EndMorning() F_UpdateTimeCycle() end function F_StartLunch() if IsMissionCompleated("3_08") and not IsMissionCompleated("3_08_PostDummy") then F_UpdateTimeCycle() return end F_UpdateTimeCycle() end function F_EndLunch() F_UpdateTimeCycle() end function F_StartAfternoon() F_UpdateTimeCycle() end function F_EndAfternoon() F_UpdateTimeCycle() end function F_StartEvening() F_UpdateTimeCycle() end function F_EndEvening() F_UpdateTimeCycle() end function F_StartCurfew_SlightlyTired() F_UpdateTimeCycle() end function F_StartCurfew_Tired() F_UpdateTimeCycle() end function F_StartCurfew_MoreTired() F_UpdateTimeCycle() end function F_StartCurfew_TooTired() F_UpdateTimeCycle() end function F_EndCurfew_TooTired() F_UpdateTimeCycle() end function F_EndTired() F_UpdateTimeCycle() end function F_Nothing() end function F_ClassWarning() if IsMissionCompleated("3_08") and not IsMissionCompleated("3_08_PostDummy") then return end local l_23_0 = math.random(1, 2) end function F_UpdateTimeCycle() if not IsMissionCompleated("1_B") then local l_24_0 = GetCurrentDay(false) if l_24_0 < 0 or l_24_0 > 2 then SetCurrentDay(0) end end F_UpdateCurfew() end function F_UpdateCurfew() local l_25_0 = shared.gCurfewRules l_25_0 = l_25_0 or F_CurfewDefaultRules l_25_0() end function F_CurfewDefaultRules() local l_26_0 = ClockGet() if l_26_0 >= 23 or l_26_0 < 7 then shared.gCurfew = true else shared.gCurfew = false end end
Write, Run & Share Lua code online using OneCompiler's Lua online compiler for free. It's one of the robust, feature-rich online compilers for Lua language, running the latest Lua version 5.4. Getting started with the OneCompiler's Lua editor is easy and fast. The editor shows sample boilerplate code when you choose language as Lua and start coding.
OneCompiler's Lua online editor supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample Lua program which takes name as input and prints hello message with your name.
name = io.read("*a")
print ("Hello ", name)
Lua is a light weight embeddable scripting language which is built on top of C. It is used in almost all kind of applications like games, web applications, mobile applications, image processing etc. It's a very powerful, fast, easy to learn, open-source scripting language.
-- global variables
a = 10
-- local variables
local x = 30
Value Type | Description |
---|---|
number | Represents numbers |
string | Represents text |
nil | Differentiates values whether it has data or not |
boolean | Value can be either true or false |
function | Represents a sub-routine |
userdata | Represents arbitary C data |
thread | Represents independent threads of execution. |
table | Can hold any value except nil |
While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.
while(condition)
do
--code
end
Repeat-Until is also used to iterate a set of statements based on a condition. It is very similar to Do-While, it is mostly used when you need to execute the statements atleast once.
repeat
--code
until( condition )
For loop is used to iterate a set of statements based on a condition.
for init,max/min value, increment
do
--code
end
Function is a sub-routine which contains set of statements. Usually functions are written when multiple calls are required to same set of statements which increase re-usuability and modularity.
optional_function_scope function function_name( argument1, argument2, argument3........, argumentn)
--code
return params with comma seperated
end