Citrus Posted April 9, 2017 Share Posted April 9, 2017 Buenas!, este script está muy bueno, basicamente lo que hace es darte la posibilidad de seleccionar tu personaje con unos blink para moverte y a su vez decidír el sexo del mismo. El problema deviene cuando has seleccionado a tu personaje? este al iniciar se quita el skin que te pusiste y automaticamente se pone el skin inicial, no sé si me doy a entender?. Lo que quiero es saber como hago para qu el skin pretederminado de mi server Day-Z no reemplaze el de panel menú selección, aquí el script!: femaleSkins = {179, 93} maleSkins = {73, 287} --------**-------- -------//\\------- ------// \\------ -----// \\----- ----// \\---- ---// \\--- --// \\-- --\\ Settings //-- local defaultSex = "male" -- Set the default sex (Can be "male" or "female") -- Please note that any of the timers below are in milliseconds (ms) local skinCamTimer = 100 -- Timer to switch the camera to the selected skin (Change to a higher value if the camera doesn't switch to the Ped Selection Screen) local playerCamTimer = 100 -- Timer to switch the camera back to the player (Change to a higher value if the camera doesn't switch back to the player) local setSkinTimer = 50 -- Timer to override any skin change done by other scripts (Change to a higher value if the player's skin doesn't change) -- Scroll settings local autoScrollStart = 200 -- Set the time it takes in ms to enable auto scroll when holding down your arrow keys (cannot be lower than 50) local autoScrollSpeed = 80 -- Set the time it takes in ms to switch between skins when holding down your arrow keys (cannot be lower than 50) --// \\-- --\\ //-- ---\\ //--- ----\\ //---- -----\\ //----- ------\\ //------ -------\\//------- --------**-------- local sWidth,sHeight = guiGetScreenSize() local origWidth,origHeight = 1280,960 local isScreenVisible = false local skinRequested = false function text(text, x, y, w, h, color, scale, font, alignX, alignY, clip, wordBreak, postGUI) dxDrawText(text, x/origWidth*sWidth+1.5, y/origHeight*sHeight+1.5, w/origWidth*sWidth+1.5, h/origHeight*sHeight+1.5, tocolor(0,0,0,255), scale/origWidth*sWidth, font, alignX, alignY, clip, wordBreak, postGUI) dxDrawText(text, x/origWidth*sWidth, y/origHeight*sHeight, w/origWidth*sWidth, h/origHeight*sHeight, color, scale/origWidth*sWidth, font, alignX, alignY, clip, wordBreak, postGUI) end function image(x, y, w, h, image, rotation, rotationCenterOffsetX, rotationCenterOffsetY, color, postGUI) dxDrawImage(x/origWidth*sWidth, y/origHeight*sHeight, w/origWidth*sWidth, h/origHeight*sHeight, image, rotation, rotationCenterOffsetX, rotationCenterOffsetY, color, postGUI) end function mainScreen() dxDrawImage(0,0,sWidth,sHeight,"img/bg.png",0,0,0,tocolor(255,255,255,255),true) text("Selecciona a tu superviviente:", 74, 35, 610, 136, tocolor(0, 155, 255, 255), 5.00, "default", "left", "top", false, false, true, false, false) text("Soldado-Z: "..selectedSkin.."/"..totalSkins, 290, 198, 440, 249, tocolor(0, 155, 255, 255), 2.50, "default", "left", "top", false, false, true, false, false) text("Use el ratón o las flechas de tu teclado para seleccionar. Presiona [Enter] cuando hallas decidido.", 322, 837, 1042, 875, tocolor(255, 255, 255, 255), 2.00, "default", "center", "center", false, false, true, false, false) image(473, 419, 96, 140, "img/arrow.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) image(767.75, 419, 96, 140, "img/arrow.png", 180, 0, 0, tocolor(255, 255, 255, 255), true) image(45, 207, 130, 131, "img/male.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) image(55, 380, 130, 131, "img/female.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) end function prevArrowBlink() image(473, 419, 96, 140, "img/arrow-blink.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) end function nextArrowBlink() image(767.75, 419, 96, 140, "img/arrow-blink.png", 180, 0, 0, tocolor(255, 255, 255, 255), true) end function maleActivated() image(45, 207, 130, 131, "img/male-active.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) end function femaleActivated() image(55, 380, 130, 131, "img/female-active.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) end local prevButtonClickable = guiCreateStaticImage(0.36, 0.44, 0.08, 0.15, "img/transparent.png", true) local nextButtonClickable = guiCreateStaticImage(0.62, 0.44, 0.07, 0.15, "img/transparent.png", true) local maleButtonClickable = guiCreateStaticImage(0.06, 0.21, 0.10, 0.14, "img/transparent.png", true) local femaleButtonClickable = guiCreateStaticImage(0.06, 0.40, 0.07, 0.14, "img/transparent.png", true) function showClickables(isScreenVisible) guiSetVisible(prevButtonClickable,isScreenVisible) guiSetVisible(nextButtonClickable,isScreenVisible) guiSetVisible(maleButtonClickable,isScreenVisible) guiSetVisible(femaleButtonClickable,isScreenVisible) end showClickables(isScreenVisible) function toggleScreen() if isScreenVisible then closeScreen() else addEventHandler("onClientRender",root,mainScreen) if defaultSex == "male" then addEventHandler("onClientRender",root,maleActivated) elseif defaultSex == "female" then addEventHandler("onClientRender",root,femaleActivated) end isScreenVisible = true showClickables(isScreenVisible) showCursor(true) setTimer(function()showChat(false)end,200,1) setPlayerHudComponentVisible("all",false) bindKey("enter","down",changePlayerSkin) end end function closeScreen() skinRequested = false firstTime = false setTimer(function()setCameraTarget(localPlayer)end,playerCamTimer,1) triggerServerEvent("setElemDimen",localPlayer,localPlayer,0) removeEventHandler("onClientRender",root,mainScreen) removeEventHandler("onClientRender",root,femaleActivated) removeEventHandler("onClientRender",root,maleActivated) isScreenVisible = false showClickables(isScreenVisible) showCursor(false) setTimer(function()showChat(true)end,200,1) setPlayerHudComponentVisible("all",true) unbindKey("enter","down",changePlayerSkin) end function onSpawn(firstTime) if skinRequested == true or firstTime == true then toggleScreen() triggerServerEvent("setElemDimen",localPlayer,localPlayer,2) triggerServerEvent("setElemFrozen",localPlayer,localPlayer,true) setTimer(function()setCameraMatrix(-4949.8793945313, 1934.9215087891, 1.1398046016693)end,skinCamTimer,1) elseif firstTime == true then addEventHandler("onClientPlayerSpawn",localPlayer,onSpawn) end firstTime = false end addEvent("onJoin",true) addEventHandler("onJoin",root,onSpawn) function requestSkinChange() if skinRequested == false then skinRequested = true addEventHandler("onClientPlayerSpawn",localPlayer,onSpawn) if not firstTime == true then outputChatBox("¡Podrá seleccionar otro skin después del siguiente spanw!.",0,225,75,true) end end end bindKey("F4","down",requestSkinChange) function changePlayerSkin() toggleScreen() setPlayerTheirSkin() skinChosen = true triggerServerEvent("setElemFrozen",localPlayer,localPlayer,false) removeEventHandler("onClientPlayerSpawn",localPlayer,onSpawn) end function setChosenSkinOnSpawn() if skinChosen == true then setTimer(function()setPlayerTheirSkin()end,50,1) end end addEventHandler("onClientPlayerSpawn",localPlayer,setChosenSkinOnSpawn) local ped = createPed(-4952.5239257813, 1940.0152587891, 1.1328125) setElementDimension(ped,2) local tune = playSFX3D("radio","Ambience",-4949.8793945313, 1934.9215087891, 1.1398046016693,true) setSoundVolume(tune,1) setSoundMaxDistance(tune,50) setElementDimension(tune,2) function getSelectedSkinID() local ID = skinTable[selectedSkin] return ID end function setMenuPedSkin() local ID = getSelectedSkinID() setElementModel(ped,ID) end function changeSex(sex) if source == maleButtonClickable or sex == "male" then defaultSex = "male" setPedAnimation(ped,"GANGS","Invite_Yes",_,_,false,false,_) skinTable = maleSkins totalSkins = #skinTable selectedSkin = 1 setMenuPedSkin() if isScreenVisible then removeEventHandler("onClientRender",root,femaleActivated) addEventHandler("onClientRender",root,maleActivated) end elseif source == femaleButtonClickable or sex == "female" then defaultSex = "female" setPedAnimation(ped,"BEACH","SitnWait_loop_W",_,_,false,false,_) skinTable = femaleSkins totalSkins = #skinTable selectedSkin = 1 setMenuPedSkin() if isScreenVisible then removeEventHandler("onClientRender",root,maleActivated) addEventHandler("onClientRender",root,femaleActivated) end end end addEventHandler("onClientGUIClick",resourceRoot,changeSex) changeSex(defaultSex) function selectNextSkin() if selectedSkin == totalSkins then selectedSkin = 1 else selectedSkin = selectedSkin+1 end end function selectPrevSkin() if selectedSkin == 1 then selectedSkin = totalSkins else selectedSkin = selectedSkin-1 end end function setPlayerTheirSkin() local ID = getSelectedSkinID() setTimer(function()triggerServerEvent("changePlayerSkin",localPlayer,ID,selectedSkin)end,setSkinTimer,1) end -- Button prev < local renderprev = true function prevPedButton() if isScreenVisible then playSound("scroll.mp3") if renderprev == true then addEventHandler("onClientRender",root,prevArrowBlink) renderprev = false end setTimer(function()removeEventHandler("onClientRender",root,prevArrowBlink) renderprev = true end,50,1) selectPrevSkin() setMenuPedSkin() end end addEventHandler("onClientGUIClick",prevButtonClickable,prevPedButton,false) bindKey("arrow_l","down",prevPedButton) -- Button next > local rendernext = true function nextPedButton() if isScreenVisible then playSound("scroll.mp3") if rendernext == true then addEventHandler("onClientRender",root,nextArrowBlink) rendernext = false end setTimer(function()removeEventHandler("onClientRender",root,nextArrowBlink) rendernext = true end,50,1) selectNextSkin() setMenuPedSkin() end end addEventHandler("onClientGUIClick",nextButtonClickable,nextPedButton,false) bindKey("arrow_r","down",nextPedButton) -- Scroll functions function nextPed_scroll() timernext = setTimer( function() timernext2 = setTimer( function() nextPedButton() end ,autoScrollSpeed,0) end ,autoScrollStart,1) end bindKey("arrow_r","down",nextPed_scroll) function prevPed_scroll() timerprev = setTimer( function() timerprev2 = setTimer( function() prevPedButton() end ,autoScrollSpeed,0) end ,autoScrollStart,1) end bindKey("arrow_l","down",prevPed_scroll) function killAutoScroll_next() if isTimer(timerprev) then killTimer(timerprev) elseif isTimer(timerprev2) then killTimer(timerprev2) end end bindKey("arrow_l","up",killAutoScroll_next) function killAutoScroll_prev() if isTimer(timernext) then killTimer(timernext) elseif isTimer(timernext2) then killTimer(timernext2) end end bindKey("arrow_r","up",killAutoScroll_prev) Link to comment
MTA Team 0xCiBeR Posted April 9, 2017 MTA Team Share Posted April 9, 2017 Hola la verdad me es muy difícil leer el código y poder ayudarte si no pones el code dentro de los tags correspondientes. Link to comment
Recommended Posts