Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x, y = guiGetScreenSize()
- skinsTable = { }
- function onClientResourceStart(startedResource)
- if startedResource == getThisResource() then
- triggerServerEvent("getSettings", root)
- setElementData(localPlayer, "alive", false)
- end
- end
- addEventHandler("onClientResourceStart", root, onClientResourceStart)
- function sendSettings(freeCam, camPosX, camPosY, camPosZ, camLookX, camLookY, camLookZ, pedPosX, pedPosY, pedPosZ, pedRot, interior, allSkins, skinID, skins)
- setElementData(localPlayer, "class_freeCam", freeCam)
- setElementData(localPlayer, "class_camPosX", camPosX)
- setElementData(localPlayer, "class_camPosY", camPosY)
- setElementData(localPlayer, "class_camPosZ", camPosZ)
- setElementData(localPlayer, "class_camLookX", camLookX)
- setElementData(localPlayer, "class_camLookY", camLookY)
- setElementData(localPlayer, "class_camLookZ", camLookZ)
- setElementData(localPlayer, "class_pedPosX", pedPosX)
- setElementData(localPlayer, "class_pedPosY", pedPosY)
- setElementData(localPlayer, "class_pedPosZ", pedPosZ)
- setElementData(localPlayer, "class_pedRot", pedRot)
- setElementData(localPlayer, "class_interior", interior)
- setElementData(localPlayer, "class_allSkins", allSkins)
- setElementData(localPlayer, "class_skinID", skinID)
- setElementData(localPlayer, "class_skins", skins)
- skinsTable = skins
- setElementModel(localPlayer, skinsTable[1])
- setElementData(localPlayer, "skinTableID", 1)
- setupPlayerForClassSelection()
- end
- addEvent("sendSettings", true)
- addEventHandler("sendSettings", root, sendSettings, freeCam, camPosX, camPosY, camPosZ, camLookX, camLookY, camLookZ, pedPosX, pedPosY, pedPosZ, pedRot, interior, allSkins, skinID, skins)
- function renderSkinID()
- dxDrawText(getElementModel(localPlayer), x - 898, y - 213, x - 769, y - 144, tocolor(255, 255, 255, 255), 2.0, "bankgothic", "center", "center", false, false, false)
- end
- function bindSetupPlayerForClassSelection()
- if isPedInVehicle(localPlayer) then
- outputChatBox("Nie możesz przejść do wybierałki, ponieważ jesteś w pojeździe!", 255, 102, 102)
- return false
- end
- if getElementData(localPlayer, "alive") == false then
- outputChatBox("Nie możesz przejść do wybierałki, ponieważ jesteś martwy!", 255, 102, 102)
- return false
- end
- unbindKey("F4")
- outputChatBox("Przejście do wybierałki nastąpi za 5 sekund..", 0, 204, 51)
- setTimer(timer_SetupPlayerForClassSelection, 5000, 1)
- end
- function timer_SetupPlayerForClassSelection()
- if isPedInVehicle(localPlayer) then
- outputChatBox("Nie możesz przejść do wybierałki gdy jesteś w pojeździe!")
- bindKey("F4", "down", bindSetupPlayerForClassSelection)
- return false
- end
- if getElementData(localPlayer, "alive") == false then
- bindKey("F4", "down", bindSetupPlayerForClassSelection)
- return false
- end
- setupPlayerForClassSelection()
- end
- function setupPlayerForClassSelection()
- if getElementData(localPlayer, "class_skinID") == 1 then
- addEventHandler("onClientRender", root, renderSkinID)
- end
- toggleAllControls(false, true, false)
- setPedAnimation(localPlayer)
- setElementData(localPlayer, "classSelection", true)
- showPlayerHudComponent("radar", false)
- currentSkinID = table.find(skinsTable, getElementModel(localPlayer))
- if currentSkinID == nil then currentSkinID = 1 end
- setElementModel(localPlayer, skinsTable[currentSkinID])
- setElementData(localPlayer, "skinTableID", currentSkinID)
- setElementInterior(localPlayer, getElementData(localPlayer, "class_interior"))
- setElementDimension(localPlayer, getElementID(localPlayer))
- if getElementData(localPlayer, "class_freeCam") == 0 then
- setCameraMatrix(getElementData(localPlayer, "class_camPosX"), getElementData(localPlayer, "class_camPosY"), getElementData(localPlayer, "class_camPosZ"), getElementData(localPlayer, "class_camLookX"), getElementData(localPlayer, "class_camLookY"), getElementData(localPlayer, "class_camLookZ"))
- end
- setElementPosition(localPlayer, getElementData(localPlayer, "class_pedPosX"), getElementData(localPlayer, "class_pedPosY"), getElementData(localPlayer, "class_pedPosZ"))
- setPedRotation(localPlayer, getElementData(localPlayer, "class_pedRot"))
- unbindKey("F4")
- bindKey("lshift", "down", stopPlayerClassSelection)
- bindKey("rshift", "down", stopPlayerClassSelection)
- bindKey("arrow_l", "down", classSelectionChangeSkin, "left")
- bindKey("arrow_r", "down", classSelectionChangeSkin, "right")
- bindKey("mouse1", "down", classSelectionChangeSkin, "right")
- bindKey("mouse2", "down", classSelectionChangeSkin, "left")
- triggerEvent("onEnterClassSelection", root)
- end
- function classSelectionChangeSkin(key, state, direction)
- local oldSkin = getElementModel(localPlayer)
- if direction == "right" then
- tableID = getElementData(localPlayer, "skinTableID") + 1
- if tableID == table.getn(skinsTable) + 1 then tableID = 1 end
- else
- tableID = getElementData(localPlayer, "skinTableID") - 1
- if tableID == 0 then tableID = table.getn(skinsTable) end
- end
- setElementData(localPlayer, "skinTableID", tableID)
- setElementModel(localPlayer, skinsTable[tableID])
- playSoundFrontEnd(2)
- triggerEvent("onClassSelectionSkinChange", root, oldSkin, skinsTable[tableID])
- end
- function stopPlayerClassSelection()
- if getElementData(localPlayer, "class_skinID") == 1 then
- removeEventHandler("onClientRender", root, renderSkinID)
- end
- setElementData(localPlayer, "classSelection", false)
- unbindKey("lshift")
- unbindKey("rshift")
- unbindKey("arrow_l")
- unbindKey("arrow_r")
- unbindKey("mouse1")
- unbindKey("mouse2")
- bindKey("F4", "down", bindSetupPlayerForClassSelection)
- toggleAllControls(true)
- showPlayerHudComponent("radar", true)
- setElementDimension(localPlayer, 0)
- triggerServerEvent("stopPlayerClassSelection", root, getElementModel(localPlayer))
- triggerEvent("onLeaveClassSelection", root)
- end
- function onClientPlayerSpawn()
- setElementData(localPlayer, "alive", true)
- end
- addEventHandler("onClientPlayerSpawn", localPlayer, onClientPlayerSpawn)
- function onClientPlayerWasted()
- setElementData(localPlayer, "alive", false)
- end
- addEventHandler("onClientPlayerWasted", localPlayer, onClientPlayerWasted)
- function isPlayerInClassSelection()
- return getElementData(localPlayer, "classSelection")
- end
- function table.find(t, v)
- for i, l in ipairs(t) do
- if l == v then
- return i
- end
- end
- return nil
- end
Advertisement
Add Comment
Please, Sign In to add comment