Skip to content

Commit

Permalink
Changed (clarified) command names
Browse files Browse the repository at this point in the history
  • Loading branch information
gimicze committed May 6, 2021
1 parent a20898f commit 66c3aa1
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 34 deletions.
64 changes: 49 additions & 15 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ TriggerEvent('chat:addSuggestion', '/stopfire', 'Stops the fire', {

TriggerEvent('chat:addSuggestion', '/stopallfires', 'Stops all fires')

TriggerEvent('chat:addSuggestion', '/registerfire', 'Registers a new fire configuration')
TriggerEvent('chat:addSuggestion', '/registerscenario', 'Registers a new fire configuration')

TriggerEvent('chat:addSuggestion', '/addflame', 'Adds a flame to a registered fire', {
TriggerEvent('chat:addSuggestion', '/addflame', 'Adds a flame to a scenario', {
{
name = "fireID",
help = "The registered fire"
name = "scenarioID",
help = "The scenario"
},
{
name = "spread",
Expand All @@ -53,9 +53,9 @@ TriggerEvent('chat:addSuggestion', '/addflame', 'Adds a flame to a registered fi
}
})

TriggerEvent('chat:addSuggestion', '/removeflame', 'Removes a flame from a registered fire', {
TriggerEvent('chat:addSuggestion', '/removeflame', 'Removes a flame from a scenario', {
{
name = "fireID",
name = "scenarioID",
help = "The fire ID"
},
{
Expand All @@ -64,16 +64,16 @@ TriggerEvent('chat:addSuggestion', '/removeflame', 'Removes a flame from a regis
}
})

TriggerEvent('chat:addSuggestion', '/removefire', 'Removes a registered fire', {
TriggerEvent('chat:addSuggestion', '/removescenario', 'Removes a scenario', {
{
name = "fireID",
name = "scenarioID",
help = "The fire ID"
}
})

TriggerEvent('chat:addSuggestion', '/startregisteredfire', 'Starts a registered fire', {
TriggerEvent('chat:addSuggestion', '/startscenario', 'Starts a scenario', {
{
name = "fireID",
name = "scenarioID",
help = "The fire ID"
},
{
Expand All @@ -82,9 +82,9 @@ TriggerEvent('chat:addSuggestion', '/startregisteredfire', 'Starts a registered
}
})

TriggerEvent('chat:addSuggestion', '/stopregisteredfire', 'Stops a registered fire', {
TriggerEvent('chat:addSuggestion', '/stopscenario', 'Stops a scenario', {
{
name = "fireID",
name = "scenarioID",
help = "The fire ID"
}
})
Expand Down Expand Up @@ -134,7 +134,7 @@ TriggerEvent('chat:addSuggestion', '/randomfires', 'Manages the random fire spaw
},
{
name = "p2",
help = "(optional) For add / remove action, fill in the registered fire ID."
help = "(optional) For add / remove action, fill in the scenario ID."
}
})

Expand Down Expand Up @@ -206,9 +206,9 @@ RegisterCommand(
)

RegisterCommand(
'registerfire',
'registerscenario',
function(source, args, rawCommand)
TriggerServerEvent('fireManager:command:registerfire', GetEntityCoords(GetPlayerPed(-1)))
TriggerServerEvent('fireManager:command:registerscenario', GetEntityCoords(GetPlayerPed(-1)))
end,
false
)
Expand All @@ -227,6 +227,40 @@ RegisterCommand(
false
)

-- Aliases

RegisterCommand(
'registerfire',
function(source, args, rawCommand)
ExecuteCommand("registerscenario" .. rawCommand:sub(13))
end,
false
)

RegisterCommand(
'removeregisteredfire',
function(source, args, rawCommand)
ExecuteCommand("removescenario" .. rawCommand:sub(21))
end,
false
)

RegisterCommand(
'startregisteredfire',
function(source, args, rawCommand)
ExecuteCommand("startscenario" .. rawCommand:sub(20))
end,
false
)

RegisterCommand(
'stopregisteredfire',
function(source, args, rawCommand)
ExecuteCommand("stopscenario" .. rawCommand:sub(19))
end,
false
)

--================================--
-- EVENTS --
--================================--
Expand Down
40 changes: 21 additions & 19 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ AddEventHandler(

local fireIndex = Fire:create(coords, maxSpread, chance)

sendMessage(source, "Created fire #" .. fireIndex)
sendMessage(source, "Spawned fire #" .. fireIndex)

if triggerDispatch then
Citizen.SetTimeout(
Expand All @@ -88,9 +88,9 @@ AddEventHandler(
end
)

RegisterNetEvent('fireManager:command:registerfire')
RegisterNetEvent('fireManager:command:registerscenario')
AddEventHandler(
'fireManager:command:registerfire',
'fireManager:command:registerscenario',
function(coords)
if not Whitelist:isWhitelisted(source, "firescript.manage") then
sendMessage(source, "Insufficient permissions.")
Expand All @@ -99,7 +99,7 @@ AddEventHandler(

local registeredFireID = Fire:register(coords)

sendMessage(source, "Registered fire #" .. registeredFireID)
sendMessage(source, "Created scenario #" .. registeredFireID)
end
)

Expand All @@ -123,11 +123,11 @@ AddEventHandler(
local flameID = Fire:addFlame(registeredFireID, coords, spread, chance)

if not flameID then
sendMessage(source, "No such fire registered.")
sendMessage(source, "No such scenario.")
return
end

sendMessage(source, "Registered flame #" .. flameID)
sendMessage(source, "Added flame #" .. flameID)
end
)

Expand Down Expand Up @@ -209,7 +209,7 @@ RegisterCommand(
)

RegisterCommand(
'removefire',
'removescenario',
function(source, args, rawCommand)
if not Whitelist:isWhitelisted(source, "firescript.manage") then
sendMessage(source, "Insufficient permissions.")
Expand All @@ -223,17 +223,17 @@ RegisterCommand(
local success = Fire:deleteRegistered(registeredFireID)

if not success then
sendMessage(source, "No such fire or flame registered.")
sendMessage(source, "No such scenario.")
return
end

sendMessage(source, "Removed fire #" .. registeredFireID)
sendMessage(source, "Removed scenario #" .. registeredFireID)
end,
false
)

RegisterCommand(
'startregisteredfire',
'startscenario',
function(source, args, rawCommand)
if not Whitelist:isWhitelisted(source, "firescript.start") then
sendMessage(source, "Insufficient permissions.")
Expand All @@ -250,17 +250,17 @@ RegisterCommand(
local success = Fire:startRegistered(registeredFireID, triggerDispatch, source)

if not success then
sendMessage(source, "No such fire or flame registered.")
sendMessage(source, "No such scenario.")
return
end

sendMessage(source, "Started registered fire #" .. registeredFireID)
sendMessage(source, "Started scenario #" .. registeredFireID)
end,
false
)

RegisterCommand(
'stopregisteredfire',
'stopscenario',
function(source, args, rawCommand)
if not Whitelist:isWhitelisted(source, "firescript.stop") then
sendMessage(source, "Insufficient permissions.")
Expand All @@ -276,11 +276,11 @@ RegisterCommand(
local success = Fire:stopRegistered(registeredFireID)

if not success then
sendMessage(source, "No such fire active.")
sendMessage(source, "No such scenario active.")
return
end

sendMessage(source, "Stopping registered fire #" .. registeredFireID)
sendMessage(source, "Stopping scenario #" .. registeredFireID)

TriggerClientEvent("pNotify:SendNotification", source, {
text = "Fire going out...",
Expand Down Expand Up @@ -395,14 +395,14 @@ RegisterCommand(
return
end
Fire:setRandom(registeredFireID, true)
sendMessage(source, ("Set registered fire #%s to spawn randomly."):format(registeredFireID))
sendMessage(source, ("Set scenario #%s to start randomly."):format(registeredFireID))
elseif action == "remove" then
if not registeredFireID then
sendMessage(source, "Invalid argument (2).")
return
end
Fire:setRandom(registeredFireID, false)
sendMessage(source, ("Set registered fire #%s not to spawn randomly."):format(registeredFireID))
sendMessage(source, ("Set scenario #%s not to start randomly."):format(registeredFireID))
elseif action == "disable" then
Fire:stopSpawner()
sendMessage(source, "Disabled random fire spawn.")
Expand Down Expand Up @@ -506,9 +506,11 @@ RegisterNetEvent('fireDispatch:create')
AddEventHandler(
'fireDispatch:create',
function(text, coords)
if not Config.Dispatch.disableCalls and Dispatch.expectingInfo[source] then
if not Config.Dispatch.disableCalls and (source < 1 or Dispatch.expectingInfo[source]) then
Dispatch:create(text, coords)
Dispatch.expectingInfo[source] = nil
if source > 0 then
Dispatch.expectingInfo[source] = nil
end
end
end
)
Expand Down

0 comments on commit 66c3aa1

Please sign in to comment.