Jump to content

set skin on gui button, didnt work


swag_k_dog

Recommended Posts

client: 

local sScreen, bCrim, bEnf
local screenW, screenH = guiGetScreenSize()

addEventHandler("onClientResourceStart", resourceRoot,
    function() 
        showCursor(true)
		sScreen = guiCreateStaticImage((screenW - 1366) / 2, (screenH - 768) / 2, 1366, 768, "images/scrn.png", false)
        bCrim = guiCreateButton(376, 369, 162, 63, "", false, sScreen)
		guiSetAlpha(bCrim, 0.00)
        bEnf = guiCreateButton(743, 369, 162, 63, "", false, sScreen)
		guiSetAlpha(bEnf, 0.00)
        
        function closePanel()
            destroyElement(sScreen) 
            removeEventHandler("onClientGUIClick", resourceRoot, guiClicked) 
            showCursor(false)
        end
        
        function guiClicked(btn, state)
            if btn == "left" and state == "up" then 
                if source == bCrim then
                    triggerServerEvent("onClientTeamPicked", localPlayer, "Criminal") 
					closePanel() 
                elseif source == bEnf then
                    triggerServerEvent("onClientTeamPicked", localPlayer, "Enforcer") 
					closePanel()					
                end
            end
        end
        addEventHandler("onClientGUIClick", resourceRoot, guiClicked) 
		
		function giveTeam(btn, localPlayer)
		if btn == "left" and state "up" then
		 if source == bCrim then
		 triggerServerEvent("setDudeSkin", localPlayer, "CrimSkin")
		elseif source == eBnf then
		 triggerServerEvent("setDudeSkin", localPlayer, "EnfSkin")
		end
		end
		end
		 
		
        
    end
)

server:

local crimz = createTeam ( "Criminal", 255, 0, 0 )
local enfz = createTeam ( "Enforcer", 0, 0, 255 )

addEvent("onClientTeamPicked", true) 
addEventHandler("onClientTeamPicked", root, function(name)  

 local team = getTeamFromName(name) 

	setPlayerTeam(client, team) 
	
end )

addEvent("setDudeSkin", true)

addEventHandler("setDudeSkin", root, function(CrimSkin, EnfSkin)
setPedElement(localPlayer, 67)
end )

I want when the player to get a skin when he clicks one of the buttons. and I dont know how to do it..

for example when you click the "Criminal" button, you get skin id 67 and when you click the "Enforcer" button you get skin id 114.

I tried and it didnt go well, help???

@pa3ck , you helped me before :P maybe again? thanks a lot

Edited by swag_k_dog
Link to comment
9 minutes ago, swag_k_dog said:

I did and I still dont get a skin after I click the button

Many things wrong in your code you can use sth like this

-- client side
function guiClicked(btn, state)
    if btn == "left" and state == "up" then 
        if source == bCrim then
            triggerServerEvent("onClientTeamPicked", localPlayer, "Criminal", --[[put the skin id here]]) 
            closePanel() 
        elseif source == bEnf then
            triggerServerEvent("onClientTeamPicked", localPlayer, "Enforcer", --[[put the skin id here]]) 
            closePanel()					
        end
    end
end
addEventHandler("onClientGUIClick", resourceRoot, guiClicked) 

-- server side
addEvent("onClientTeamPicked", true) 
addEventHandler("onClientTeamPicked", root, 
function(name,skin)  
    if name and tonumber(skin) then 
        local team = getTeamFromName(name) 
        setPlayerTeam(source, team) 
        setElementModel(source,tonumber(skin))
    end 
end)

And remove the  giveTeam function.

Edited by Walid
Link to comment
5 minutes ago, Walid said:

Many things wrong in your code you can use sth like this


-- client side
function guiClicked(btn, state)
    if btn == "left" and state == "up" then 
        if source == bCrim then
            triggerServerEvent("onClientTeamPicked", localPlayer, "Criminal", --[[put the skin id here]]) 
            closePanel() 
        elseif source == bEnf then
            triggerServerEvent("onClientTeamPicked", localPlayer, "Enforcer", --[[put the skin id here]]) 
            closePanel()					
        end
    end
end
addEventHandler("onClientGUIClick", resourceRoot, guiClicked) 

-- server side
addEvent("onClientTeamPicked", true) 
addEventHandler("onClientTeamPicked", root, 
function(name,skin)  
	if name and tonumber(skin) then 
        local team = getTeamFromName(name) 
        setPlayerTeam(source, team) 
        setElementModel(source,tonumber(skin))
    end 
)

And remove the  giveTeam function.

I just tried and still no 

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