RedDead Posted July 28, 2012 Share Posted July 28, 2012 i'v downloaded a class chooser and i dont want the player,spawn where he putted in the script i want to make my own players , spawn point client.lua x, y = guiGetScreenSize() x2 = 2511.3748 * x y2 = y - -1668.2717 * y x3 = 13.5635* x y3 = y - 91.8790 * y 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), x2, y2, x3, y3, tocolor(255, 255, 255, 255), 2.0, "bankgothic", "center", "center", false, false, false) end function bindSetupPlayerForClassSelection() if isPedInVehicle(localPlayer) then outputChatBox("You can't return to class selection because you are in vehicle!", 255, 102, 102) return false end if getElementData(localPlayer, "alive") == false then outputChatBox("You can't return to class selection because you are in vehicle!", 255, 102, 102) return false end unbindKey("F4") outputChatBox("Returning to class selection in 5 seconds..", 0, 204, 51) setTimer(timer_SetupPlayerForClassSelection, 5000, 1) end function timer_SetupPlayerForClassSelection() if isPedInVehicle(localPlayer) then outputChatBox("You can't return to class selection because you are in vehicle!", 255, 102, 102) 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("all", false) currentSkin = getElementModel(localPlayer) currentSkinID = table.find(skinsTable, currentSkin) 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, currentSkin) triggerServerEvent("setupPlayerForClassSelection", root, currentSkin) 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("all", true) setElementDimension(localPlayer, 0) local skin = getElementModel(localPlayer) triggerEvent("onLeaveClassSelection", root, skin) triggerServerEvent("stopPlayerClassSelection", root, skin) 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 xml : -- VER: 1.7.1a-EN --> "lopezloo" type="script" name="Class Selection" description="Classic Class Selection" version="1.7.1" /> server.lua resourceName = getResourceName(getThisResource()) spawnSettings = { } function stopPlayerClassSelection(skin) triggerEvent("onLeaveClassSelection", client, skin) if spawnSettings[1] == 0 then spawnPlayer(client, spawnSettings[2], spawnSettings[3], spawnSettings[4], spawnSettings[5], skin, spawnSettings[6], spawnSettings[7]) setCameraTarget(client) end end addEvent("stopPlayerClassSelection", true) addEventHandler("stopPlayerClassSelection", root, stopPlayerClassSelection, skin) function setupPlayerForClassSelection(currentSkin) triggerEvent("onEnterClassSelection", client, currentSkin) end addEvent("setupPlayerForClassSelection", true) addEventHandler("setupPlayerForClassSelection", root, setupPlayerForClassSelection, currentSkin) function getSettings() local freeCam = get(resourceName .. ".freeCam") local camPosX = get(resourceName .. ".cameraPosX") local camPosY = get(resourceName .. ".cameraPosY") local camPosZ = get(resourceName .. ".cameraPosZ") local camLookX = get(resourceName .. ".cameraLookX") local camLookY = get(resourceName .. ".cameraLookY") local camLookZ = get(resourceName .. ".cameraLookZ") local pedPosX = get(resourceName .. ".pedPosX") local pedPosY = get(resourceName .. ".pedPosY") local pedPosZ = get(resourceName .. ".pedPosZ") local pedRot = get(resourceName .. ".pedRot") local interior = get(resourceName .. ".interior") table.insert(spawnSettings, get(resourceName .. ".customSpawn")) table.insert(spawnSettings, get(resourceName .. ".spawnPosX")) table.insert(spawnSettings, get(resourceName .. ".spawnPosY")) table.insert(spawnSettings, get(resourceName .. ".spawnPosZ")) table.insert(spawnSettings, get(resourceName .. ".spawnRot")) table.insert(spawnSettings, get(resourceName .. ".spawnInterior")) table.insert(spawnSettings, get(resourceName .. ".spawnDimension")) local skinID = get(resourceName .. ".skinID") local allSkins = get(resourceName .. ".allSkins") skinsEx = { } if allSkins == 1 then skinsEx = getValidPedModels() else skins = get(resourceName .. ".skins") for i, skin in pairs(skins) do if isValidSkin(skin) then table.insert(skinsEx, skin) end end end triggerClientEvent("sendSettings", client, freeCam, camPosX, camPosY, camPosZ, camLookX, camLookY, camLookZ, pedPosX, pedPosY, pedPosZ, pedRot, interior, allSkins, skinID, skinsEx) end addEvent("getSettings", true) addEventHandler("getSettings", root, getSettings) function isValidSkin(specifiedSkin) -- function from Multi Theft Auto Wiki ^^ if (specifiedSkin) then local allSkins = getValidPedModels() local result = false for key, skin in ipairs(allSkins) do if skin == tonumber(specifiedSkin) then result = skin break end end if (result) then return true else return false end else return false end end Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now