Jump to content

Clicking Problem


justn

Recommended Posts

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
  • Moderators

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

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