Update commands.lua

Moved a lot of commands to server side, made them better, and added a /911 call.
This commit is contained in:
Andyyy7666
2022-01-23 23:56:08 +01:00
committed by GitHub
parent e110a4cb7f
commit 71832114c8

View File

@@ -12,12 +12,12 @@ if config.enableAopCommand then
{ name="Area", help="Area of Play" } { name="Area", help="Area of Play" }
}) })
TriggerEvent("chat:addSuggestion", "/" .. config.checkAopCommand, "Check the current Area of Play.", {}) TriggerEvent("chat:addSuggestion", "/" .. config.checkAopCommand, "Check the current Area of Play.", {})
RegisterCommand(config.checkAopCommand, function(source, args, raw) RegisterCommand(config.checkAopCommand, function(source, args, rawCommand)
TriggerServerEvent("getAop") TriggerServerEvent("getAop")
end, false) end, false)
RegisterCommand(config.aopCommand, function(source, args, raw) RegisterCommand(config.aopCommand, function(source, args, rawCommand)
if admin then if admin then
TriggerServerEvent("registerAop", string.gsub(raw, config.aopCommand .. " ", "")) TriggerServerEvent("registerAop", string.sub(rawCommand, string.len(config.aopCommand + 1), string.len(rawCommand)))
else else
TriggerEvent("chat:addMessage", { TriggerEvent("chat:addMessage", {
args = {"~r~You don't have permission to set the aop."} args = {"~r~You don't have permission to set the aop."}
@@ -48,31 +48,22 @@ if config.enableAopCommand then
end) end)
end end
-- Twotter command RegisterNetEvent("911")
RegisterCommand("twt", function(source, args, rawCommand) AddEventHandler("911", function(coords, rawCommand)
TriggerServerEvent("twt", GetPlayerServerId(PlayerId()), mainTwtName, string.gsub(rawCommand, "twt", "")) local location = GetStreetNameFromHashKey(GetStreetNameAtCoord(coords.x, coords.y, coords.z))
end, false)
RegisterNetEvent("twt")
AddEventHandler("twt", function(id, twtName, twt)
TriggerEvent("chat:addMessage", { TriggerEvent("chat:addMessage", {
template = "<img src='data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+Cjxz%0D%0AdmcKICB2aWV3Ym94PSIwIDAgMjAwMCAxNjI1LjM2IgogIHdpZHRoPSI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2IC0xNDAuNDI5LDEx%0D%0AMC4wNjIgLTMxNy4zNTEsMTc1LjY2IC01MDkuNTk3MiwxNzUuNjYgLTMzLjEyMTEsMCAtNjUuNzg1%0D%0AMSwtMS45NDkgLTk3Ljg4MjgsLTUuNzM4IDE4MS41ODYsMTE2LjQxNzYgMzk3LjI3LDE4NC4zNTkg%0D%0ANjI4Ljk4OCwxODQuMzU5IDc1NC43MzIsMCAxMTY3LjQ2MiwtNjI1LjIzOCAxMTY3LjQ2MiwtMTE2%0D%0ANy40NyAwLC0xNy43OSAtMC40MSwtMzUuNDggLTEuMiwtNTMuMDggODAuMTc5OSwtNTcuODYgMTQ5%0D%0ALjczOTksLTEzMC4xMiAyMDQuNzQ5OSwtMjEyLjQxIgogICAgc3R5bGU9ImZpbGw6IzAwYWNlZCIv%0D%0APgo8L3N2Zz4K' height='16'> <b>{0}</b>: {1}", color = {255, 0, 0},
multiline = true, args = {"^*[911] ^3Location: " .. location .. " ^1| Call infomation^0", string.sub(rawCommand, 4, string.len(rawCommand))}
args = {"^4@" .. twtName .. " (#" .. id .. ")", twt}
}) })
end) blip = AddBlipForCoord(coords.x, coords.y, coords.z)
SetBlipSprite(blip, 817)
-- Me command SetBlipAsShortRange(blip, true)
RegisterCommand("me", function(source, args, rawCommand) BeginTextCommandSetBlipName("STRING")
TriggerServerEvent("me", GetPlayerServerId(PlayerId()), mainFirstName .. " " .. mainLastName, string.gsub(rawCommand, "me", ""), GetEntityCoords(PlayerPedId())) SetBlipColour(blip, 1)
end, false) AddTextComponentString("911 CALL: " .. location)
RegisterNetEvent("me") EndTextCommandSetBlipName(blip)
AddEventHandler("me", function(id, name, msg, coords) Citizen.Wait(60 * 1000)
if #(coords - GetEntityCoords(PlayerPedId())) < 19.999 then RemoveBlip(blip)
TriggerEvent("chat:addMessage", {
color = {255, 0, 0},
args = {"^*ME | ^0" .. name .. " (#" .. id .. ")", msg}
})
end
end) end)
-- Change character command -- Change character command