justn Posted April 3, 2014 Share Posted April 3, 2014 So I have this problem with a clothes shop, and the only problem is, i need to click the buy button alot of times, then it will add clothes Client: addEventHandler("onClientGUIClick",Clothes_Window, function (b) if b == "left" then if source == BuyClothes then local Selected = guiGridListGetItemText ( NameClothes_Grid, guiGridListGetSelectedItem ( NameClothes_Grid ), colID ) local Selected2 = guiGridListGetItemText ( NameClothes_Grid, guiGridListGetSelectedItem ( NameClothes_Grid ), colname ) local Selected3 = guiGridListGetItemText ( NameClothes_Grid, guiGridListGetSelectedItem ( NameClothes_Grid ), clomod ) if getPedClothes ( localPlayer, tonumber(Selected3)) then removePedClothes ( localPlayer, tonumber(Selected3)) triggerServerEvent("addClothes",localPlayer,Selected2,Selected3) exports["TopBarChat"]:sendClientMessage("#00ff00* #FFFFFFYou bought a "..Selected2.." for $25",255,255,255,true) else triggerServerEvent("addClothes",localPlayer,Selected2,Selected3) end end end end) Server: function clothes ( Selected2, Selected3) local stuff = math.random(0,17) addPedClothes (source,tostring(Selected2),tostring(Selected3),tonumber(stuff)) end addEvent("addClothes",true) addEventHandler("addClothes",getRootElement(),clothes) Link to comment
.:HyPeX:. Posted April 3, 2014 Share Posted April 3, 2014 Why you send it server-side? its unnecesary to do that, those events and fnc are also aviable client-side. Link to comment
justn Posted April 3, 2014 Author Share Posted April 3, 2014 I know . . but .. can you help or not ? Link to comment
justn Posted April 3, 2014 Author Share Posted April 3, 2014 Not really, but the problem started in the part with math.random Link to comment
Moderators IIYAMA Posted April 3, 2014 Moderators Share Posted April 3, 2014 Of course it isn't working. You should not use math random in the first place. Every type has it's own texture's and models. See wiki example: https://wiki.multitheftauto.com/wiki/Ge ... yTypeIndex function scriptNextClothes ( thePlayer, key, clothesType ) local currentTexture, currentModel = getPedClothes ( thePlayer, clothesType ) -- get the current clothes on this slot local clothesIndex = -1 if ( currentTexture ) then -- if he had clothes of that type local tempA, tempB = getTypeIndexFromClothes ( currentTexture, currentModel ) -- get the type and index for these clothes, so we can increase it to get the next set in the list if ( tempA and tempB ) then -- if we found them clothesType, clothesIndex = tempA, tempB end end clothesIndex = clothesIndex + 1 local texture, model = getClothesByTypeIndex ( clothesType, clothesIndex ) -- get the new texture and model if ( texture == false ) then -- if we've reached the end of the list removePedClothes ( thePlayer, clothesType ) else addPedClothes ( thePlayer, texture, model, clothesType ) end end addCommandHandler ( "nextClothes", scriptNextClothes ) Link to comment
justn Posted April 3, 2014 Author Share Posted April 3, 2014 Well the thing is.. i don't really understand how im doing it for clothes store 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