Dziugasc Posted April 25, 2019 Posted April 25, 2019 Hello, I spent few hours trying to fix my code, but it didn't work for me CODE: (client) local skins = {7,124,69} addEvent( "PlayerCharacterSelection", true) local spawnPed = createPed ( 7, -1969.93103, 158.23845, 27.68750 , 180 ) local PedDimension = setElementDimension(spawnPed,2) setPedAnimation(spawnPed, "DANCING", "dnce_M_c") function setCameraOnClothes() setCameraMatrix( -1969.69775, 155.04910, 26.78750, -1970.17273, 162.80780, 29.77750) end addCommandHandler( "PlayerCharacterSelection", setCameraOnClothes) function pedRotateE ( ) local rotX, rotY, rotZ = getElementRotation(spawnPed) setElementRotation(spawnPed,0,0,rotZ+10,"default",true) end addCommandHandler ( "e", pedRotateE ) function pedRotateQ ( ) local rotX, rotY, rotZ = getElementRotation(spawnPed) setElementRotation(spawnPed,0,0,rotZ-10,"default",true) end addCommandHandler ( "q", pedRotateQ ) function bindTheKeys () bindKey ( "mouse_wheel_down", "down", pedRotateQ ) bindKey ( "mouse_wheel_up", "down", pedRotateE ) end addEventHandler ( "onClientResourceStart", root , bindTheKeys ) function getSelectedSkin( ) local selectedSkin = skinTable[skins] return selectedSkin end function setPedSkin2() local selectedSkin = GetSelectedSkin setElementModel(spawnPed,selectedSkin) end function changeSkin() skins = skinTable totalSkins = #skinTable selectedSkin = 7 setPedSkin2() end function selectNextSkin() if selectedSkin == totalSkins then selectedSkin = 7 else selectedSkin = selectedSkin+1 setPedSkin2() end end addCommandHandler("next", selectNextSkin) function selectPrevSkin() if selectedSkin == totalSkins then selectedSkin = 7 else selectedSkin = selectedSkin-1 setPedSkin2() end end addCommandHandler("prev", selectPrevSkin)
Moderators IIYAMA Posted April 25, 2019 Moderators Posted April 25, 2019 @Dziugasc Indeed, that is not going to work. local skins = {7,124,69} local skinIndex = 1 function getSelectedSkin() local selectedSkin = skins[skinIndex] return selectedSkin end function updateToNextSkin () skinIndex = skinIndex + 1 if skinIndex > #skins then skinIndex = 1 end return getSelectedSkin() end function updateToPreviousSkin () skinIndex = skinIndex - 1 if skinIndex < 1 then skinIndex = #skins end return getSelectedSkin() end 1 Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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