Bilal135 Posted September 11, 2015 Posted September 11, 2015 GUIEditor = { gridlist = {}, window = {}, button = {} } addEventHandler("onClientResourceStart", root, function() GUIEditor.window[1] = guiCreateWindow(552, 217, 275, 289, "Important People", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetVisible(GUIEditor.window[1], false) GUIEditor.gridlist[1] = guiCreateGridList(9, 27, 256, 202, false, GUIEditor.window[1]) column = guiGridListAddColumn(GUIEditor.gridlist[1], "Name", 0.5) guiGridListAddColumn(GUIEditor.gridlist[1], "Rank", 0.5) for i = 1, 2 do guiGridListAddRow(GUIEditor.gridlist[1]) end guiGridListSetItemText(GUIEditor.gridlist[1], 0, 1, "[AV]Bilal", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 0, 2, "Admin", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 1, 1, "[immortal]Desik", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 1, 2, "Super Moderator", false, false) GUIEditor.button[1] = guiCreateButton(84, 239, 103, 38, "Close", false, GUIEditor.window[1]) guiSetVisible(GUIEditor.window[1], false) end ) function showTheGui() local v = guiGetVisible( GUIEditor.window[1] ) guiSetVisible(GUIEditor.window[1], not v ) showCursor ( not isCursorShowing ( ) ) end addCommandHandler("staff", showTheGui) bindKey("F5", "down", showTheGui) function onGuiClick() if (source == GUIEditor.button[1]) then guiSetVisible(GUIEditor.window[1], false) showCursor(false) end end addEventHandler("onClientGUIClick", root, onGuiClick) function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end function adduser_func ( player, cmd, target ) local target = getPlayerFromPartialName ( target ) if target then local row = guiGridListAddRow(GUIEditor.gridlist[1]) guiGridListSetItemText(GUIEditor.gridlist[1], row, column, getPlayerName(target), false, false) outputChatBox("Player has been added to F5 menu sucessfully.", player, 0, 255, 0) else outputChatBox("* Player not found.", player, 255, 0, 0) end end addCommandHandler ( "adduser", adduser_func ) I tried my best to fix it, but I couldn't. /adduser is not working. No errors in debugscript. Thanks in advance.
TAPL Posted September 11, 2015 Posted September 11, 2015 function adduser_func ( cmd, target ) local target = getPlayerFromPartialName ( target ) if target then local row = guiGridListAddRow(GUIEditor.gridlist[1]) guiGridListSetItemText(GUIEditor.gridlist[1], row, column, getPlayerName(target), false, false) outputChatBox("Player has been added to F5 menu sucessfully.", 0, 255, 0) else outputChatBox("* Player not found.", 255, 0, 0) end end addCommandHandler ( "adduser", adduser_func )
JR10 Posted September 11, 2015 Posted September 11, 2015 The command handler function in client-side doesn't have a player parameter and neither do outputChatBox.
Bilal135 Posted September 11, 2015 Author Posted September 11, 2015 I added one more thing, and now always outputs: "Player not found". function adduser_func ( player, cmd, target ) local target = getPlayerFromPartialName ( target ) if target then local row = guiGridListAddRow(GUIEditor.gridlist[1]) guiGridListSetItemText(GUIEditor.gridlist[1], row, column, getPlayerName(target), false, false) guiGridListSetItemText(GUIEditor.gridlist[1], row, column1, "Warden", false, false) outputChatBox("Player has been added to F5 menu sucessfully.", 0, 255, 0) else outputChatBox("* Player not found.", 255, 0, 0) end end addCommandHandler ( "adduser", adduser_func )
Bilal135 Posted September 11, 2015 Author Posted September 11, 2015 One more problem, only I can see the new name in the panel, why not others? Please help.
TAPL Posted September 11, 2015 Posted September 11, 2015 The grid list is client side which mean it on your computer. You will need to use trigger to server side and then trigger back to client side for all players.
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