Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Start by logging in and typing .test
- See console for ping pong messages between global state and map the player was on
- ]]
- local mapid, instanceid = -1, -1
- if(GetMap()) then
- mapid, instanceid = GetMap():GetMapId(), GetMap():GetInstanceId()
- end
- local function SendMsg(m, i, msg)
- print(mapid.." "..instanceid.." Sending "..tostring(msg).." to "..m.." "..i)
- SendStateMsg(m, i, mapid, instanceid, msg)
- end
- local function OnPing(event, m, i, msg)
- print(mapid.." "..instanceid.." Received "..tostring(msg).." from "..m.." "..i)
- --Send delayed ping or pong depending on which was received
- CreateLuaEvent(function() SendMsg(m, i, msg == "PING" and "PONG" or "PING") end, 5000, 1)
- end
- if(GetMap()) then
- RegisterServerEvent(31, OnPing)
- else
- RegisterServerEvent(31, OnPing)
- local function OnCommand(event, player, command)
- if(command ~= "test") then
- return
- end
- SendMsg(player:GetMapId(), player:GetInstanceId(), "PING")
- return false
- end
- RegisterPlayerEvent(42, OnCommand) -- on command
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement