Guest Posted October 3, 2012 Share Posted October 3, 2012 Hello ! How to block buttons, which required number of points is greater than the number of points a player ? local towary = { {"Odpady", "Trociny", 0, 100, 250}, {"Odpady", "Puszki", 1, 200, 400}, {"Odpady", "Butelki", 2, 400, 550} } local towar = { } local kupuj = { } local x,y = guiGetScreenSize() function closegui() guiSetVisible(oknotow, false) showCursor(false) end oknotow = guiCreateWindow((x-500)/2,(y-350)/2,500,350,"System towarów",false) guiSetVisible ( oknotow, false ) info1 = guiCreateLabel (0.06,0.08,0.7,0.3,"Towar", true, oknotow) info2 = guiCreateLabel (0.22,0.08,0.7,0.3,"Ilość score", true, oknotow) info3 = guiCreateLabel (0.45,0.08,0.7,0.3,"Min. suma", true, oknotow) info4 = guiCreateLabel (0.67,0.08,0.7,0.3,"Max. suma", true, oknotow) guiSetFont ( info1, "default-bold-small" ) guiSetFont ( info2, "default-bold-small" ) guiSetFont ( info3, "default-bold-small" ) guiSetFont ( info4, "default-bold-small" ) for k, v in ipairs ( towary ) do function zakup () if source == kupuj[k] then outputChatBox ( "Zaladowales towar o id " .. k, source) end end towar[1] = guiCreateLabel (0.03,0.1+0.08*k,0.2,0.1,v[2],true,oknotow) towar[2] = guiCreateLabel (0.27,0.1+0.08*k,0.2,0.1,v[3],true,oknotow) towar[3] = guiCreateLabel (0.46,0.1+0.08*k,0.2,0.1,v[4].."$",true,oknotow) towar[4] = guiCreateLabel (0.68,0.1+0.08*k,0.2,0.1,v[5].."$",true,oknotow) kupuj[k] = guiCreateButton (0.83,0.095+0.08*k,0.13,0.06,"Załaduj",true,oknotow) addEventHandler ( "onClientGUIClick", kupuj[k], zakup, false ) end zamknij = guiCreateButton (0.45,0.9,0.15,0.07,"Zamknij",true,oknotow) addEventHandler ( "onClientGUIClick", zamknij, closegui ) Sorry, for bad english ! Link to comment
Guest Posted October 3, 2012 Share Posted October 3, 2012 Yes, i know, but how to block not the appropriate buttons. Towar1 = 1 points Towar2 = 3 points Towar3 = 10 points Player = 4 points If player will have 4 points, he/she can see only buttons Towar1 and Towar2 ! Link to comment
Castillo Posted October 3, 2012 Share Posted October 3, 2012 Do you have these "points" stored somewhere? Link to comment
Guest Posted October 3, 2012 Share Posted October 3, 2012 (edited) local towary = { {"Odpady", "Trociny", 0, 100, 250}, {"Odpady", "Puszki", 1, 200, 400}, {"Odpady", "Butelki", 2, 400, 550} } Odpady = category e.g.: Trociny = towar e.g.: 0 = minimum points e.g.: 100 = minimum prize e.g.: 250 = maximum prize Edit: I have not yet made the player points. Edited October 3, 2012 by Guest Link to comment
Castillo Posted October 3, 2012 Share Posted October 3, 2012 Well, then you should first store them, then you can disable the buttons. Link to comment
Guest Posted October 3, 2012 Share Posted October 3, 2012 Can you show an example? Player points can be expressed with variable points. Link to comment
Castillo Posted October 3, 2012 Share Posted October 3, 2012 local towary = { { "Odpady", "Trociny", 0, 100, 250 }, { "Odpady", "Puszki", 1, 200, 400 }, { "Odpady", "Butelki", 2, 400, 550 } } local towar = { } local kupuj = { } local x,y = guiGetScreenSize ( ) local playerPoints = 1 function closegui ( ) guiSetVisible ( oknotow, false ) showCursor ( false ) end function zakup ( ) for k, v in ipairs ( towary ) do if ( source == kupuj [ k ] ) then outputChatBox ( "Zaladowales towar o id ".. k ) end end end oknotow = guiCreateWindow((x-500)/2,(y-350)/2,500,350,"System towarów",false) guiSetVisible ( oknotow, false ) info1 = guiCreateLabel (0.06,0.08,0.7,0.3,"Towar", true, oknotow) info2 = guiCreateLabel (0.22,0.08,0.7,0.3,"Ilosc score", true, oknotow) info3 = guiCreateLabel (0.45,0.08,0.7,0.3,"Min. suma", true, oknotow) info4 = guiCreateLabel (0.67,0.08,0.7,0.3,"Max. suma", true, oknotow) guiSetFont ( info1, "default-bold-small" ) guiSetFont ( info2, "default-bold-small" ) guiSetFont ( info3, "default-bold-small" ) guiSetFont ( info4, "default-bold-small" ) for k, v in ipairs ( towary ) do towar[1] = guiCreateLabel (0.03,0.1+0.08*k,0.2,0.1,v[2],true,oknotow) towar[2] = guiCreateLabel (0.27,0.1+0.08*k,0.2,0.1,v[3],true,oknotow) towar[3] = guiCreateLabel (0.46,0.1+0.08*k,0.2,0.1,v[4].."$",true,oknotow) towar[4] = guiCreateLabel (0.68,0.1+0.08*k,0.2,0.1,v[5].."$",true,oknotow) kupuj[k] = guiCreateButton (0.83,0.095+0.08*k,0.13,0.06,"Zaladuj",true,oknotow) addEventHandler ( "onClientGUIClick", kupuj [ k ], zakup, false ) end zamknij = guiCreateButton (0.45,0.9,0.15,0.07,"Zamknij",true,oknotow) addEventHandler ( "onClientGUIClick", zamknij, closegui ) for k, v in ipairs ( towary ) do guiSetEnabled ( kupuj [ k ], ( playerPoints >= v [ 3 ] ) ) end for k, v in ipairs ( towary ) do guiSetEnabled ( kupuj [ k ], ( playerPoints >= v [ 3 ] ) ) end You must use that when you open the GUI. Link to comment
Guest Posted October 3, 2012 Share Posted October 3, 2012 Ok, but now i can't click button 1 and 2 (true). Link to comment
Castillo Posted October 3, 2012 Share Posted October 3, 2012 I tested it and worked fine. Link to comment
Guest Posted October 4, 2012 Share Posted October 4, 2012 Ehh, now it worked. Thank you 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