PivityGmodStore

Realistic Events

Here you will learn how to make and edit realistic events.

First navigate to lua/ch_adv_mayor_eco/shared/events/ <-- and find a file named real_event_xx.lua

In this example we will use real_event_warsyria.lua

local syria_war_timer = 100 -- Seconds from when the mayor chooses to send troops and war starts
local syria_money_win_profit = 1000 -- How much money does the mayor earn when he "wins" the war?
local syria_weapons_for_cops = { -- List of weapons they can receive from the event if won.
"weapon_ak472",
"weapon_deagle2",
"weapon_fiveseven2",
"weapon_glock2",
"weapon_m42",
"weapon_mac102",
"weapon_mp52",
"weapon_p2282",
"weapon_pumpshotgun2" -- THE LAST LINE SHOULD NOT HAVE A COMMA AT THE END. BE AWARE OF THIS WHEN EDITING THIS!
}


CH_Mayor.Economy.Events["event_warsyria"] = {
Name = "Conflicts in Syria",
Desc = "As part of the Garry's Union they request your city to deploy military troops in Syria. This could be profitable for your city in the end, but could also mean you would loose men in combat. What do you want to do?",
Choices = {
[1] = {
Name = "Agree and send your troops",
Reward = true,
EcoPoints = 7,
Price = 750,
AnswerText = "Your troops were successfully dispatched to Syria. Now only time will tell if they can successfully win the war and bring home money and artillery.",
EventFunction = function()
-- Notify everyone
DarkRP.notifyAll( 1, 10, "[Mayoral Event] Due to recent actions taken by the mayor, lots of soldiers were sent to Syria. Time will tell how this goes!" )
timer.Simple( syria_war_timer, function()
-- Notify the mayor
local mayor = CH_Mayor.GetMayor()
if IsValid( mayor ) then
DarkRP.notify( mayor, 1, CH_Mayor.Config.NotificationTime, "[Mayoral Event] Your soldiers have defeated Syrian militants and have brought home weapons and money." )
DarkRP.notify( mayor, 1, CH_Mayor.Config.NotificationTime, "[Mayoral Event] Because of this your current government officials have all been equipped with stronger weapons and full body armor." )
end
-- Mayor earns some extra money for wininng
CH_Mayor.AddVaultMoney( syria_money_win_profit )
-- Equip police jobs
for k, ply in ipairs( player.GetAll() ) do
if ply:CH_Mayor_IsGovTeam() then
ply:Give( table.Random( syria_weapons_for_cops ) )
ply:SetArmor( 100 )
end
end
end )
end,
},
[2] = {
Name = "Disagree and send nothing",
Reward = false,
EcoPoints = 4,
AnswerText = "The rest of the worlds presidents are very angry with you for not contributing with soldiers for the war. Your friendship with several cities has been put on hold, and this could mean severe damage to your city.",
EventFunction = function()
-- Notify everyone
DarkRP.notifyAll( 1, CH_Mayor.Config.NotificationTime, "[Mayoral Event] Due to recent actions taken by the mayor, friendship with nearby cities has been cut. This could damage the town!" )


-- Should something happen here?
end,
},
},
}

The EventFunction will execute if the mayor chooses the option that it is connected with. In this event it will be Option 1

It will notify everyone and then start a timer based on the syria_war_timer variable. When the timer executes, it will "conclude" the war on syria and you've technically won it. It will then add syria_money_win_profit variable to your mayor vault money and all gov teams will be given a random weapon from the syria_weapons_for_cops table and 100 armor.

Depending on how good of a coder you are, you can make anything happen with the EventFunction option.

Can't find what you're looking for?

Contact support