Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local cash, soBlip, so, isRunning
- function startSoChase(plr, cmd, money)
- local acc = getAccountName(getPlayerAccount(plr))
- local accessSO = exports.CITstateOfficial:checkSOPermission(acc)
- if (not accessSO) then --Use this as it's ready for all SO checks. Even you can see who'se HSO, AHSO and SO.
- return false
- end
- if (money == "stop") then
- if (not isRunning and (so ~= plr and accessSO:upper() == "SO")) then
- return false
- end
- stopEvent()
- return true
- end
- if (isRunning) then
- outputChatBox("An event is already running you dumbfuck!", plr, 255, 0, 0)
- return false
- end
- if (not getPedOccupiedVehicle(plr)) then
- outputChatBox("You need to be inside a vehicle to start the SO chase event you idiot", plr, 255, 0, 0)
- return false
- end
- local money = tonumber(money)
- if (not money or money < 10000 or money > 100000) then
- outputChatBox("SYNTAX: /sochase <money>/<stop>, the amount of money must be more than $10,000 and lower than $100,000.", plr, 255, 0, 0)
- return false
- end
- isRunning = true
- cash = money
- local vehicle = getPedOccupiedVehicle(plr)
- soBlip = createBlipAttachedTo(vehicle, 41, 2, 255, 255, 255, 255, 0, 16383.0, resourceRoot)
- so = plr
- local x, y, z = getElementPosition(plr)
- for k, v in ipairs(getPlayersInTeam(getTeamFromName("Civilian Workers"))) do
- outputChatBox("State Official " ..getPlayerName(plr).. " is hosting SO chase event! Try to hit his " ..getVehicleNameFromModel(getElementModel(vehicle)).. " and win $" ..money.. ", his location is " ..getZoneName(x, y, z), v, 255, 167, 0)
- setElementVisibleTo(soBlip, v, true)
- end
- --exports.CITmoney:TPM(plr, cash, "CIT.SOChaseEvent") -- Auto-Refund.
- removeEventHandler("onPlayerQuit", so, stopEvent)
- removeEventHandler("onPlayerVehicleExit", so, stopEvent)
- removeEventHandler("onPlayerWasted", so, stopEvent)
- removeEventHandler("onPlayerLogin", root, loginPlr)
- addEventHandler("onPlayerQuit", so, stopEvent)
- addEventHandler("onPlayerVehicleExit", so, stopEvent)
- addEventHandler("onPlayerWasted", so, stopEvent)
- addEventHandler("onPlayerLogin", root, loginPlr)
- triggerClientEvent(resourceRoot, "CIT.StartSoChaseEvent", resourceRoot, so, vehicle)
- end
- addCommandHandler("sochase", startSoChase)
- function chaseRewards(plr)
- if (not isRunning) then
- return false
- end
- if (plr and isElement(plr) and getElementType(plr) == "player") then
- for i, v in pairs(getPlayersInTeam(getTeamFromName("Civilian Workers"))) do
- outputChatBox(""..getPlayerName(plr).." won the SO chase event!", v, 255, 167, 0)
- end
- exports.CITmoney:GPM(plr, cash, "CIT.SOChaseEventWinner")
- end
- if (soBlip or isElement(soBlip)) then
- destroyElement(soBlip)
- soBlip = nil
- end
- cash = nil
- isRunning = false
- end
- addEvent("CIT.SOChaseWinner", true)
- addEventHandler("CIT.SOChaseWinner", resourceRoot, chaseRewards)
- function stopEvent()
- for i, v in pairs(getPlayersInTeam(getTeamFromName("Civilian Workers"))) do
- outputChatBox("The SO chase event has been canceled!", v, 20, 255, 20)
- end
- isRunning = false
- cash = nil
- if (soBlip or isElement(soBlip)) then
- destroyElement(soBlip)
- soBlip = nil
- end
- removeEventHandler("onPlayerQuit", so, stopEvent)
- removeEventHandler("onPlayerVehicleExit", so, stopEvent)
- removeEventHandler("onPlayerWasted", so, stopEvent)
- removeEventHandler("onPlayerLogin", root, loginPlr)
- so = nil
- end
- function plrTeamChanged(newTeam)
- if (not isRunning) then
- return false
- end
- if (source == so) then
- stopEvent()
- return true
- end
- if (getTeamName(newTeam) == "Civilian Workers") then
- local x, y, z = getElementPosition(so)
- outputChatBox("State Official " ..getPlayerName(so).. " is hosting SO chase event! Try to hit his " ..getVehicleNameFromModel(getElementModel(getPedOccupiedVehicle(so))).. " and win $" ..money.. ", his location is " ..getZoneName(x, y, z), source, 255, 167, 0)
- setElementVisibleTo(soBlip, source, true)
- end
- if (soBlip and isElementVisibleTo(soBlip, source)) then
- setElementVisibleTo(soBlip, source, false)
- end
- end
- addEventHandler("onPlayerChangeTeam", root, plrTeamChanged)
- function loginPlr()
- local plrTeam = getPlayerTeam(source)
- if (getTeamName(plrTeam) == "Civilian Workers") then
- local x, y, z = getElementPosition(so)
- outputChatBox("State Official " ..getPlayerName(so).. " is hosting SO chase event! Try to hit his " ..getVehicleNameFromModel(getElementModel(getPedOccupiedVehicle(so))).. " and win $" ..money.. ", his location is " ..getZoneName(x, y, z), source, 255, 167, 0)
- setElementVisibleTo(soBlip, source, true)
- end
- end
Add Comment
Please, Sign In to add comment