-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathserver.lua
42 lines (36 loc) · 1.47 KB
/
server.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
RegisterNetEvent("wand:HitPlayer", function(player, spell, coords)
local source = source
if not Player(source).state.wanding then
return
end
TriggerClientEvent("Wand:ActivateSpell", player, {id = spell, coords = coords})
end)
RegisterNetEvent("wand:enableParticles", function()
local source = source
Player(source).state:set("wanding", true, true)
TriggerClientEvent("wand:startParticles", -1, source,NetworkGetNetworkIdFromEntity(GetPlayerPed(source)))
end)
RegisterNetEvent("wand:disableParticles", function()
local source = source
Player(source).state:set("wanding", false, true)
TriggerClientEvent("wand:removeParticles", -1, source)
end)
AddEventHandler("playerEnteredScope", function(data)
local playerEntering, player = tonumber(data["player"]), tonumber(data["for"])
if Player(playerEntering).state.wanding then
TriggerClientEvent("wand:startParticles", player, playerEntering, NetworkGetNetworkIdFromEntity(GetPlayerPed(playerEntering)))
end
end)
AddEventHandler("playerLeftScope", function(data)
local playerLeaving, player = tonumber(data["player"]), tonumber(data["for"])
if Player(playerLeaving).state.wanding then
TriggerClientEvent("wand:disableParticles", player, playerLeaving)
end
end)
RegisterNetEvent("wand:PlayerLevitate", function(ply, coords)
local source = source
if not Player(source).state.wanding then
return
end
SetEntityCoords(GetPlayerPed(ply), coords)
end)