Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Author: Azller Lollison (in public this source is missing)
- local sampev = require 'lib.samp.events'
- wh = {
- activate = false,
- players = {}
- }
- local font = renderCreateFont("Arial", 8, 5)
- function main()
- while not isSampAvailable() do wait(0) end
- sampRegisterChatCommand('syncwh', function() wh.activate = not wh.activate; sampAddChatMessage(wh.activate and 'Activate' or 'OFF', -1) end)
- while true do wait(0)
- if wh.activate then
- for i = 1, #wh.players do
- if wh.players[i] then
- if isPointOnScreen(wh.players[i]["coords"].x, wh.players[i]["coords"].y, wh.players[i]["coords"].z, 1) then
- if sampIsPlayerConnected(wh.players[i].id) then
- local wPosX, wPosY = convert3DCoordsToScreen(wh.players[i]["coords"].x + (wh.players[i]["speed"].x * 2), wh.players[i]["coords"].y + (wh.players[i]["speed"].y * 2), wh.players[i]["coords"].z + (wh.players[i]["speed"].z * 2))
- renderFontDrawText(font, sampGetPlayerNickname(wh.players[i].id).."["..wh.players[i].id.."]", wPosX, wPosY + 3, 0xFFFFFFFF, false)
- else
- wh.players[i] = nil
- end
- end
- end
- end
- end
- end
- wait(-1)
- end
- local function registerPlayerIdInSystem(num)
- wh.players[#wh.players + 1] = {id = num,
- ["coords"] = {0, 0, 0},
- ["speed"] = {1, 1, 1}
- }
- end
- local function playerIdRegisteredInSystem(id)
- for i = 1, #wh.players do
- if wh.players[i] then
- if wh.players[i].id == id then return true end
- end
- end
- return false
- end
- function sampev.onPlayerStreamOut(id)
- for i = 1, #wh.players do
- if wh.players[i] then
- if wh.players[i].id == id then wh.players[i] = nil end
- end
- end
- end
- function sampev.onPlayerQuit(id)
- for i = 1, #wh.players do
- if wh.players[i] then
- if wh.players[i].id == id then wh.players[i] = nil end
- end
- end
- end
- function sampev.onVehicleSync(id, vehicleID, data)
- if playerIdRegisteredInSystem(id) then
- for a = 1, #wh.players do
- if wh.players[a] then
- if wh.players[a].id == id then
- wh.players[a]["coords"] = data.position
- wh.players[a]["speed"] = data.moveSpeed
- end
- end
- end
- else
- registerPlayerIdInSystem(id);
- end
- end
- function sampev.onPlayerSync(id, data)
- if playerIdRegisteredInSystem(id) then
- for a = 1, #wh.players do
- if wh.players[a] then
- if wh.players[a].id == id then
- wh.players[a]["coords"] = data.position
- wh.players[a]["speed"] = data.moveSpeed
- end
- end
- end
- else
- registerPlayerIdInSystem(id);
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment