Jump to content

[HELP] Can't find problem in skinTable


Dziugasc

Recommended Posts

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)

 

Link to comment
  • Moderators

@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

 

  • Thanks 1
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...