FSXTim Posted May 27, 2012 Share Posted May 27, 2012 Hello, I created a gridlist, as you can see here: http://s14.directupload.net/file/d/2903/7fq2mslv_png.htm But how can I create a list of all player in it? Greets Link to comment
Alpha Posted May 27, 2012 Share Posted May 27, 2012 for index, player in pairs(getElementsByType("player")) do local row = guiGridListAddRow(gridlist) guiGridListSetItemText(gridlist, row, 1, getPlayerName(player), false, false) end Link to comment
FSXTim Posted May 27, 2012 Author Share Posted May 27, 2012 (edited) Thanks, that's working. One more question: How can I get the selected player (function/event)? Greets Edited May 27, 2012 by Guest Link to comment
Guest Guest4401 Posted May 27, 2012 Share Posted May 27, 2012 How can I get the selected player (function/event)? guiGridListGetSelectedItem guiGridListGetItemText getPlayerFromName -- to get player element from the selected item (string) Link to comment
FSXTim Posted May 27, 2012 Author Share Posted May 27, 2012 (edited) I don't know what do you exactly mean. Can you give me an example for my script, I have to make a meassage system. Greets Edited May 27, 2012 by Guest Link to comment
Smart. Posted May 27, 2012 Share Posted May 27, 2012 try: function whatever ( ) if ( source == yourGridVariable ) then row, col = guiGridListGetSelectedItem ( source ) if ( row and col and row ~= -1 and col ~= -1 ) then local playername = guiGridListGetItemText ( source, row, col ) local thePlayer = getPlayerFromName ( playername ) if ( thePlayer ) then --whatever end end end end addEventHandler ( "onClientGUIClick", root, whatever ) Link to comment
FSXTim Posted May 27, 2012 Author Share Posted May 27, 2012 Thanks, sir! I'm alone on my server, so I cannot test the script, is it correct? (!)clientside(!) function msgToPlayer (state) if state == "left" then if source == GUIEditor_ButtonSenden then row, col = guiGridListGetSelectedItem ( source ) if ( row and col and row ~= -1 and col ~= -1 ) then local playername = guiGridListGetItemText (GUIEditor_Grid[1], row, col) local targetPlayer = getPlayerFromName (playername) if targetPlayer then local localp = getLocalPlayer() local memoText = guiGetText(GUIEditor_MemoText) if memoText ~= "" and memoText:len() > 1 then outputChatBox("SMS von #FFFFFF"..localp..": #FF8C00"..memoText.."", targetPlayer, 255, 140, 0, true) else outputChatBox("Du hast keinen Text eingegeben!", 255, 48, 48) end end end end end end addEventHandler("onClientGUIClick", getRootElement(), msgToPlayer) Greets Link to comment
Guest Guest4401 Posted May 27, 2012 Share Posted May 27, 2012 It's not correct outputChatBox("SMS von #FFFFFF"..localp..": #FF8C00"..memoText.."", targetPlayer, 255, 140, 0, true) There is no visibleTo argument in outputChatBox if used clientside. Link to comment
FSXTim Posted May 27, 2012 Author Share Posted May 27, 2012 1. Okay, so I have to trigger it serverside? 2. The rest is correct? Greets Link to comment
FSXTim Posted May 27, 2012 Author Share Posted May 27, 2012 Thanks at all, the script is working, no errors! Greets 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