Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.71 KB | None | 0 0
  1.  
  2. -- client side
  3.  
  4. addEventHandler( "onClientGUIClick", resourceRoot,
  5. function()
  6.     if (source == GUIEditor.button[1]) then -- The button to buy
  7.         guiSetVisible(GUIEditor.window[1], true) -- The window to buy
  8.         showCursor(true)
  9.     elseif (source == buyButton) then -- add your button to buy
  10.         buyFish()
  11.     end
  12. end)
  13.      
  14.      
  15. function buyFish()
  16.     local money = getPlayerMoney(localPlayer)
  17.     if (money >= 300) then
  18.         outputChatBox("You have bought a fish food.")
  19.         triggerServerEvent("buyFish", resourceRoot)
  20.     else
  21.         outputChatBox("You don't have enough money.")
  22.     end
  23. end
  24.  
  25.  
  26. -- server side
  27.  
  28. function buyFish()
  29.     takePlayerMoney(client, 300)
  30. end
  31. addEvent("buyFish", true)
  32. addEventHandler("buyFish", root, buyFish)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement