-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostalCode-c.lua
67 lines (58 loc) · 1.86 KB
/
postalCode-c.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
RegisterCommand("postcode", function(source, args, raw)
if args[1] ~= nil then
local postalCode = args[1]
setWaypoint(postalCode)
else
notify(Config.Prefix.. " ~r~Error: Unknown target!")
end
end, false)
RegisterCommand("gps", function(source, args, raw)
if args[1] ~= nil then
local postalCode = args[1]
setWaypoint(postalCode)
else
notify(Config.Prefix.. "~r~Error: Unknown target!")
end
end, false)
RegisterCommand("markpostal", function(source, args, raw)
if args[1] ~= nil then
local postalCode = args[1]
setWaypoint(postalCode)
else
notify(Config.Prefix.. "~r~Error: Unknown target!")
end
end, false)
function notify(msg)
SetNotificationTextEntry("STRING")
AddTextComponentString(msg)
DrawNotification(true, false)
end
function setWaypoint(postalCode)
local postalCode_coords = vector2(0,0)
for i = 1, #Config.postalcodes, 1 do
if Config.postalcodes[i].code == postalCode then
postalCode_coords = vector2(Config.postalcodes[i].x, Config.postalcodes[i].y)
end
end
if postalCode_coords.x ~= 0.0 and postalCode_coords.y ~= 0.0then
SetNewWaypoint(postalCode_coords.x, postalCode_coords.y)
notify(Config.Prefix.. "Marker was set ~g~successfully~s~. ~y~Postcode~s~: ~y~" ..postalCode)
else
notify(Config.Prefix.. "~r~Error: Unknown target!")
end
end
Citizen.CreateThread(function()
TriggerEvent('chat:addSuggestion', '/postcode', 'set marker at target position', {
{ name="postal code", help="postal code of target (EX: 627, LSC)" }
})
end)
Citizen.CreateThread(function()
TriggerEvent('chat:addSuggestion', '/gps', 'set marker at target position', {
{ name="postal code", help="postal code of target (EX: 627, LSC)" }
})
end)
Citizen.CreateThread(function()
TriggerEvent('chat:addSuggestion', '/markpostal', 'set marker at target position', {
{ name="postal code", help="postal code of target (EX: 627, LSC)" }
})
end)