Guest Posted September 29, 2012 Share Posted September 29, 2012 Hello ! I have problem with gui button: function zakup(hitElement) if kupuj[1] then outputChatBox("Załadowałeś towar o id 1!", hitElement) end if kupuj[2] then outputChatBox("Załadowałeś towar o id 2!", hitElement) end if kupuj[3] then outputChatBox("Załadowałeś towar o id 3!", hitElement) end end oknotow = guiCreateWindow((x-500)/2,(y-350)/2,500,350,"System towarów",false) for k, v in ipairs (towary) do towar = {} zakup = {} kupuj = {} info = guiCreateLabel (0.06,0.08,0.9,0.3,"Towar Ilość score Min. suma Max. suma", true, oknotow) guiSetFont ( info, "default-bold-small" ) towar[1] = guiCreateLabel (0.03,0.1+0.08*k,0.9,0.3,v[2],true,oknotow) towar[2] = guiCreateLabel (0.27,0.1+0.08*k,0.9,0.3,v[3],true,oknotow) towar[3] = guiCreateLabel (0.46,0.1+0.08*k,0.9,0.3,v[4].."$",true,oknotow) towar[4] = guiCreateLabel (0.68,0.1+0.08*k,0.9,0.3,v[5].."$",true,oknotow) kupuj[k] = guiCreateButton (0.8,0.095+0.08*k,0.13,0.06,"Załaduj",true,oknotow) addEventHandler( "onClientGUIClick", kupuj[k], zakup) zamknij = guiCreateButton (0.45,0.9,0.15,0.07,"Zamknij",true,oknotow) addEventHandler( "onClientGUIClick", zamknij, closegui ) guiSetVisible(oknotow, false) end Why it don't work ? PS. How do to blipy only showed on the radar, and not on the map ? Sorry for bad english ! Link to comment
Musamba Posted September 29, 2012 Share Posted September 29, 2012 /debugscript 3 Any error? Link to comment
Castillo Posted September 29, 2012 Share Posted September 29, 2012 He asked if there is ANY error in the debugscript. Link to comment
Mossy Posted September 29, 2012 Share Posted September 29, 2012 Yes, any. There are no errors. Well which is it? Link to comment
Castillo Posted September 29, 2012 Share Posted September 29, 2012 function zakup ( ) if ( source == kupuj [ 1 ] ) then outputChatBox ( "Zaladowales towar o id 1!" ) elseif ( source == kupuj [ 2 ] ) then outputChatBox ( "Zaladowales towar o id 2!" ) elseif ( source == kupuj [ 3 ] ) then outputChatBox ( "Zaladowales towar o id 3!" ) end end oknotow = guiCreateWindow((x-500)/2,(y-350)/2,500,350,"System towarów",false) for k, v in ipairs ( towary ) do towar = {} zakup = {} kupuj = {} info = guiCreateLabel (0.06,0.08,0.9,0.3,"Towar Ilosc score Min. suma Max. suma", true, oknotow) guiSetFont ( info, "default-bold-small" ) towar[1] = guiCreateLabel (0.03,0.1+0.08*k,0.9,0.3,v[2],true,oknotow) towar[2] = guiCreateLabel (0.27,0.1+0.08*k,0.9,0.3,v[3],true,oknotow) towar[3] = guiCreateLabel (0.46,0.1+0.08*k,0.9,0.3,v[4].."$",true,oknotow) towar[4] = guiCreateLabel (0.68,0.1+0.08*k,0.9,0.3,v[5].."$",true,oknotow) kupuj[k] = guiCreateButton (0.8,0.095+0.08*k,0.13,0.06,"Zaladuj",true,oknotow) addEventHandler ( "onClientGUIClick", kupuj[k], zakup, false ) zamknij = guiCreateButton (0.45,0.9,0.15,0.07,"Zamknij",true,oknotow) addEventHandler ( "onClientGUIClick", zamknij, closegui ) guiSetVisible ( oknotow, false ) end P.S: Is not possible to hide a blip in the "big map ( F11 )" and not in the radar. Link to comment
Castillo Posted September 30, 2012 Share Posted September 30, 2012 What doesn't work? post your complete script. Link to comment
Guest Posted September 30, 2012 Share Posted September 30, 2012 local markers = { {-1725, -121, 2 }, {-1854, 1402, 6.1}, {-2282, 2278, 4,5}, {-367, 1547, 75,1}, {345, 2534, 16,2}, {1641, 2412, 10}, {-2887, 503, 4}, {-1515, 721, 6}, {-683, 965, 12}, {948, 2279, 11}, {1488, 2146, 10}, {1910, 2157, 10}, {2242, 1977, 9}, {-658, 2318, 138}, {-2054, -2565, 30}, {-1416, -1468, 101}, {-605, -483, 25}, {-55, -326, 5}, {1077, -307, 75}, {-2644, 1334, 7}, {2481, 2796, 10}, {-857, -1944, 15}, {-87, -1574, 2}, {-2264, -1688, 480}, {-2029.1010742188, 172.45364379883, 27.35425567627 } } local towary = { {"Odpady", "Trociny", 0, 100, 250}, {"Odpady", "Puszki", 1, 200, 400}, {"Odpady", "Butelki", 2, 400, 550} } local x,y = guiGetScreenSize() function closegui() guiSetVisible(oknotow, false) showCursor(false) end function zakup ( ) if ( source == kupuj [ 1 ] ) then outputChatBox ( "Zaladowales towar o id 1!" ) elseif ( source == kupuj [ 2 ] ) then outputChatBox ( "Zaladowales towar o id 2!" ) elseif ( source == kupuj [ 3 ] ) then outputChatBox ( "Zaladowales towar o id 3!" ) end end oknotow = guiCreateWindow((x-500)/2,(y-350)/2,500,350,"System towarów",false) for k, v in ipairs ( towary ) do towar = {} kupuj = {} info = guiCreateLabel (0.06,0.08,0.9,0.3,"Towar Ilosc score Min. suma Max. suma", true, oknotow) guiSetFont ( info, "default-bold-small" ) towar[1] = guiCreateLabel (0.03,0.1+0.08*k,0.9,0.3,v[2],true,oknotow) towar[2] = guiCreateLabel (0.27,0.1+0.08*k,0.9,0.3,v[3],true,oknotow) towar[3] = guiCreateLabel (0.46,0.1+0.08*k,0.9,0.3,v[4].."$",true,oknotow) towar[4] = guiCreateLabel (0.68,0.1+0.08*k,0.9,0.3,v[5].."$",true,oknotow) kupuj[k] = guiCreateButton (0.8,0.095+0.08*k,0.13,0.06,"Zaladuj",true,oknotow) addEventHandler ( "onClientGUIClick", kupuj[k], zakup, false ) zamknij = guiCreateButton (0.45,0.9,0.15,0.07,"Zamknij",true,oknotow) addEventHandler ( "onClientGUIClick", zamknij, closegui ) guiSetVisible ( oknotow, false ) end for a, b in ipairs (markers) do destmarker = createMarker(b[1], b[2], b[3], "cylinder", 3, 255, 255, 0, 255) createBlip(b[1], b[2], b[3], 51, 2, 255, 0, 0, 255, 0, 1000) setElementData(destmarker, "id", b[4]) end source = getLocalPlayer() -- Cement Truck, DFT-30, Linerunner, Tanker, Mule, RoadTrain, Rumpo, Flatbed local vehicle_ids = {[524] = true, [578] = true, [403] = true, [514] = true, [414] = true, [515] = true, [440] = true, [455] = true} function system(hitElement) local vehicle = getPedOccupiedVehicle(hitElement) if destmarker then if vehicle then if vehicle_ids[getElementModel(vehicle)] then guiSetVisible(oknotow, true) showCursor(true) else outputChatBox("To nie jest pojazd dostawczy!", hitElement, 0, 255, 0) end else outputChatBox("Aby załadować/rozładować towar musisz mieć pojazd!", hitElement, 0, 255, 0) end end end addEventHandler( "onClientMarkerHit", resourceRoot, system ) Client ^^^. I can't click on 1 and 2 button. Link to comment
Castillo Posted September 30, 2012 Share Posted September 30, 2012 local markers = { {-1725, -121, 2 }, {-1854, 1402, 6.1}, {-2282, 2278, 4,5}, {-367, 1547, 75,1}, {345, 2534, 16,2}, {1641, 2412, 10}, {-2887, 503, 4}, {-1515, 721, 6}, {-683, 965, 12}, {948, 2279, 11}, {1488, 2146, 10}, {1910, 2157, 10}, {2242, 1977, 9}, {-658, 2318, 138}, {-2054, -2565, 30}, {-1416, -1468, 101}, {-605, -483, 25}, {-55, -326, 5}, {1077, -307, 75}, {-2644, 1334, 7}, {2481, 2796, 10}, {-857, -1944, 15}, {-87, -1574, 2}, {-2264, -1688, 480}, {-2029.1010742188, 172.45364379883, 27.35425567627 } } 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 function zakup ( ) if ( source == kupuj [ 1 ] ) then outputChatBox ( "Zaladowales towar o id 1!" ) elseif ( source == kupuj [ 2 ] ) then outputChatBox ( "Zaladowales towar o id 2!" ) elseif ( source == kupuj [ 3 ] ) then outputChatBox ( "Zaladowales towar o id 3!" ) end end oknotow = guiCreateWindow((x-500)/2,(y-350)/2,500,350,"System towarów",false) guiSetVisible ( oknotow, false ) info = guiCreateLabel (0.06,0.08,0.7,0.3,"Towar Ilosc score Min. suma Max. suma", true, oknotow) guiSetFont ( info, "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.8,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 a, b in ipairs (markers) do destmarker = createMarker(b[1], b[2], b[3], "cylinder", 3, 255, 255, 0, 255) createBlip(b[1], b[2], b[3], 51, 2, 255, 0, 0, 255, 0, 1000) setElementData(destmarker, "id", b[4]) end source = getLocalPlayer() -- Cement Truck, DFT-30, Linerunner, Tanker, Mule, RoadTrain, Rumpo, Flatbed local vehicle_ids = {[524] = true, [578] = true, [403] = true, [514] = true, [414] = true, [515] = true, [440] = true, [455] = true} function system(hitElement) local vehicle = getPedOccupiedVehicle(hitElement) if destmarker then if vehicle then if vehicle_ids[getElementModel(vehicle)] then guiSetVisible(oknotow, true) showCursor(true) else outputChatBox("To nie jest pojazd dostawczy!", hitElement, 0, 255, 0) end else outputChatBox("Aby zaladowac/rozladowac towar musisz miec pojazd!", hitElement, 0, 255, 0) end end end addEventHandler( "onClientMarkerHit", resourceRoot, system ) Fixed. Problems found: 1: Your GUI-labels we're in front of the GUI-buttons, that's why you couldn't click them. 2: You was creating the close button and the info label 3 times, because you set it inside the loop. 3: You was cleaning the "towar" and "kapuj" tables every time you created the button, becuase you set it inside the loop. 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