Jump to content

Doesnt work


Bilal135

Recommended Posts

Posted
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.

Posted
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 ) 

Posted

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 ) 

Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...