LabiVila Posted July 25, 2014 Share Posted July 25, 2014 Hello all, I won't post all the script because I think it's not useful, I've got the button here and: client-side yourname = getPlayerName (getLocalPlayer()) challb = guiCreateButton (0.65, 0.80, 0.30, 0.15, "Challenge", true, PVPw) function buttonCLICK (button) if (button == "left") then triggerServerEvent ("message", localPlayer, yourname , buttonCLICK) end end addEventHandler ("onClientGUIClick", challb, buttonCLICK, false)) how should I do that when I click the challb button, a server-side message appears to everyone in the server saying anything (not important) ? I know it's somehow with triggerServer/ClientEvent but not sure how to use it. I'd be grateful if someone writes the full script. Link to comment
Bonsai Posted July 25, 2014 Share Posted July 25, 2014 It would be bad if some writes the full script. You would copy and paste and come back tomorrow with another question. In this case I guess you have to trigger a server event that calls a function and in that function you trigger a client event for all clients. Check the wiki, there are some examples. Link to comment
LabiVila Posted July 25, 2014 Author Share Posted July 25, 2014 Yea managed to solve that one, thanks, by trying myself is better. What about this one? function playerList () local playerList = guiCreateGridList (0.10, 0.10, 0.50, 0.85, true, PVPw) local column = guiGridListAddColumn (playerList, "Player", 0.85) if (column) then for id, playeritem in ipairs (getElementsByType ("player")) do local row = guiGridListAddRow (playerList) guiGridListSetItemText (playerList, row, column, getPlayerName (playeritem), false, false) end end end addEventHandler ("onClientResourceStart", getRootElement(), playerList) how can I get the clicked player's name and put it to outputChatBox? https://wiki.multitheftauto.com/wiki/Gu ... etItemText I think it's this but it's honestly hard... I'd be grateful for any help (and any explanation) Link to comment
Bonsai Posted July 26, 2014 Share Posted July 26, 2014 guiGridListGetSelectedItem This function returns the row/column of the selected item. After that you just use guiGridListGetItemText. As you can see you need the row and column index there. If you only have one column this would be 1. The row is the one returned by the first function. Thats it basically. Link to comment
LabiVila Posted July 26, 2014 Author Share Posted July 26, 2014 Yea, it's easy for you but not for beginners like me. However, let's not cry, function playerList () local playerList = guiCreateGridList (0.10, 0.10, 0.50, 0.85, true, PVPw) local column = guiGridListAddColumn (playerList, "Player", 0.85) local asd = guiGridListGetItemText (playerList, column) if (column and asd) then for id, playeritem in ipairs (getElementsByType ("player")) do local row = guiGridListAddRow (playerList) guiGridListSetItemText (playerList, row, column, getPlayerName (playeritem), false, false) outputChatBox (""..asd.."") end end end addEventHandler ("onClientResourceStart", getRootElement(), playerList) The code might be confusing but.. I need a hand on it, what isn't working? The debugscript 3 says that it needs a number at line 22, and there's none. 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