ksTakor Posted April 15, 2013 Share Posted April 15, 2013 Help me with my script I already make the gui but I don't know how to make the button set the elements. And I can't open. Please help function onJoin () if isPlayerAdmin (source) then bindKey ( source, "F7", "down", isPlayerAdmins ) end end function isPlayerAdmin (source) local accountname = getAccountName(getPlayerAccount(source)) if isObjectInACLGroup("user." ..accountname, aclGetGroup("Admin")) then return true elseif isObjectInACLGroup("user." ..accountname, aclGetGroup("SuperModerator")) then return true end end function opengui () if isPlayerAdmin (source) then bindKey ( source, "F7", "down", isPlayerAdmins ) guiGetEnabled ( paineldayz, true) end end paineldayz = { tab = {}, tabpanel = {}, edit = {}, button = {}, window = {}, label = {}, gridlist = {} } function panelgui() paineldayz.window[1] = guiCreateWindow(383, 107, 448, 515, "", false) guiWindowSetSizable(paineldayz.window[1], false) paineldayz.tabpanel[1] = guiCreateTabPanel(10, 77, 427, 325, false, paineldayz.window[1]) paineldayz.tab[1] = guiCreateTab("Weapons", paineldayz.tabpanel[1]) paineldayz.gridlist[1] = guiCreateGridList(10, 10, 409, 280, false, paineldayz.tab[1]) guiGridListAddColumn(paineldayz.gridlist[1], "Weapons", 0.9) for i = 1, 16 do guiGridListAddRow(paineldayz.gridlist[1]) end guiGridListSetItemText(paineldayz.gridlist[1], 0, 1, "AK-47", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 1, 1, "Baseball Bat", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 2, 1, "CZ 550", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 3, 1, "Desert Eagle", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 4, 1, "Golf Club", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 5, 1, "Hatchet", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 6, 1, "Lee Enfield", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 7, 1, "M1911", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 8, 1, "M4", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 9, 1, "M9 SD", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 10, 1, "MP5A5", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 11, 1, "PDW", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 12, 1, "SPAZ-12 Shotgun", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 13, 1, "Sawn-Off Shotgun", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 14, 1, "Shovel", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 15, 1, "Winchester 1866", false, false) paineldayz.tab[2] = guiCreateTab("Ammo", paineldayz.tabpanel[1]) paineldayz.gridlist[2] = guiCreateGridList(10, 10, 408, 280, false, paineldayz.tab[2]) guiGridListAddColumn(paineldayz.gridlist[2], "Ammo", 0.9) for i = 1, 12 do guiGridListAddRow(paineldayz.gridlist[2]) end guiGridListSetItemText(paineldayz.gridlist[2], 0, 1, "M4 Mag", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 1, 1, "AK-47 Mag", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 2, 1, "CZ 550 Mag", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 3, 1, "MP5A5 Mag", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 4, 1, "PDW Mag", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 5, 1, "1866 Slug", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 6, 1, "SPAZ-12 Pellet", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 7, 1, "2Rnd. Slug", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 8, 1, "M1911 Mag", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 9, 1, "M9 SD Mag", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 10, 1, "Desert Eagle", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 11, 1, "Lee Enfield Mag", false, false) paineldayz.tab[3] = guiCreateTab("Food", paineldayz.tabpanel[1]) paineldayz.gridlist[3] = guiCreateGridList(10, 10, 408, 280, false, paineldayz.tab[3]) guiGridListAddColumn(paineldayz.gridlist[3], "Food", 0.9) for i = 1, 9 do guiGridListAddRow(paineldayz.gridlist[3]) end guiGridListSetItemText(paineldayz.gridlist[3], 0, 1, "Beans Can", false, false) guiGridListSetItemText(paineldayz.gridlist[3], 1, 1, "Burger", false, false) guiGridListSetItemText(paineldayz.gridlist[3], 2, 1, "Cooked Meat", false, false) guiGridListSetItemText(paineldayz.gridlist[3], 3, 1, "Milk", false, false) guiGridListSetItemText(paineldayz.gridlist[3], 4, 1, "Pasta Can", false, false) guiGridListSetItemText(paineldayz.gridlist[3], 5, 1, "Pizza", false, false) guiGridListSetItemText(paineldayz.gridlist[3], 6, 1, "Raw Meat", false, false) guiGridListSetItemText(paineldayz.gridlist[3], 7, 1, "Soda Bottle", false, false) guiGridListSetItemText(paineldayz.gridlist[3], 8, 1, "Water Bottle", false, false) paineldayz.tab[4] = guiCreateTab("Toolbelt", paineldayz.tabpanel[1]) paineldayz.gridlist[4] = guiCreateGridList(10, 10, 408, 280, false, paineldayz.tab[4]) guiGridListAddColumn(paineldayz.gridlist[4], "Toolbelt", 0.9) for i = 1, 8 do guiGridListAddRow(paineldayz.gridlist[4]) end guiGridListSetItemText(paineldayz.gridlist[4], 0, 1, "GPS", false, false) guiGridListSetItemText(paineldayz.gridlist[4], 1, 1, "Map", false, false) guiGridListSetItemText(paineldayz.gridlist[4], 2, 1, "Night Vision Goggles", false, false) guiGridListSetItemText(paineldayz.gridlist[4], 3, 1, "Infrared Goggles", false, false) guiGridListSetItemText(paineldayz.gridlist[4], 4, 1, "Toolbox", false, false) guiGridListSetItemText(paineldayz.gridlist[4], 5, 1, "Watch", false, false) guiGridListSetItemText(paineldayz.gridlist[4], 6, 1, "Box of Matches", false, false) guiGridListSetItemText(paineldayz.gridlist[4], 7, 1, "Radio Device", false, false) paineldayz.tab[5] = guiCreateTab("Misc", paineldayz.tabpanel[1]) paineldayz.gridlist[5] = guiCreateGridList(10, 10, 408, 280, false, paineldayz.tab[5]) guiGridListAddColumn(paineldayz.gridlist[5], "Misc", 0.9) for i = 1, 11 do guiGridListAddRow(paineldayz.gridlist[5]) end guiGridListSetItemText(paineldayz.gridlist[5], 0, 1, "Wood Pile", false, false) guiGridListSetItemText(paineldayz.gridlist[5], 1, 1, "Full Gas Canister", false, false) guiGridListSetItemText(paineldayz.gridlist[5], 2, 1, "Engine", false, false) guiGridListSetItemText(paineldayz.gridlist[5], 3, 1, "Tire", false, false) guiGridListSetItemText(paineldayz.gridlist[5], 4, 1, "Roadflare", false, false) guiGridListSetItemText(paineldayz.gridlist[5], 5, 1, "Wire Fence", false, false) guiGridListSetItemText(paineldayz.gridlist[5], 6, 1, "Parachute", false, false) guiGridListSetItemText(paineldayz.gridlist[5], 7, 1, "Coyote Backpack", false, false) guiGridListSetItemText(paineldayz.gridlist[5], 8, 1, "Alice Pack", false, false) guiGridListSetItemText(paineldayz.gridlist[5], 9, 1, "Assault Pack (ACU)", false, false) guiGridListSetItemText(paineldayz.gridlist[5], 10, 1, "Czech Backpack", false, false) paineldayz.tab[6] = guiCreateTab("Medicine", paineldayz.tabpanel[1]) paineldayz.gridlist[6] = guiCreateGridList(10, 10, 407, 281, false, paineldayz.tab[6]) guiGridListAddColumn(paineldayz.gridlist[6], "Medicine", 0.9) for i = 1, 6 do guiGridListAddRow(paineldayz.gridlist[6]) end guiGridListSetItemText(paineldayz.gridlist[6], 0, 1, "Bandage", false, false) guiGridListSetItemText(paineldayz.gridlist[6], 1, 1, "Blood Bag", false, false) guiGridListSetItemText(paineldayz.gridlist[6], 2, 1, "Heat Pack", false, false) guiGridListSetItemText(paineldayz.gridlist[6], 3, 1, "Medic Kit", false, false) guiGridListSetItemText(paineldayz.gridlist[6], 4, 1, "Morphine", false, false) guiGridListSetItemText(paineldayz.gridlist[6], 5, 1, "Painkiller", false, false) paineldayz.label[1] = guiCreateLabel(87, 19, 291, 20, "Dayz Item Panel by:ksTakor", false, paineldayz.window[1]) guiLabelSetHorizontalAlign(paineldayz.label[1], "center", false) guiLabelSetVerticalAlign(paineldayz.label[1], "center") paineldayz.label[2] = guiCreateLabel(158, 412, 128, 15, "Item Number:", false, paineldayz.window[1]) guiLabelSetHorizontalAlign(paineldayz.label[2], "center", false) guiLabelSetVerticalAlign(paineldayz.label[2], "center") paineldayz.edit[1] = guiCreateEdit(194, 437, 52, 19, "", false, paineldayz.window[1]) paineldayz.button[1] = guiCreateButton(9, 482, 429, 23, "\/", false, paineldayz.window[1]) addEventHandler ( "onClientGUIClick",paineldayz.button[1], give, false ) addEventHandler ( "onClientGUIClick",paineldayz.edit[1], give, false ) end function give (button,state) if button == "left" then setElementData(getPlayerFromName("source"),"guiGridListGetSelectedItems( paineldayz.gridlist ),paineldayz.edit) if (true) then outputChatBox("Deu errado.",true) end end Link to comment
OGF Posted April 15, 2013 Share Posted April 15, 2013 Assuming you did all of this client-sided, things such as the isPlayerAdmin should be on the server side. so make a function that has triggerClientEvent so when the button is pressed the window opens. the onJoin function also.. --Server sided script.. function isPlayerAdmin (source) local accountname = getAccountName(getPlayerAccount(source)) if isObjectInACLGroup("user." ..accountname, aclGetGroup("Admin")) then return true elseif isObjectInACLGroup("user." ..accountname, aclGetGroup("SuperModerator")) then return true end end function openWindow(source) if isPlayerAdmin (source) then triggerClientEvent ( ... ) --code there. end end function onJoin () if isPlayerAdmin (source) then bindKey ( source, "F7", "down", openWindow) end end addEventHandler ( "onPlayerJoin", root, onJoin ) Link to comment
DNL291 Posted April 15, 2013 Share Posted April 15, 2013 Also, the give function contains errors. Link to comment
Max+ Posted April 15, 2013 Share Posted April 15, 2013 defined source in the function , not needed , Link to comment
Sasu Posted April 15, 2013 Share Posted April 15, 2013 Also, the event is wrong because when a player join He is in guest account. Link to comment
ksTakor Posted April 15, 2013 Author Share Posted April 15, 2013 DNL291 can you tell me the error? I am nuub kk And Thanks Sasuke Client: paineldayz = { tab = {}, tabpanel = {}, edit = {}, button = {}, window = {}, label = {}, gridlist = {} } function panelgui() paineldayz.window[1] = guiCreateWindow(383, 107, 448, 515, "", false) guiWindowSetSizable(paineldayz.window[1], false) paineldayz.tabpanel[1] = guiCreateTabPanel(10, 77, 427, 325, false, paineldayz.window[1]) paineldayz.tab[1] = guiCreateTab("Weapons", paineldayz.tabpanel[1]) paineldayz.gridlist[1] = guiCreateGridList(10, 10, 409, 280, false, paineldayz.tab[1]) guiGridListAddColumn(paineldayz.gridlist[1], "Weapons", 0.9) for i = 1, 16 do guiGridListAddRow(paineldayz.gridlist[1]) end guiGridListSetItemText(paineldayz.gridlist[1], 0, 1, "AK-47", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 1, 1, "Baseball Bat", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 2, 1, "CZ 550", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 3, 1, "Desert Eagle", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 4, 1, "Golf Club", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 5, 1, "Hatchet", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 6, 1, "Lee Enfield", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 7, 1, "M1911", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 8, 1, "M4", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 9, 1, "M9 SD", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 10, 1, "MP5A5", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 11, 1, "PDW", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 12, 1, "SPAZ-12 Shotgun", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 13, 1, "Sawn-Off Shotgun", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 14, 1, "Shovel", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 15, 1, "Winchester 1866", false, false) paineldayz.tab[2] = guiCreateTab("Ammo", paineldayz.tabpanel[1]) paineldayz.gridlist[2] = guiCreateGridList(10, 10, 408, 280, false, paineldayz.tab[2]) guiGridListAddColumn(paineldayz.gridlist[2], "Ammo", 0.9) for i = 1, 12 do guiGridListAddRow(paineldayz.gridlist[2]) end guiGridListSetItemText(paineldayz.gridlist[2], 0, 1, "M4 Mag", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 1, 1, "AK-47 Mag", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 2, 1, "CZ 550 Mag", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 3, 1, "MP5A5 Mag", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 4, 1, "PDW Mag", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 5, 1, "1866 Slug", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 6, 1, "SPAZ-12 Pellet", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 7, 1, "2Rnd. Slug", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 8, 1, "M1911 Mag", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 9, 1, "M9 SD Mag", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 10, 1, "Desert Eagle", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 11, 1, "Lee Enfield Mag", false, false) paineldayz.tab[3] = guiCreateTab("Food", paineldayz.tabpanel[1]) paineldayz.gridlist[3] = guiCreateGridList(10, 10, 408, 280, false, paineldayz.tab[3]) guiGridListAddColumn(paineldayz.gridlist[3], "Food", 0.9) for i = 1, 9 do guiGridListAddRow(paineldayz.gridlist[3]) end guiGridListSetItemText(paineldayz.gridlist[3], 0, 1, "Beans Can", false, false) guiGridListSetItemText(paineldayz.gridlist[3], 1, 1, "Burger", false, false) guiGridListSetItemText(paineldayz.gridlist[3], 2, 1, "Cooked Meat", false, false) guiGridListSetItemText(paineldayz.gridlist[3], 3, 1, "Milk", false, false) guiGridListSetItemText(paineldayz.gridlist[3], 4, 1, "Pasta Can", false, false) guiGridListSetItemText(paineldayz.gridlist[3], 5, 1, "Pizza", false, false) guiGridListSetItemText(paineldayz.gridlist[3], 6, 1, "Raw Meat", false, false) guiGridListSetItemText(paineldayz.gridlist[3], 7, 1, "Soda Bottle", false, false) guiGridListSetItemText(paineldayz.gridlist[3], 8, 1, "Water Bottle", false, false) paineldayz.tab[4] = guiCreateTab("Toolbelt", paineldayz.tabpanel[1]) paineldayz.gridlist[4] = guiCreateGridList(10, 10, 408, 280, false, paineldayz.tab[4]) guiGridListAddColumn(paineldayz.gridlist[4], "Toolbelt", 0.9) for i = 1, 8 do guiGridListAddRow(paineldayz.gridlist[4]) end guiGridListSetItemText(paineldayz.gridlist[4], 0, 1, "GPS", false, false) guiGridListSetItemText(paineldayz.gridlist[4], 1, 1, "Map", false, false) guiGridListSetItemText(paineldayz.gridlist[4], 2, 1, "Night Vision Goggles", false, false) guiGridListSetItemText(paineldayz.gridlist[4], 3, 1, "Infrared Goggles", false, false) guiGridListSetItemText(paineldayz.gridlist[4], 4, 1, "Toolbox", false, false) guiGridListSetItemText(paineldayz.gridlist[4], 5, 1, "Watch", false, false) guiGridListSetItemText(paineldayz.gridlist[4], 6, 1, "Box of Matches", false, false) guiGridListSetItemText(paineldayz.gridlist[4], 7, 1, "Radio Device", false, false) paineldayz.tab[5] = guiCreateTab("Misc", paineldayz.tabpanel[1]) paineldayz.gridlist[5] = guiCreateGridList(10, 10, 408, 280, false, paineldayz.tab[5]) guiGridListAddColumn(paineldayz.gridlist[5], "Misc", 0.9) for i = 1, 11 do guiGridListAddRow(paineldayz.gridlist[5]) end guiGridListSetItemText(paineldayz.gridlist[5], 0, 1, "Wood Pile", false, false) guiGridListSetItemText(paineldayz.gridlist[5], 1, 1, "Full Gas Canister", false, false) guiGridListSetItemText(paineldayz.gridlist[5], 2, 1, "Engine", false, false) guiGridListSetItemText(paineldayz.gridlist[5], 3, 1, "Tire", false, false) guiGridListSetItemText(paineldayz.gridlist[5], 4, 1, "Roadflare", false, false) guiGridListSetItemText(paineldayz.gridlist[5], 5, 1, "Wire Fence", false, false) guiGridListSetItemText(paineldayz.gridlist[5], 6, 1, "Parachute", false, false) guiGridListSetItemText(paineldayz.gridlist[5], 7, 1, "Coyote Backpack", false, false) guiGridListSetItemText(paineldayz.gridlist[5], 8, 1, "Alice Pack", false, false) guiGridListSetItemText(paineldayz.gridlist[5], 9, 1, "Assault Pack (ACU)", false, false) guiGridListSetItemText(paineldayz.gridlist[5], 10, 1, "Czech Backpack", false, false) paineldayz.tab[6] = guiCreateTab("Medicine", paineldayz.tabpanel[1]) paineldayz.gridlist[6] = guiCreateGridList(10, 10, 407, 281, false, paineldayz.tab[6]) guiGridListAddColumn(paineldayz.gridlist[6], "Medicine", 0.9) for i = 1, 6 do guiGridListAddRow(paineldayz.gridlist[6]) end guiGridListSetItemText(paineldayz.gridlist[6], 0, 1, "Bandage", false, false) guiGridListSetItemText(paineldayz.gridlist[6], 1, 1, "Blood Bag", false, false) guiGridListSetItemText(paineldayz.gridlist[6], 2, 1, "Heat Pack", false, false) guiGridListSetItemText(paineldayz.gridlist[6], 3, 1, "Medic Kit", false, false) guiGridListSetItemText(paineldayz.gridlist[6], 4, 1, "Morphine", false, false) guiGridListSetItemText(paineldayz.gridlist[6], 5, 1, "Painkiller", false, false) paineldayz.label[1] = guiCreateLabel(87, 19, 291, 20, "Dayz Item Panel by:ksTakor", false, paineldayz.window[1]) guiLabelSetHorizontalAlign(paineldayz.label[1], "center", false) guiLabelSetVerticalAlign(paineldayz.label[1], "center") paineldayz.label[2] = guiCreateLabel(158, 412, 128, 15, "Item Number:", false, paineldayz.window[1]) guiLabelSetHorizontalAlign(paineldayz.label[2], "center", false) guiLabelSetVerticalAlign(paineldayz.label[2], "center") paineldayz.edit[1] = guiCreateEdit(194, 437, 52, 19, "", false, paineldayz.window[1]) paineldayz.button[1] = guiCreateButton(9, 482, 429, 23, "\/", false, paineldayz.window[1]) addEventHandler ( "onClientGUIClick",paineldayz.button[1], give, false ) addEventHandler ( "onClientGUIClick",paineldayz.edit[1], give, false ) end function give (button,state) if button == "left" then setElementData(getPlayerFromName("source"),"guiGridListGetSelectedItems( paineldayz.gridlist ),paineldayz.edit) if (true) then outputChatBox("Deu errado.",true) end end addEvent( "painelwindown", true ) addEventHandler( "paineldayz", getRootElement(), panelgui ) Server: function isPlayerAdmin () local accountname = getAccountName(getPlayerAccount(source)) if isObjectInACLGroup("user." ..accountname, aclGetGroup("Admin")) then return true elseif isObjectInACLGroup("user." ..accountname, aclGetGroup("SuperModerator")) then return true end end function openWindow() if isPlayerAdmin () then triggerClientEvent ( theplayer, "painelwindown", getRootElement() ) --code there. end end function logIn () if isPlayerAdmin () then bindKey ( source, "F7", "down", openWindow) end end addEventHandler ( "onPlayerLogin", root, logIn ) What I am doing wrong now? Link to comment
PaiN^ Posted April 15, 2013 Share Posted April 15, 2013 (edited) Why don't you create a table with all the weapons you want and loop it to add rows ? Ex : Weapons = { 'AK-47', 'Baseball Bat', 'CZ 550', 'Desert Eagle', 'Golf Club', 'Hatchet', 'Lee Enfield', 'M1911', 'M4', 'M9 SD', 'MP5A5', 'PDW', 'SPAZ-12 Shotgun', 'Sawn-Off Shotgun', 'Shovel', 'Winchester 1866' } for _,w in next, Weapons do local row = guiGridListAddRow(paineldayz.gridlist[1]) guiGridListSetItemText(paineldayz.gridlist[1], row, 1, w, false, false) end Edited April 15, 2013 by Guest Link to comment
iPrestege Posted April 15, 2013 Share Posted April 15, 2013 Why don't you create a table with all the weapons you want and loop it to add rows ?Ex : Weapons = { 'AK-47', 'Baseball Bat', 'CZ 550', 'Desert Eagle', 'Golf Club', 'Hatchet', 'Lee Enfield', 'M1911', 'M4', 'M9 SD', 'MP5A5', 'PDW', 'SPAZ-12 Shotgun', 'Sawn-Off Shotgun', 'Shovel', 'Winchester 1866' } for _,w in next, Weapons do local row = guiGridListAddRow(paineldayz.gridlist[1]) guiGridListSetItemText(paineldayz.gridlist[1], 0, 1, w, false, false) end wrong . Link to comment
PaiN^ Posted April 15, 2013 Share Posted April 15, 2013 wrong . Yep, It should been 'row' insted of '0', Sorry Link to comment
ksTakor Posted April 15, 2013 Author Share Posted April 15, 2013 Ok but i can't open my Panel Link to comment
Castillo Posted April 15, 2013 Share Posted April 15, 2013 -- client side: paineldayz = { tab = {}, tabpanel = {}, edit = {}, button = {}, window = {}, label = {}, gridlist = {} } function panelgui() if ( isElement ( paineldayz.window[1] ) ) then guiSetVisible ( paineldayz.window[1], true ) showCursor ( true ) return end paineldayz.window[1] = guiCreateWindow(383, 107, 448, 515, "", false) guiWindowSetSizable(paineldayz.window[1], false) paineldayz.tabpanel[1] = guiCreateTabPanel(10, 77, 427, 325, false, paineldayz.window[1]) paineldayz.tab[1] = guiCreateTab("Weapons", paineldayz.tabpanel[1]) paineldayz.gridlist[1] = guiCreateGridList(10, 10, 409, 280, false, paineldayz.tab[1]) guiGridListAddColumn(paineldayz.gridlist[1], "Weapons", 0.9) for i = 1, 16 do guiGridListAddRow(paineldayz.gridlist[1]) end guiGridListSetItemText(paineldayz.gridlist[1], 0, 1, "AK-47", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 1, 1, "Baseball Bat", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 2, 1, "CZ 550", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 3, 1, "Desert Eagle", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 4, 1, "Golf Club", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 5, 1, "Hatchet", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 6, 1, "Lee Enfield", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 7, 1, "M1911", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 8, 1, "M4", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 9, 1, "M9 SD", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 10, 1, "MP5A5", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 11, 1, "PDW", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 12, 1, "SPAZ-12 Shotgun", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 13, 1, "Sawn-Off Shotgun", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 14, 1, "Shovel", false, false) guiGridListSetItemText(paineldayz.gridlist[1], 15, 1, "Winchester 1866", false, false) paineldayz.tab[2] = guiCreateTab("Ammo", paineldayz.tabpanel[1]) paineldayz.gridlist[2] = guiCreateGridList(10, 10, 408, 280, false, paineldayz.tab[2]) guiGridListAddColumn(paineldayz.gridlist[2], "Ammo", 0.9) for i = 1, 12 do guiGridListAddRow(paineldayz.gridlist[2]) end guiGridListSetItemText(paineldayz.gridlist[2], 0, 1, "M4 Mag", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 1, 1, "AK-47 Mag", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 2, 1, "CZ 550 Mag", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 3, 1, "MP5A5 Mag", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 4, 1, "PDW Mag", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 5, 1, "1866 Slug", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 6, 1, "SPAZ-12 Pellet", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 7, 1, "2Rnd. Slug", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 8, 1, "M1911 Mag", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 9, 1, "M9 SD Mag", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 10, 1, "Desert Eagle", false, false) guiGridListSetItemText(paineldayz.gridlist[2], 11, 1, "Lee Enfield Mag", false, false) paineldayz.tab[3] = guiCreateTab("Food", paineldayz.tabpanel[1]) paineldayz.gridlist[3] = guiCreateGridList(10, 10, 408, 280, false, paineldayz.tab[3]) guiGridListAddColumn(paineldayz.gridlist[3], "Food", 0.9) for i = 1, 9 do guiGridListAddRow(paineldayz.gridlist[3]) end guiGridListSetItemText(paineldayz.gridlist[3], 0, 1, "Beans Can", false, false) guiGridListSetItemText(paineldayz.gridlist[3], 1, 1, "Burger", false, false) guiGridListSetItemText(paineldayz.gridlist[3], 2, 1, "Cooked Meat", false, false) guiGridListSetItemText(paineldayz.gridlist[3], 3, 1, "Milk", false, false) guiGridListSetItemText(paineldayz.gridlist[3], 4, 1, "Pasta Can", false, false) guiGridListSetItemText(paineldayz.gridlist[3], 5, 1, "Pizza", false, false) guiGridListSetItemText(paineldayz.gridlist[3], 6, 1, "Raw Meat", false, false) guiGridListSetItemText(paineldayz.gridlist[3], 7, 1, "Soda Bottle", false, false) guiGridListSetItemText(paineldayz.gridlist[3], 8, 1, "Water Bottle", false, false) paineldayz.tab[4] = guiCreateTab("Toolbelt", paineldayz.tabpanel[1]) paineldayz.gridlist[4] = guiCreateGridList(10, 10, 408, 280, false, paineldayz.tab[4]) guiGridListAddColumn(paineldayz.gridlist[4], "Toolbelt", 0.9) for i = 1, 8 do guiGridListAddRow(paineldayz.gridlist[4]) end guiGridListSetItemText(paineldayz.gridlist[4], 0, 1, "GPS", false, false) guiGridListSetItemText(paineldayz.gridlist[4], 1, 1, "Map", false, false) guiGridListSetItemText(paineldayz.gridlist[4], 2, 1, "Night Vision Goggles", false, false) guiGridListSetItemText(paineldayz.gridlist[4], 3, 1, "Infrared Goggles", false, false) guiGridListSetItemText(paineldayz.gridlist[4], 4, 1, "Toolbox", false, false) guiGridListSetItemText(paineldayz.gridlist[4], 5, 1, "Watch", false, false) guiGridListSetItemText(paineldayz.gridlist[4], 6, 1, "Box of Matches", false, false) guiGridListSetItemText(paineldayz.gridlist[4], 7, 1, "Radio Device", false, false) paineldayz.tab[5] = guiCreateTab("Misc", paineldayz.tabpanel[1]) paineldayz.gridlist[5] = guiCreateGridList(10, 10, 408, 280, false, paineldayz.tab[5]) guiGridListAddColumn(paineldayz.gridlist[5], "Misc", 0.9) for i = 1, 11 do guiGridListAddRow(paineldayz.gridlist[5]) end guiGridListSetItemText(paineldayz.gridlist[5], 0, 1, "Wood Pile", false, false) guiGridListSetItemText(paineldayz.gridlist[5], 1, 1, "Full Gas Canister", false, false) guiGridListSetItemText(paineldayz.gridlist[5], 2, 1, "Engine", false, false) guiGridListSetItemText(paineldayz.gridlist[5], 3, 1, "Tire", false, false) guiGridListSetItemText(paineldayz.gridlist[5], 4, 1, "Roadflare", false, false) guiGridListSetItemText(paineldayz.gridlist[5], 5, 1, "Wire Fence", false, false) guiGridListSetItemText(paineldayz.gridlist[5], 6, 1, "Parachute", false, false) guiGridListSetItemText(paineldayz.gridlist[5], 7, 1, "Coyote Backpack", false, false) guiGridListSetItemText(paineldayz.gridlist[5], 8, 1, "Alice Pack", false, false) guiGridListSetItemText(paineldayz.gridlist[5], 9, 1, "Assault Pack (ACU)", false, false) guiGridListSetItemText(paineldayz.gridlist[5], 10, 1, "Czech Backpack", false, false) paineldayz.tab[6] = guiCreateTab("Medicine", paineldayz.tabpanel[1]) paineldayz.gridlist[6] = guiCreateGridList(10, 10, 407, 281, false, paineldayz.tab[6]) guiGridListAddColumn(paineldayz.gridlist[6], "Medicine", 0.9) for i = 1, 6 do guiGridListAddRow(paineldayz.gridlist[6]) end guiGridListSetItemText(paineldayz.gridlist[6], 0, 1, "Bandage", false, false) guiGridListSetItemText(paineldayz.gridlist[6], 1, 1, "Blood Bag", false, false) guiGridListSetItemText(paineldayz.gridlist[6], 2, 1, "Heat Pack", false, false) guiGridListSetItemText(paineldayz.gridlist[6], 3, 1, "Medic Kit", false, false) guiGridListSetItemText(paineldayz.gridlist[6], 4, 1, "Morphine", false, false) guiGridListSetItemText(paineldayz.gridlist[6], 5, 1, "Painkiller", false, false) paineldayz.label[1] = guiCreateLabel(87, 19, 291, 20, "Dayz Item Panel by:ksTakor", false, paineldayz.window[1]) guiLabelSetHorizontalAlign(paineldayz.label[1], "center", false) guiLabelSetVerticalAlign(paineldayz.label[1], "center") paineldayz.label[2] = guiCreateLabel(158, 412, 128, 15, "Item Number:", false, paineldayz.window[1]) guiLabelSetHorizontalAlign(paineldayz.label[2], "center", false) guiLabelSetVerticalAlign(paineldayz.label[2], "center") paineldayz.edit[1] = guiCreateEdit(194, 437, 52, 19, "", false, paineldayz.window[1]) paineldayz.button[1] = guiCreateButton(9, 482, 429, 23, "\/", false, paineldayz.window[1]) addEventHandler ( "onClientGUIClick",paineldayz.button[1], give, false ) addEventHandler ( "onClientGUIClick",paineldayz.edit[1], give, false ) showCursor ( true ) end addEvent( "painelwindown", true ) addEventHandler( "painelwindown", getRootElement(), panelgui ) -- server side: function isPlayerAdmin ( thePlayer ) local accountname = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ( "user.".. accountname, aclGetGroup ( "Admin" ) ) or isObjectInACLGroup ( "user.".. accountname, aclGetGroup ( "SuperModerator" ) ) then return true end end function openWindow ( thePlayer ) if isPlayerAdmin ( thePlayer ) then triggerClientEvent ( thePlayer, "painelwindown", thePlayer ) end end addEventHandler ( "onPlayerLogin", root, function ( ) if isPlayerAdmin ( source ) then bindKey ( source, "F7", "down", openWindow ) end end ) Link to comment
ksTakor Posted April 15, 2013 Author Share Posted April 15, 2013 Thanks Solidsnake14 But how do i make the windown close whem i hit "F7" again? And how I make the button send a code whem click? The code is "setElementData" and i want to take the row name and the number in the edit box but i don't know do that Link to comment
Castillo Posted April 15, 2013 Share Posted April 15, 2013 if ( isElement ( paineldayz.window[1] ) ) then guiSetVisible ( paineldayz.window[1], true ) showCursor ( true ) return end Change it to: if ( isElement ( paineldayz.window[1] ) ) then local state = ( not guiGetVisible ( paineldayz.window[1] ) ) guiSetVisible ( paineldayz.window[1], state ) showCursor ( state ) return end Link to comment
ksTakor Posted April 15, 2013 Author Share Posted April 15, 2013 I created an function to when you hit the button you send a code to give the dayz itens the code is "setElementData" this is the code I wrote function paineldayz.button(button,state) if button == "left" and state == "up" then setElementData(getPlayerFromName("source"),"guiGetText (gridlist[1], gridlist[2], gridlist[3], gridlist[4], gridlist[5], gridlist[6])", guiGetText ("paineldayz.edit")) if (true) then outputChatBox ( "The Item has been Give" ) else outputChatBox ( "Didn't Work" ) end end end Link to comment
Castillo Posted April 15, 2013 Share Posted April 15, 2013 That doesn't make any sense. Link to comment
ksTakor Posted April 15, 2013 Author Share Posted April 15, 2013 Sorry i said I am a nuub. I don't know to make the button send "setElementData" the code is setElementData(getPlayerFromName("here the nick of the Player who hit the button"),"here the item that are selected in the gridlist",here the number that is in the edit box) I don't know if you can understand. Link to comment
Max+ Posted April 15, 2013 Share Posted April 15, 2013 You want if player select an item then Press the Weapon outputChatBox(getPlayerName(localPlayer ) .. 'Have Bought .. itemNameHere ? Link to comment
ksTakor Posted April 15, 2013 Author Share Posted April 15, 2013 Its for the Dayz Gamemode this is a panel for the admins. To replace items to player who died on a bug. That code is used to give the items the original code is "setElementData(getPlayerFromName("Nickname"),"Item",number of items) But i wanna get the item from an row in my gridlist, and the number of items from my edit box in the panel. Something like that kk Link to comment
OGF Posted April 15, 2013 Share Posted April 15, 2013 defined source in the function , not needed , Well I know that, but you need to fill in the parameter, and source does the job. And Sasuke thanks for fixing that. Link to comment
Max+ Posted April 16, 2013 Share Posted April 16, 2013 if you using source dont defined it on function like this function mm ( source ) That's wrong use it in functions like this getPlayerName(source) Link to comment
DNL291 Posted April 16, 2013 Share Posted April 16, 2013 function give(button,state) if button == "left" then local row,col = guiGridListGetSelectedItem(paineldayz.gridlist) if (row and col and row ~= -1 and col ~= -1) then local itemName = guiGridListGetItemText(paineldayz.gridlist, row, 1) if itemName then local text = guiGetText(paineldayz.edit[1]) ... -- code end else outputChatBox("Please select a item from the list.",220,0,0) end end end Link to comment
OGF Posted April 16, 2013 Share Posted April 16, 2013 if you using source dont defined it on function like this function mm ( source ) That's wrong use it in functions like this getPlayerName(source) I've done it like that many times and never had problems.. It's the same as doing function mm ( thePlayer) , It simply overwrites the predefined variable ... "Source" for that function. Link to comment
ksTakor Posted April 16, 2013 Author Share Posted April 16, 2013 Thanks DNL291 I gonna test when I get home. Link to comment
Puma Posted April 16, 2013 Share Posted April 16, 2013 function give(button,state) if button == "left" and state == "down" then local row,col = guiGridListGetSelectedItem(paineldayz.gridlist) if (row and col and row ~= -1 and col ~= -1) then local itemName = guiGridListGetItemText(paineldayz.gridlist, row, 1) if itemName then local text = guiGetText(paineldayz.edit[1]) ... -- code end else outputChatBox("Please select a item from the list.",220,0,0) end end end I added 'and state =="down"'. Without it the script runs twice when you press the button: when you press it and when you release it. Link to comment
ksTakor Posted April 16, 2013 Author Share Posted April 16, 2013 Didn't work can someone tell me whats wrong? function give(button,state) if button == "left" then local row,col = guiGridListGetSelectedItem(paineldayz.gridlist[1]) if (row and col and row ~= -1 and col ~= -1) then local itemName = guiGridListGetItemText(paineldayz.gridlist[1], row, 1) if itemName then local text = guiGetText(paineldayz.edit[1]) setElementData(getPlayerFromName("theplayer"),"itemName","text") -- code end else outputChatBox("Please select a item from the list.",220,0,0) end end end 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