Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local sa = require "lib.samp.events"
- local state = true
- local friends = {}
- function main()
- if not isSampfuncsLoaded() or not isSampLoaded() then return end
- while not isSampAvailable() do wait(100) end
- sampRegisterChatCommand("setcolor", setid)
- sampRegisterChatCommand("set", function()
- state = not state
- sampAddChatMessage(state and "ON" or "off", -1)
- end)
- end
- function setcolor(id)
- local bs = raknetNewBitStream()
- raknetBitStreamWriteInt16(bs, id) -- ID - РёРґ РёРіСЂРѕРєР°
- raknetBitStreamWriteInt32(bs, -16738047) -- color - цвет
- raknetEmulRpcReceiveBitStream(72,bs)
- raknetDeleteBitStream(bs)
- sampAddChatMessage("Цвет игрока с ID "..id.." изменён!", -1)
- end
- function setid(arg)
- if state then
- if #arg > 0 then -- Если указан аргумент у команды
- if arg:find("[^%d]+") then -- Если указаны не только цифры
- _, myid = sampGetPlayerIdByCharHandle(PLAYER_PED)
- if sampGetPlayerNickname(myid) == arg then
- sampAddChatMessage("Ты указал свой Nick_Name!", -1)
- else
- maxId = sampGetMaxPlayerId()
- for i = 0, maxId do
- if sampIsPlayerConnected(i) and sampGetPlayerNickname(i) == arg then
- friends[sampGetPlayerNickname(i)] = true
- setcolor(i)
- return true
- end
- end
- sampAddChatMessage("Игрока с таким ником нет в игре!", -1)
- end
- else
- id = tonumber(arg)
- _, myid = sampGetPlayerIdByCharHandle(PLAYER_PED)
- if myid == id then
- sampAddChatMessage("Ты указал свой ID!", -1)
- elseif sampIsPlayerConnected(id) then
- friends[sampGetPlayerNickname(id)] = true
- setcolor(id)
- else
- sampAddChatMessage("Игрока с ID " .. arg .. " нет в игре", -1)
- end
- end
- else
- sampAddChatMessage("Не указан ник/id. Пример: /setcolor [id/Nick_Name]", -1)
- end
- end
- end
- function sa.onSetPlayerColor(id, color)
- if friends[sampGetPlayerNickname(id)] then
- return false
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement