Jump to content

Recommended Posts

function changeWalkingStyle(_, changeModel, _, _, _, spawnModel)
    local skin = eventName == 'onElementModelChange' and changeModel or (eventName == 'onPlayerSpawn' and spawnModel)
    local model, walkingStyle = 0, 121;
    if skin then
        if getElementType(source) == 'player' then
            if skin == model then 
                setPedWalkingStyle(source, walkingStyle)
            else
                setPedWalkingStyle(source, 0)
            end
        end
    else
        for _, player in ipairs(getElementsByType('player')) do
            if getElementModel(player) == model then
                setPedWalkingStyle(player, walkingStyle)
            else
                setPedWalkingStyle(player, 0)
            end
        end
    end
end
addEventHandler('onElementModelChange', root, changeWalkingStyle)
addEventHandler('onPlayerSpawn', root, changeWalkingStyle)
addEventHandler('onResourceStart', root, changeWalkingStyle)

 

Link to comment

I think it should work:

pedwalk = {
--[model id] = ped walking style,
[0] = 121,
}

function style(_, skin,_,_,_,skin2)
	if eventName == "onResourceStart" then
		for _, player in ipairs(getElementsByType('player')) do
			setStyle(pl)
		end
	elseif eventName == "onElementModelChange" then
		if getElementType(pl) == "player" or getElementType(pl) == "ped" then
			setStyle(source,skin)
		end
	elseif eventName == "onPlayerSpawn" then
		setStyle(source,skin2)
	end
end
addEventHandler('onResourceStart', root, style)
addEventHandler('onElementModelChange', root, style)
addEventHandler('onPlayerSpawn', root, style)

function setStyle(pl,b)
	if getElementType(pl) == "player" then -- only for players
		if not b then b = getElementModel(pl) end -- check if no skin here
		if pedwalk[b]
			setPedWalkingStyle(pl, pedwalk[b])
		end
	end
end

 

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...