Recommended Posts

2 minutes ago, Ivan Orel said:

How to make Walking Style for specific skin (player)?

use onElementModelChange and setPedWalkingStyle

this is an example 

function changeWalkingStyle(oldModel,newModel)
    if ( getElementType(source) == "player" ) then
             if ( newModel == 152 ) then 

	        setPedWalkingStyle( source, 133 )
	
	     end
    end
end
addEventHandler("onElementModelChange", root, changeWalkingStyle)

 

Share this post


Link to post
13 minutes ago, <~KaMiKaZe~> said:

use onElementModelChange and setPedWalkingStyle

this is an example 


function changeWalkingStyle(oldModel,newModel)
    if ( getElementType(source) == "player" ) then
             if ( newModel == 152 ) then 

	        setPedWalkingStyle( source, 133 )
	
	     end
    end
end
addEventHandler("onElementModelChange", root, changeWalkingStyle)

 

doesn't work

Share this post


Link to post
1 minute ago, Ivan Orel said:

doesn't work

You put it in the server-side ?

Share this post


Link to post

 

7 minutes ago, Ivan Orel said:

on client-side

Put that on server-side. There is no "onClientElementModelChange"

Share this post


Link to post
7 minutes ago, <~KaMiKaZe~> said:

 

Put that on server-side. There is no "onClientElementModelChange"

I Put that on server-side, so... Doesn't work

Share this post


Link to post
2 minutes ago, Ivan Orel said:

I Put that on server-side, so... Doesn't work

That only works if you write " /ss 152 ". It's not programmed for every skin. It's only an example

Share this post


Link to post
18 minutes ago, <~KaMiKaZe~> said:

That only works if you write " /ss 152 ". It's not programmed for every skin. It's only an example

I do not want to use the command. I want this to happen automatically.

Share this post


Link to post
3 minutes ago, Ivan Orel said:

I do not want to use the command. I want this to happen automatically.

That is automatic. When the player has the skin, their walk style going to change.

Share this post


Link to post
Just now, <~KaMiKaZe~> said:

That is automatic. When the player has the skin, their walk style going to change.

I change skin from freeroam and admin panel and doesn't work.

Share this post


Link to post
3 minutes ago, Ivan Orel said:

I change skin from freeroam and admin panel and doesn't work.

Hmm, i really don't know. The code works perfectly on my test server

Share this post


Link to post
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)

 

Share this post


Link to post

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

 

Share this post


Link to post

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.