WASSIm. Posted July 12, 2015 Share Posted July 12, 2015 Hi guys, i working on custom admin panel and when kick someone with panel its says "Please pute kick reason" but when use command on console the player got kicked, please help Client triggerServerEvent("onAdminEditPanel", localPlayer, type, name, text) Server addEvent("onAdminEditPanel", true) addEventHandler("onAdminEditPanel", root, function (command, ...) if (command) and (...) then outputDebugString(table.concat({...}, ", ")) executeCommandHandler("c"..command, source, ...) end end) addCommandHandler("ckick", function (theAdmin, _, name, reason) local thePlayer = getPlayerFromName(name) if not (thePlayer) then exports["ZA-hud"]:outputDxHelp("The player is not found", theAdmin, 255, 0, 0) return end if not (reason) or (reason == "") then exports["ZA-hud"]:outputDxHelp("Please pute kick reason", theAdmin, 255, 0, 0) return end kickPlayer(thePlayer, theAdmin, reason) end) Link to comment
GTX Posted July 12, 2015 Share Posted July 12, 2015 Try this. addEvent("onAdminEditPanel", true) addEventHandler("onAdminEditPanel", root, function (command, name, reason) if (command) and (name) and (reason) then executeCommandHandler("c"..command, source, name, reason) end end) addCommandHandler("ckick", function (theAdmin, _, name, ...) local reason = table.concat({...}, " ") local thePlayer = getPlayerFromName(name) if not (thePlayer) then exports["ZA-hud"]:outputDxHelp("The player is not found", theAdmin, 255, 0, 0) return end if not (reason) or (reason == "") or (reason == " ") then exports["ZA-hud"]:outputDxHelp("Please pute kick reason", theAdmin, 255, 0, 0) return end kickPlayer(thePlayer, theAdmin, reason) end) Link to comment
WASSIm. Posted July 12, 2015 Author Share Posted July 12, 2015 But i have moree, full function: addEventHandler("onClientGUIClick", resourceRoot, function() -- Player Tab local name = exports["ZA-system"]:guiGridListGetSelectedText(GUIMain.gridlist[1]) if (source == GUIMain.gridlist[1]) then local name = exports["ZA-system"]:guiGridListGetSelectedText(GUIMain.gridlist[1]) triggerServerEvent("onAdminCheckPayer", localPlayer, name) elseif (source == GUIMain.button[1]) then triggerEvent("onClientAdminEditPanel", localPlayer, "ban", name, nil, "Reason..") elseif (source == GUIMain.button[2]) then triggerEvent("onClientAdminEditPanel", localPlayer, "kick", name, nil, "Reason..") elseif (source == GUIMain.button[3]) then triggerServerEvent("onAdminEditPanel", localPlayer, "freeze", name) elseif (source == GUIMain.button[4]) then triggerEvent("onClientAdminEditPanel", localPlayer, "mute", name, nil, "Reason..") elseif (source == GUIMain.button[5]) then triggerServerEvent("onAdminEditPanel", localPlayer, "kill", name) elseif (source == GUIMain.button[6]) then triggerServerEvent("onAdminEditPanel", localPlayer, "see", name) elseif (source == GUIMain.button[7]) then -- NOTHING elseif (source == GUIMain.button[8]) then triggerEvent("onClientAdminEditPanel", localPlayer, "set", name, "armour", "100") elseif (source == GUIMain.button[9]) then triggerEvent("onClientAdminEditPanel", localPlayer, "set", name, "health", "200") elseif (source == GUIMain.button[10]) then triggerEvent("onClientAdminEditPanel", localPlayer, "set", name, "level", "1") elseif (source == GUIMain.button[11]) then triggerEvent("onClientAdminEditPanel", localPlayer, "set", name, "weapon", "0") elseif (source == GUIMain.button[12]) then triggerEvent("onClientAdminEditPanel", localPlayer, "set", name, "nick", name) elseif (source == GUIMain.button[13]) then triggerEvent("onClientAdminEditPanel", localPlayer, "set", name, "money", "0") elseif (source == GUIMain.button[14]) then triggerServerEvent("onAdminEditPanel", localPlayer, "fixvehicle", name) elseif (source == GUIMain.button[15]) then triggerServerEvent("onAdminEditPanel", localPlayer, "blowvehicle", name) elseif (source == GUIMain.button[16]) then triggerServerEvent("onAdminEditPanel", localPlayer, "warpme", name) elseif (source == GUIMain.button[17]) then triggerServerEvent("onAdminEditPanel", localPlayer, "warphim", name) elseif (source == GUIMain.button[18]) then triggerEvent("onClientAdminEditPanel", localPlayer, "smessage", name, nil, "...") elseif (source == GUIMain.button[19]) then triggerServerEvent("onAdminEditPanel", localPlayer, "takescreenshot", name) -- Other Window elseif (source == GUIBan.button[1]) then local reason, time = guiGetText(GUIBan.edit[1]), guiGetText(GUIBan.edit[2]) local timetype = exports["ZA-system"]:guiGridListGetSelectedText(GUIBan.gridlist[1]) local serial = guiCheckBoxGetSelected(GUIBan.checkbox[1]) local ip = guiCheckBoxGetSelected(GUIBan.checkbox[2]) local account = guiCheckBoxGetSelected(GUIBan.checkbox[3]) triggerServerEvent("onAdminEditPanel", localPlayer, "ban", name, reason, time, timetype, serial, ip, account) elseif (source == GUIBan.button[2]) then exports["ZA-system"]:guiWindowShow(GUIBan.window[1], false) elseif (source == GUIOther.button[1]) then local text = guiGetText(GUIOther.edit[1]) local type = getElementData(GUIOther.window[1], "type") if (type == "kick") or (type == "smessage") then triggerServerEvent("onAdminEditPanel", localPlayer, type, name, text) else triggerServerEvent("onAdminEditPanel", localPlayer, "set", name, type, text) end elseif (source == GUIOther.button[2]) then exports["ZA-system"]:guiWindowShow(GUIOther.window[1], false) elseif (source == GUIMute.button[1]) then local reason, time = guiGetText(GUIMute.edit[1]), guiGetText(GUIMute.edit[2]) local timetype = exports["ZA-system"]:guiGridListGetSelectedText(GUIMute.gridlist[1]) local global = guiCheckBoxGetSelected(GUIMute.checkbox[1]) local team = guiCheckBoxGetSelected(GUIMute.checkbox[2]) local localc = guiCheckBoxGetSelected(GUIMute.checkbox[3]) triggerServerEvent("onAdminEditPanel", localPlayer, "mute", {name, reason, time, timetype, global, team, localc}) elseif (source == GUIMute.button[2]) then exports["ZA-system"]:guiWindowShow(GUIMute.window[1], false) end -- Ban -- Speaker local url = guiGetText(GUIMain.edit[3]) --local name = exports["ZA-system"]:guiGridListGetSelectedText(GUIMain.gridlist[1], 1) --local url2 = exports["ZA-system"]:guiGridListGetSelectedText(GUIMain.gridlist[1], 2) if (source == GUIMain.button[23]) then triggerServerEvent("onAdminEditPanel", localPlayer, "music", url) elseif (source == GUIMain.button[24]) then triggerServerEvent("onAdminEditPanel", localPlayer, "music", url) elseif (source == GUIMain.button[25]) then triggerServerEvent("onAdminEditPanel", localPlayer, "attachmusic", url) elseif (source == GUIMain.button[26]) then triggerServerEvent("onAdminEditPanel", localPlayer, "movemusic", url) elseif (source == GUIMain.button[27]) then triggerServerEvent("onAdminEditPanel", localPlayer, "removemusic", url) elseif (source == GUIMain.button[27]) then triggerServerEvent("onAdminEditPanel", localPlayer, "pausemusic", url) end end) Link to comment
GTX Posted July 12, 2015 Share Posted July 12, 2015 This should work. addEvent("onAdminEditPanel", true) addEventHandler("onAdminEditPanel", root, function (command, name, ...) if (command) and (name) then executeCommandHandler("c"..command, source, name, ...) end end) addCommandHandler("ckick", function (theAdmin, _, name, ...) local reason = table.concat({...}, " ") local thePlayer = getPlayerFromName(name) if not (thePlayer) then exports["ZA-hud"]:outputDxHelp("The player is not found", theAdmin, 255, 0, 0) return end if not (reason) or (reason == "") or (reason == " ") then exports["ZA-hud"]:outputDxHelp("Please pute kick reason", theAdmin, 255, 0, 0) return end kickPlayer(thePlayer, theAdmin, reason) end) Link to comment
GTX Posted July 12, 2015 Share Posted July 12, 2015 This? addEvent("onAdminEditPanel", true) addEventHandler("onAdminEditPanel", root, function (command, name, ...) if (command) and (name) then executeCommandHandler("c"..command, source, name, {...}) end end) addCommandHandler("ckick", function (theAdmin, _, name, args) local reason = table.concat(args, " ") local thePlayer = getPlayerFromName(name) if not (thePlayer) then exports["ZA-hud"]:outputDxHelp("The player is not found", theAdmin, 255, 0, 0) return end if not (reason) or (reason == "") or (reason == " ") then exports["ZA-hud"]:outputDxHelp("Please pute kick reason", theAdmin, 255, 0, 0) return end kickPlayer(thePlayer, theAdmin, reason) end) Link to comment
WASSIm. Posted July 12, 2015 Author Share Posted July 12, 2015 problem not on command kick, is on event onAdminEditPanel Link to comment
GTX Posted July 12, 2015 Share Posted July 12, 2015 Did you test it? I think it should work. Link to comment
Sasu Posted July 13, 2015 Share Posted July 13, 2015 Check what reason returns in the command: addCommandHandler("ckick", function (theAdmin, _, name, reason) local thePlayer = getPlayerFromName(name) outputChatBox(tostring(reason), theAdmin) --<<<< if not (thePlayer) then exports["ZA-hud"]:outputDxHelp("The player is not found", theAdmin, 255, 0, 0) return end if not (reason) or (reason == "") then exports["ZA-hud"]:outputDxHelp("Please pute kick reason", theAdmin, 255, 0, 0) return end kickPlayer(thePlayer, theAdmin, reason) end) EDIT: I read the wiki and I saw that it says: args: Additional parameters that will be passed to the handler function(s) of the command that is called, separated by spaces. So try this: addEvent("onAdminEditPanel", true) addEventHandler("onAdminEditPanel", root, function (command, ...) if (command) and (...) then outputDebugString(table.concat({...}, ", ")) local args = table.concat({...}, " ") --- <<<< executeCommandHandler("c"..command, source, args) end end) addCommandHandler("ckick", function (theAdmin, _, name, reason) local thePlayer = getPlayerFromName(name) outputChatBox(tostring(reason), theAdmin) if not (thePlayer) then exports["ZA-hud"]:outputDxHelp("The player is not found", theAdmin, 255, 0, 0) return end if not (reason) or (reason == "") then exports["ZA-hud"]:outputDxHelp("Please pute kick reason", theAdmin, 255, 0, 0) return end kickPlayer(thePlayer, theAdmin, reason) end) Link to comment
WASSIm. Posted July 14, 2015 Author Share Posted July 14, 2015 Thank you its work, But i have same problem from other code the seconded argument and other don't work if (string.sub(message, 1, 1) == "/") then local argcmd = split(message, " ") local command = tostring(argcmd[1]:gsub("/", "", 1)) table.remove(argcmd, 1) executeCommandHandler(command, source, unpack(argcmd)) triggerClientEvent(source, "onClientPlayerChatCommand", source, command, unpack(argcmd)) end Link to comment
Sasu Posted July 15, 2015 Share Posted July 15, 2015 if (string.sub(message, 1, 1) == "/") then local argcmd = split(message, " ") local command = tostring(argcmd[1]:gsub("/", "", 1)) table.remove(argcmd, 1) executeCommandHandler(command, source, table.concat(argcmd, " ")) triggerClientEvent(source, "onClientPlayerChatCommand", source, command, unpack(argcmd)) end 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