Stranger Posted April 5, 2014 Posted April 5, 2014 hey guys, why if i do trigger to setElementModel from client to server side , not work ? client side: addEventHandler("onClientGUIClick", root, function() if (source == s1) then local row, col = guiGridListGetSelectedItem(gri) local ski = guiGridListGetItemText(gri, row, col) if (ski) then guiSetVisible(se, false) showCursor(false) if (ski == "Skin 1") then triggerServerEvent ("onPlayerSelectTheSkinOne", localPlayer) elseif (ski == "Skin 2") then triggerServerEvent ("onPlayerSelectTheSkinTwo", localPlayer) elseif (ski == "Skin 3") then triggerServerEvent ("onPlayerSelectTheSkinThree", localPlayer) elseif (ski == "Skin 4") then triggerServerEvent ("onPlayerSelectTheSkinFour", localPlayer) end end end end ) server side: addEvent ("onPlayerSelectTheSkinOne", true) addEvent ("onPlayerSelectTheSkinTwo", true) addEvent ("onPlayerSelectTheSkinThree", true) addEvent ("onPlayerSelectTheSkinFour", true) addEventHandler ("onPlayerSelectTheSkinOne", function () setElementModel(source, 283) end) addEventHandler ("onPlayerSelectTheSkinTwo", function () setElementModel(source, 282) end) addEventHandler ("onPlayerSelectTheSkinThree", function () setElementModel(source, 285) end) addEventHandler ("onPlayerSelectTheSkinFour", function () setElementModel(source, 287) end)
myonlake Posted April 5, 2014 Posted April 5, 2014 Let's start from what guiGridListGetItemText returns right now. Mind dumping it and tell us what it does?
Stranger Posted April 5, 2014 Author Posted April 5, 2014 i meant if someone select a skin from the grid list, and press the button then do trigger to setElementModel, i did put it in client side but no one can see the skin but him.
myonlake Posted April 5, 2014 Posted April 5, 2014 Instead of triggering the event to the localPlayer, put it to root. Make sure you pass in the player element as an argument however.
Stranger Posted April 5, 2014 Author Posted April 5, 2014 ohhh sorry that i forgot 'root', thank you, i will try it now. ------- yesh it's work, thank you...
Arnold-1 Posted April 5, 2014 Posted April 5, 2014 another thing, why did you make 4 triggers, just make one with an argument: addEventHandler("onClientGUIClick", root, function() if (source == s1) then local row, col = guiGridListGetSelectedItem(gri) local ski = guiGridListGetItemText(gri, row, col) if (ski) then guiSetVisible(se, false) showCursor(false) triggerServerEvent ("onPlayerSelectTheSkinSkin",root,ski) end end end ) server: addEvent ("onPlayerSelectTheSkin", true) addEventHandler ("onPlayerSelectTheSkin", function (theSkin) if theSkin == "Skin 1" then setElementModel(source, 283) elseif theSkin == "Skin 2" then setElementModel(source, 282) elseif theSkin == "Skin3" then setElementModel(source, 285) elseif theSkin == "Skin4" then setElementModel(source, 287) end end)
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