mjau Posted August 20, 2011 Posted August 20, 2011 Hi i have a gui and i wondered how i can fill the first gridlist in it with all the players on the server how to do this Heres my gui GUIEditor_Window = {} GUIEditor_TabPanel = {} GUIEditor_Tab = {} GUIEditor_Button = {} GUIEditor_Label = {} GUIEditor_Grid = {} GUIEditor_Window[1] = guiCreateWindow(375,372,425,235,"Army Ranger Tools",false) GUIEditor_TabPanel[1] = guiCreateTabPanel(9,20,407,206,false,GUIEditor_Window[1]) GUIEditor_Tab[1] = guiCreateTab("EMP",GUIEditor_TabPanel[1]) GUIEditor_Grid[1] = guiCreateGridList(3,4,164,175,false,GUIEditor_Tab[1]) guiGridListSetSelectionMode(GUIEditor_Grid[1],2) guiGridListAddColumn(GUIEditor_Grid[1],"Players",0.2) GUIEditor_Button[1] = guiCreateButton(171,11,93,36,"EMP Him",false,GUIEditor_Tab[1]) GUIEditor_Button[2] = guiCreateButton(171,54,93,35,"Spectate",false,GUIEditor_Tab[1]) GUIEditor_Label[1] = guiCreateLabel(271,58,116,31,"To check if right person",false,GUIEditor_Tab[1]) guiLabelSetColor(GUIEditor_Label[1],255,255,255) guiLabelSetVerticalAlign(GUIEditor_Label[1],"top") guiLabelSetHorizontalAlign(GUIEditor_Label[1],"left",true) GUIEditor_Tab[2] = guiCreateTab("Equipment",GUIEditor_TabPanel[1]) GUIEditor_Button[3] = guiCreateButton(2,2,96,40,"Tazer",false,GUIEditor_Tab[2]) GUIEditor_Button[4] = guiCreateButton(102,3,96,40,"Parachute",false,GUIEditor_Tab[2]) GUIEditor_Button[5] = guiCreateButton(203,4,96,40,"Nightvision",false,GUIEditor_Tab[2]) GUIEditor_Button[6] = guiCreateButton(302,5,96,40,"Infrared",false,GUIEditor_Tab[2]) GUIEditor_Tab[3] = guiCreateTab("Others",GUIEditor_TabPanel[1]) GUIEditor_Grid[2] = guiCreateGridList(2,3,132,174,false,GUIEditor_Tab[3]) guiGridListSetSelectionMode(GUIEditor_Grid[2],2) guiGridListAddColumn(GUIEditor_Grid[2],"Players",0.2) GUIEditor_Button[7] = guiCreateButton(135,8,96,36,"Deport From A69",false,GUIEditor_Tab[3])
JR10 Posted August 20, 2011 Posted August 20, 2011 for index, player in ipairs ( getElementsByType ( "player" ) ) do local row = guiGridListAddRow ( GUIEditor_Grid[1] ) guiGridListSetItemText ( GUIEditor_Grid[1] , row , 1 , getPlayerName ( player ) , false , false ) end
mjau Posted August 20, 2011 Author Posted August 20, 2011 Tnx now i have a new problem how can i make it set the engine state off on the selcted player wehn i clcik a button ? This is my code GUIEditor_Window = {} GUIEditor_TabPanel = {} GUIEditor_Tab = {} GUIEditor_Button = {} GUIEditor_Label = {} GUIEditor_Grid = {} function gui() showCursor ( true ) GUIEditor_Window[1] = guiCreateWindow(380,328,425,274,"Army Ranger Tools",false) GUIEditor_TabPanel[1] = guiCreateTabPanel(9,20,407,206,false,GUIEditor_Window[1]) GUIEditor_Tab[1] = guiCreateTab("EMP",GUIEditor_TabPanel[1]) GUIEditor_Grid[1] = guiCreateGridList(3,4,164,175,false,GUIEditor_Tab[1]) guiGridListSetSelectionMode(GUIEditor_Grid[1],2) guiGridListAddColumn(GUIEditor_Grid[1],"Players",0.2) GUIEditor_Button[1] = guiCreateButton(171,11,93,36,"EMP Him",false,GUIEditor_Tab[1]) GUIEditor_Button[2] = guiCreateButton(171,54,93,35,"Spectate",false,GUIEditor_Tab[1]) GUIEditor_Label[1] = guiCreateLabel(271,58,116,31,"To check if right person",false,GUIEditor_Tab[1]) guiLabelSetColor(GUIEditor_Label[1],255,255,255) guiLabelSetVerticalAlign(GUIEditor_Label[1],"top") guiLabelSetHorizontalAlign(GUIEditor_Label[1],"left",false) GUIEditor_Button[3] = guiCreateButton(171,92,93,35,"Refresh",false,GUIEditor_Tab[1]) GUIEditor_Label[2] = guiCreateLabel(268,96,120,29,"Refresh the playerlist",false,GUIEditor_Tab[1]) guiLabelSetColor(GUIEditor_Label[2],255,255,255) guiLabelSetVerticalAlign(GUIEditor_Label[2],"top") guiLabelSetHorizontalAlign(GUIEditor_Label[2],"left",true) GUIEditor_Tab[2] = guiCreateTab("Equipment",GUIEditor_TabPanel[1]) GUIEditor_Button[4] = guiCreateButton(2,2,96,40,"Tazer",false,GUIEditor_Tab[2]) GUIEditor_Button[5] = guiCreateButton(102,3,96,40,"Parachute",false,GUIEditor_Tab[2]) GUIEditor_Button[6] = guiCreateButton(203,4,96,40,"Nightvision",false,GUIEditor_Tab[2]) GUIEditor_Button[7] = guiCreateButton(302,5,96,40,"Infrared",false,GUIEditor_Tab[2]) GUIEditor_Button[8] = guiCreateButton(2,47,96,40,"Nightstick",false,GUIEditor_Tab[2]) GUIEditor_Tab[3] = guiCreateTab("Others",GUIEditor_TabPanel[1]) GUIEditor_Grid[2] = guiCreateGridList(2,3,132,174,false,GUIEditor_Tab[3]) guiGridListSetSelectionMode(GUIEditor_Grid[2],2) guiGridListAddColumn(GUIEditor_Grid[2],"Players",0.2) GUIEditor_Button[9] = guiCreateButton(135,8,96,36,"Deport From A69",false,GUIEditor_Tab[3]) GUIEditor_Button[10] = guiCreateButton(16,233,393,32,"Close me",false,GUIEditor_Window[1]) addEventHandler("onClientGUIClick", GUIEditor_Button[3], findplayers, false) end addCommandHandler("tools", gui) function findplayers() guiGridListClear ( GUIEditor_Grid[1] ) for index, player in ipairs ( getElementsByType ( "player" ) ) do local row = guiGridListAddRow ( GUIEditor_Grid[1] ) guiGridListSetItemText ( GUIEditor_Grid[1] , row , 1 , getPlayerName ( player ) , false , false ) end end
Castillo Posted August 21, 2011 Posted August 21, 2011 -- client side: GUIEditor_Window = {} GUIEditor_TabPanel = {} GUIEditor_Tab = {} GUIEditor_Button = {} GUIEditor_Label = {} GUIEditor_Grid = {} function gui() showCursor ( true ) GUIEditor_Window[1] = guiCreateWindow(380,328,425,274,"Army Ranger Tools",false) GUIEditor_TabPanel[1] = guiCreateTabPanel(9,20,407,206,false,GUIEditor_Window[1]) GUIEditor_Tab[1] = guiCreateTab("EMP",GUIEditor_TabPanel[1]) GUIEditor_Grid[1] = guiCreateGridList(3,4,164,175,false,GUIEditor_Tab[1]) guiGridListSetSelectionMode(GUIEditor_Grid[1],2) guiGridListAddColumn(GUIEditor_Grid[1],"Players",0.2) GUIEditor_Button[1] = guiCreateButton(171,11,93,36,"EMP Him",false,GUIEditor_Tab[1]) GUIEditor_Button[2] = guiCreateButton(171,54,93,35,"Spectate",false,GUIEditor_Tab[1]) GUIEditor_Label[1] = guiCreateLabel(271,58,116,31,"To check if right person",false,GUIEditor_Tab[1]) guiLabelSetColor(GUIEditor_Label[1],255,255,255) guiLabelSetVerticalAlign(GUIEditor_Label[1],"top") guiLabelSetHorizontalAlign(GUIEditor_Label[1],"left",false) GUIEditor_Button[3] = guiCreateButton(171,92,93,35,"Refresh",false,GUIEditor_Tab[1]) GUIEditor_Label[2] = guiCreateLabel(268,96,120,29,"Refresh the playerlist",false,GUIEditor_Tab[1]) guiLabelSetColor(GUIEditor_Label[2],255,255,255) guiLabelSetVerticalAlign(GUIEditor_Label[2],"top") guiLabelSetHorizontalAlign(GUIEditor_Label[2],"left",true) GUIEditor_Tab[2] = guiCreateTab("Equipment",GUIEditor_TabPanel[1]) GUIEditor_Button[4] = guiCreateButton(2,2,96,40,"Tazer",false,GUIEditor_Tab[2]) GUIEditor_Button[5] = guiCreateButton(102,3,96,40,"Parachute",false,GUIEditor_Tab[2]) GUIEditor_Button[6] = guiCreateButton(203,4,96,40,"Nightvision",false,GUIEditor_Tab[2]) GUIEditor_Button[7] = guiCreateButton(302,5,96,40,"Infrared",false,GUIEditor_Tab[2]) GUIEditor_Button[8] = guiCreateButton(2,47,96,40,"Nightstick",false,GUIEditor_Tab[2]) GUIEditor_Tab[3] = guiCreateTab("Others",GUIEditor_TabPanel[1]) GUIEditor_Grid[2] = guiCreateGridList(2,3,132,174,false,GUIEditor_Tab[3]) guiGridListSetSelectionMode(GUIEditor_Grid[2],2) guiGridListAddColumn(GUIEditor_Grid[2],"Players",0.2) GUIEditor_Button[9] = guiCreateButton(135,8,96,36,"Deport From A69",false,GUIEditor_Tab[3]) GUIEditor_Button[10] = guiCreateButton(16,233,393,32,"Close me",false,GUIEditor_Window[1]) addEventHandler("onClientGUIClick", GUIEditor_Button[3], findplayers, false) addEventHandler("onClientGUIClick", GUIEditor_Button[1], turnEngine, false) end addCommandHandler("tools", gui) function turnEngine() local row,col = guiGridListGetSelectedItem(GUIEditor_Grid[1]) if row and col and row ~= -1 and col ~= -1 then local playerName = guiGridListGetItemText(GUIEditor_Grid[1], row, col) local player = getPlayerFromName(playerName) if player then if isPedInVehicle(player) then triggerServerEvent("turnEngineOff",getLocalPlayer(),player) end end end end function findplayers() guiGridListClear ( GUIEditor_Grid[1] ) for index, player in ipairs ( getElementsByType ( "player" ) ) do local row = guiGridListAddRow ( GUIEditor_Grid[1] ) guiGridListSetItemText ( GUIEditor_Grid[1] , row , 1 , getPlayerName ( player ) , false , false ) end end -- server side addEvent("turnEngineOff",true) addEventHandler("turnEngineOff",root, function (player) local vehicle = getPedOccupiedVehicle(player) setVehicleEngineState(vehicle, false) end) I haven't tested it.
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