Jump to content

problem bindkey


iFoReX

Recommended Posts

I have a problem with a argument of my bindkey :c

cl-side

GUIEditor_Window = {} 
GUIEditor_Button = {} 
GUIEditor_Label = {} 
GUIEditor_Edit = {} 
GUIEditor_Grid = {} 
  
GUIEditor_Window[1] = guiCreateWindow(0.4925,0.3317,0.51,0.6717,"GUI Admin",true) 
guiWindowSetSizable(GUIEditor_Window[1],false) 
GUIEditor_Grid[1] = guiCreateGridList(11,87,167,307,false,GUIEditor_Window[1]) 
guiGridListSetSelectionMode(GUIEditor_Grid[1],2) 
  
guiGridListAddColumn(GUIEditor_Grid[1],"Players",0.2) 
GUIEditor_Edit[1] = guiCreateEdit(11,46,167,34,"",false,GUIEditor_Window[1]) 
GUIEditor_Button[1] = guiCreateButton(191,46,103,38,"Mute",false,GUIEditor_Window[1]) 
GUIEditor_Button[2] = guiCreateButton(191,96,103,38,"Ban",false,GUIEditor_Window[1]) 
GUIEditor_Button[3] = guiCreateButton(191,146,103,38,"Kick",false,GUIEditor_Window[1]) 
GUIEditor_Button[4] = guiCreateButton(191,200,103,38,"Dimension",false,GUIEditor_Window[1]) 
GUIEditor_Button[5] = guiCreateButton(191,259,103,38,"Warp to Player",false,GUIEditor_Window[1]) 
GUIEditor_Label[1] = guiCreateLabel(190,345,213,51,"Admin Panel By ElMota",false,GUIEditor_Window[1]) 
guiSetFont(GUIEditor_Label[1],"clear-normal") 
GUIEditor_Button[6] = guiCreateButton(313,46,86,38,"Resources",false,GUIEditor_Window[1]) 
  
GUIEditor_Window[2] = guiCreateWindow(0.35,0.2783,0.3388,0.4217,"Ban Times",true) 
guiWindowSetSizable(GUIEditor_Window[2],false) 
GUIEditor_Button[7] = guiCreateButton(32,39,189,40,"1 Year",false,GUIEditor_Window[2]) 
GUIEditor_Button[8] = guiCreateButton(32,87,189,40,"1 Month",false,GUIEditor_Window[2]) 
GUIEditor_Button[9] = guiCreateButton(32,138,189,38,"1 Day",false,GUIEditor_Window[2]) 
GUIEditor_Button[10] = guiCreateButton(172,216,90,28,"Cancelar",false,GUIEditor_Window[2]) 
  
GUIEditor_Window[3] = guiCreateWindow(0.2988,0.2867,0.4737,0.4267,"Dimension GUI",true) 
GUIEditor_Label[2] = guiCreateLabel(48,102,107,18,"Set Dimension ...",false,GUIEditor_Window[3]) 
GUIEditor_Edit[2] = guiCreateEdit(131,123,65,27,"",false,GUIEditor_Window[3]) 
GUIEditor_Button[11] = guiCreateButton(246,199,120,44,"Set Dimension",false,GUIEditor_Window[3]) 
GUIEditor_Button[12] = guiCreateButton(9,199,120,44,"Cancel",false,GUIEditor_Window[3]) 
  
GUIEditor_Window[4] = guiCreateWindow(0.3613,0.13,0.3025,0.845,"GUI Resources",true) 
guiWindowSetSizable(GUIEditor_Window[4],false) 
GUIEditor_Grid[2] = guiCreateGridList(21,71,201,358,false,GUIEditor_Window[4]) 
guiGridListSetSelectionMode(GUIEditor_Grid[2],2) 
  
guiGridListAddColumn(GUIEditor_Grid[2],"resources :",0.2) 
GUIEditor_Edit[3] = guiCreateEdit(23,32,197,35,"",false,GUIEditor_Window[4]) 
GUIEditor_Button[13] = guiCreateButton(141,453,92,37,"Start Resource",false,GUIEditor_Window[4]) 
GUIEditor_Button[14] = guiCreateButton(10,453,92,37,"Cancel",false,GUIEditor_Window[4]) 
  
  
guiSetVisible(GUIEditor_Window[1],false) 
guiSetVisible(GUIEditor_Window[2],false) 
guiSetVisible(GUIEditor_Window[3],false) 
guiSetVisible(GUIEditor_Window[4],false) 
showCursor(false) 
  
function GUIOpen() 
            guiSetVisible(GUIEditor_Window[1], not guiGetVisible(GUIEditor_Window[1])) 
            guiSetVisible(GUIEditor_Window[2], not guiGetVisible(GUIEditor_Window[2])) 
            guiSetVisible(GUIEditor_Window[3], not guiGetVisible(GUIEditor_Window[3])) 
            guiSetVisible(GUIEditor_Window[4], not guiGetVisible(GUIEditor_Window[4])) 
            showCursor(guiGetVisible(GUIEditor_Window[1])) 
    end 
addEvent("onVisibleAdmin", true) 
addEventHandler("onVisibleAdmin", getLocalPlayer(), GUIOpen) 

sv-side

-------------Server--------- 
function opGUI() 
     local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
     triggerClientEvent(source, "onVisibleAdmin", source) 
     end 
end 
  
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()),  
function() 
bindKey(source, "p","down", opGUI) 
end 
) 

Link to comment

1: "source" from "onResourceStart" is the resource that got started, you must loop online players.

2: You forgot to define "thePlayer" and "opGUI" function.

3: Use this:

function opGUI ( thePlayer ) 
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
    if isObjectInACLGroup ( "user.".. accName, aclGetGroup ( "Admin" ) ) then 
        triggerClientEvent ( thePlayer, "onVisibleAdmin", thePlayer ) 
    end 
end 
  
addEventHandler ( "onPlayerJoin", root, 
    function ( ) 
        bindKey ( source, "p", "down", opGUI ) 
    end 
) 
  
addEventHandler ( "onResourceStart", resourceRoot, 
    function ( ) 
        for index, player in ipairs ( getElementsByType ( "player" ) ) do 
            bindKey ( player, "p", "down", opGUI ) 
        end 
    end 
) 

Link to comment

how I can do for a string find for my grid of players in my edit

here the lines

addEventHandler ( "onClientGUIChanged", GUIEditor_Edit[1], 
    function ( ) 
    string.find(string, GUIEditor_Grid[1]) 
        end 
    end 
) 

Link to comment

your going to have to use a

for i,v in ipairs()do 

to narrow down the rows or to get the text from the gui gridlist

I think this is right:

for i=1,guiGridListGetRowCount(GRIDLIST) do 
    if(guiGridListGetItemText(GRIDLIST,i,1)==string)then 
        guiGridListSetSelectedItem(GRIDLIST,i,1) 
    end 
end 

Link to comment

Try this:

Client:

GUIEditor_Window = {} 
GUIEditor_Button = {} 
GUIEditor_Label = {} 
GUIEditor_Edit = {} 
GUIEditor_Grid = {} 
  
GUIEditor_Window[1] = guiCreateWindow(0.4925,0.3317,0.51,0.6717,"GUI Admin",true) 
guiWindowSetSizable(GUIEditor_Window[1],false) 
GUIEditor_Grid[1] = guiCreateGridList(11,87,167,307,false,GUIEditor_Window[1]) 
guiGridListSetSelectionMode(GUIEditor_Grid[1],2) 
  
guiGridListAddColumn(GUIEditor_Grid[1],"Players",0.2) 
GUIEditor_Edit[1] = guiCreateEdit(11,46,167,34,"",false,GUIEditor_Window[1]) 
GUIEditor_Button[1] = guiCreateButton(191,46,103,38,"Mute",false,GUIEditor_Window[1]) 
GUIEditor_Button[2] = guiCreateButton(191,96,103,38,"Ban",false,GUIEditor_Window[1]) 
GUIEditor_Button[3] = guiCreateButton(191,146,103,38,"Kick",false,GUIEditor_Window[1]) 
GUIEditor_Button[4] = guiCreateButton(191,200,103,38,"Dimension",false,GUIEditor_Window[1]) 
GUIEditor_Button[5] = guiCreateButton(191,259,103,38,"Warp to Player",false,GUIEditor_Window[1]) 
GUIEditor_Label[1] = guiCreateLabel(190,345,213,51,"Admin Panel By ElMota",false,GUIEditor_Window[1]) 
guiSetFont(GUIEditor_Label[1],"clear-normal") 
GUIEditor_Button[6] = guiCreateButton(313,46,86,38,"Resources",false,GUIEditor_Window[1]) 
  
GUIEditor_Window[2] = guiCreateWindow(0.35,0.2783,0.3388,0.4217,"Ban Times",true) 
guiWindowSetSizable(GUIEditor_Window[2],false) 
GUIEditor_Button[7] = guiCreateButton(32,39,189,40,"1 Year",false,GUIEditor_Window[2]) 
GUIEditor_Button[8] = guiCreateButton(32,87,189,40,"1 Month",false,GUIEditor_Window[2]) 
GUIEditor_Button[9] = guiCreateButton(32,138,189,38,"1 Day",false,GUIEditor_Window[2]) 
GUIEditor_Button[10] = guiCreateButton(172,216,90,28,"Cancelar",false,GUIEditor_Window[2]) 
  
GUIEditor_Window[3] = guiCreateWindow(0.2988,0.2867,0.4737,0.4267,"Dimension GUI",true) 
GUIEditor_Label[2] = guiCreateLabel(48,102,107,18,"Set Dimension ...",false,GUIEditor_Window[3]) 
GUIEditor_Edit[2] = guiCreateEdit(131,123,65,27,"",false,GUIEditor_Window[3]) 
GUIEditor_Button[11] = guiCreateButton(246,199,120,44,"Set Dimension",false,GUIEditor_Window[3]) 
GUIEditor_Button[12] = guiCreateButton(9,199,120,44,"Cancel",false,GUIEditor_Window[3]) 
  
GUIEditor_Window[4] = guiCreateWindow(0.3613,0.13,0.3025,0.845,"GUI Resources",true) 
guiWindowSetSizable(GUIEditor_Window[4],false) 
GUIEditor_Grid[2] = guiCreateGridList(21,71,201,358,false,GUIEditor_Window[4]) 
guiGridListSetSelectionMode(GUIEditor_Grid[2],2) 
  
guiGridListAddColumn(GUIEditor_Grid[2],"resources :",0.2) 
GUIEditor_Edit[3] = guiCreateEdit(23,32,197,35,"",false,GUIEditor_Window[4]) 
GUIEditor_Button[13] = guiCreateButton(141,453,92,37,"Start Resource",false,GUIEditor_Window[4]) 
GUIEditor_Button[14] = guiCreateButton(10,453,92,37,"Cancel",false,GUIEditor_Window[4]) 
  
  
guiSetVisible(GUIEditor_Window[1],false) 
guiSetVisible(GUIEditor_Window[2],false) 
guiSetVisible(GUIEditor_Window[3],false) 
guiSetVisible(GUIEditor_Window[4],false) 
showCursor(false) 
  
  
addEvent("onVisibleAdmin", true) 
addEventHandler("onVisibleAdmin",root,function() 
            guiSetVisible(GUIEditor_Window[1], not guiGetVisible(GUIEditor_Window[1])) 
            guiSetVisible(GUIEditor_Window[2], not guiGetVisible(GUIEditor_Window[2])) 
            guiSetVisible(GUIEditor_Window[3], not guiGetVisible(GUIEditor_Window[3])) 
            guiSetVisible(GUIEditor_Window[4], not guiGetVisible(GUIEditor_Window[4])) 
            showCursor(not isCursorShowing()) 
end) 
  
addEventHandler("onClientResourceStart",resourceRoot,function() 
    for i,v in pairs(getElementsByType("player"))do 
        guiGridListSetItemText(GUIEditor_Grid[1],guiGridListAddRow(GUIEditor_Grid[1]),1,getPlayerName(v),false,false) 
    end 
end) 
  
addEventHandler("onClientGUIChanged",GUIEditor_Edit[1],function(element) 
    for i=1,guiGridListGetRowCount(GUIEditor_Grid[1])do 
        if(guiGridListGetItemText(GUIEditor_Grid[1],i,1)==guiGetText(source))then 
            guiGridListSetItemSelected(GUIEditor_Grid[1],i,1) 
        end 
    end 
end) 

Server:

function opGUI ( thePlayer ) 
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
    if isObjectInACLGroup ( "user.".. accName, aclGetGroup ( "Admin" ) ) then 
        triggerClientEvent ( thePlayer, "onVisibleAdmin", thePlayer ) 
    end 
end 
  
addEventHandler ( "onPlayerJoin", root,function() 
    bindKey ( source, "p", "down", opGUI ) 
end) 
  
addEventHandler ("onResourceStart", resourceRoot,function() 
    for index,player in ipairs(getElementsByType("player" ))do 
        bindKey ( player, "p", "down", opGUI ) 
    end 
end) 

Link to comment

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