swag_k_dog Posted October 8, 2016 Share Posted October 8, 2016 (edited) 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 maybe again? thanks a lot Edited October 8, 2016 by swag_k_dog Link to comment
Walid Posted October 8, 2016 Share Posted October 8, 2016 7 minutes ago, swag_k_dog said: setPedElement(localPlayer, 67) Replace (setPedElement with setElementModel) and (localPlayer with source) Link to comment
swag_k_dog Posted October 8, 2016 Author Share Posted October 8, 2016 1 minute ago, Walid said: Replace (setPedElement with setElementModel) and (localPlayer with source) I did and I still dont get a skin after I click the button Link to comment
Walid Posted October 8, 2016 Share Posted October 8, 2016 (edited) 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 October 8, 2016 by Walid Link to comment
swag_k_dog Posted October 8, 2016 Author Share Posted October 8, 2016 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
Walid Posted October 8, 2016 Share Posted October 8, 2016 (edited) 4 minutes ago, swag_k_dog said: I just tried and still no i'm pretty sure it's not your code anyways post full code here. Edited October 8, 2016 by Walid Link to comment
swag_k_dog Posted October 8, 2016 Author Share Posted October 8, 2016 (edited) nvm, just got it. you forgot an "end" at the final of the server side.. thanks <3 @Walid Edited October 8, 2016 by swag_k_dog Link to comment
Walid Posted October 8, 2016 Share Posted October 8, 2016 1 minute ago, swag_k_dog said: nvm, just got it. you forgot an "end" at the final of the server side.. thanks <3 @Walid I already added it check my code anyways you are welcome. 1 Link to comment
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