-.Paradox.- Posted March 30, 2014 Share Posted March 30, 2014 Hello guys, I decided to make a Staff Panel, and it's working very good, The thing that i don't know how to use is how to get Selected Player info like example health and armor etc.. Thanks for help. Link to comment
WhoAmI Posted March 30, 2014 Share Posted March 30, 2014 If your gridlist is full of player's names just use getPlayerFromName And then getElementHealth etc. Link to comment
-.Paradox.- Posted March 30, 2014 Author Share Posted March 30, 2014 Like this? But i think i need to create manually a row every player, can you see what's wrong with it please addEventHandler("onClientGUIClick", guiRoot, function(player) thePlayer = getPlayerFromName(source) if thePlayer then if source == GUIEditor.label[1] then local row = guiGridListGetSelectedItem(GUIEditor.gridlist[1]) if row == 0 then getElementHealth(thePlayer) end end end) Link to comment
WhoAmI Posted March 30, 2014 Share Posted March 30, 2014 Lol, no. For example gridlist = guiCreateGridList ( .. ) column = guiGridListAddColumn ( .. ) for _, player in ipairs ( getElementsByType ( "player" ) ) do local row = guiGridListAddRow ( gridlist ) guiGridListSetItemText ( gridlist, row, column, getPlayerName ( player ), false, false ) end And then get it by using local itemtext = guiGridListGetItemText ( gridlist, guiGridListGetSelectedItem ( gridlist ), column ) local player = getPlayerFromName ( itemtext ) Link to comment
-.Paradox.- Posted March 30, 2014 Author Share Posted March 30, 2014 I did not understand, I want to output player health into a label, i already looped players in the gridlist GUIEditor.label[1] Link to comment
-.Paradox.- Posted March 30, 2014 Author Share Posted March 30, 2014 Here is my code, and sorry i still don't know how to use it I want it to output the (Selected Gridlist player) health in this format GUIEditor.label[5] = guiCreateLabel(196, 225, 269, 15, "Health"..health, false, GUIEditor.window[1]) Can you help me if it's possible? function toggleStaff( source ) -- Show the panel if not guiGetVisible( GUIEditor.window[1] ) then showCursor ( true ) guiSetVisible( GUIEditor.window[1], true ) -- Update player list guiGridListClear ( GUIEditor.gridlist[1] ) if ( column ) then for id, player in ipairs(getElementsByType("player")) do local row = guiGridListAddRow ( GUIEditor.gridlist[1] ) guiGridListSetItemText ( GUIEditor.gridlist[1], row, column, getPlayerName ( player ), false, false ) guiGridListSetItemText(GUIEditor.gridlist[1], row, 2,GUIEditor.label[5] ~= "" and getElementHealth(localPlayer) or "", false, false) local itemtext = guiGridListGetItemText ( gridlist, guiGridListGetSelectedItem ( gridlist ), column ) local player = getPlayerFromName ( itemtext ) end end else showCursor ( false ) guiSetVisible( GUIEditor.window[1], false ) end end bindKey( "M", "down", toggleStaff ) addCommandHandler("staff", toggleStaff) Link to comment
WhoAmI Posted March 30, 2014 Share Posted March 30, 2014 Your code is a mess. local itemtext = guiGridListGetItemText ( gridlist, guiGridListGetSelectedItem ( gridlist ), column ) local player = getPlayerFromName ( itemtext ) local health = getElementHealth ( player ) guiSetText ( some_label, health ) It should looks like it. And it should be executed when player clicks on gridlist. Link to comment
-.Paradox.- Posted March 30, 2014 Author Share Posted March 30, 2014 Can i use GUIEditor.label[5] = guiCreateLabel(196, 225, 269, 15, "Health"..health, false, GUIEditor.window[1]) instead of guiSetText? Link to comment
Jaysds1 Posted March 30, 2014 Share Posted March 30, 2014 (edited) Try this: for _,v in ipairs(getElementsByType("player"))do local row = guiGridListAddRow(GUIEditor.gridlist[1]) local playerName = getPlayerName(v) guiGridListSetItemText(GUIEditor.gridlist[1],row,1,playerName,false,false) end addEventHandler("onClientGUIClick",GUIEditor.gridlist[1], function(b) if b ~= "left" then return end local row,column = guiGridListGetSelectedItem(source) if row == -1 then return end local playerName = guiGridListGetItemText(GUIEditor.gridlist[1],row,column) local player = getPlayerFromName(playerName) if not playerName then guiGridListRemoveRow(row) return end local playerHealth = getElementHealth(player) local playerArmour = getPedArmor(player) end end,false) Edited March 30, 2014 by Guest Link to comment
-.Paradox.- Posted March 30, 2014 Author Share Posted March 30, 2014 I'm trying to output the selected player health into a label (like the Admin panel stuff) Link to comment
Jaysds1 Posted March 30, 2014 Share Posted March 30, 2014 You could still use the code I've posted above, but you would need to add the guiSetText for the labels you would like to change. Link to comment
-.Paradox.- Posted March 30, 2014 Author Share Posted March 30, 2014 ')' expected to close '(' at line 85 near end I will send you my full code in pm 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