orcun99 Posted June 21, 2017 Share Posted June 21, 2017 (edited) Spoiler addCommandHandler("group", function(source) if exports.acl:isPlayerInGroup(source, "ev") or exports.acl:isPlayerInGroup(source, "admin") then triggerClientEvent(source, "createWindow", getRootElement()) triggerClientEvent(source, "fillagrid", getRootElement()) triggerClientEvent(source, "fillcgrid", getRootElement()) triggerClientEvent(source, "fillugrid", getRootElement()) end end ) function addGroup(client, group) local playerToAdd = getPlayerAccount(client) if not exports.acl:isPlayerInGroup(playerToAdd, group)then exports.acl:addAccountToGroup(playerToAdd,group) exports.msj:sendMessage("You've been added to: " ..group.. "!", 0, 150, 0, client) end end addEvent("addPlayerToGroup", true) addEventHandler("addPlayerToGroup", resourceRoot, addGroup) function removeGroup(client, group) local playerToRemove = getPlayerAccount(client) if exports.acl:isPlayerInGroup(playerToAdd, group) then exports.acl:removeAccountFromGroup(playerToRemove,group) exports.msj:sendMessage("You've been removed from: " ..group.. "!", 0, 150, 0, client) end end addEvent("removePlayerFromGroup", true) addEventHandler("removePlayerFromGroup", resourceRoot, removeGroup) I have erorr line 13 Bad argument @ 'getplayeraccount' [Expected element at argument 1, got string 'TEST'] Line 13 : local playerToAdd = getPlayerAccount(client) Edited June 21, 2017 by orcun99 Link to comment
Discord Moderators Pirulax Posted June 21, 2017 Discord Moderators Share Posted June 21, 2017 Please Code in code tags. 1 Link to comment
S3Nn4oX Posted June 21, 2017 Share Posted June 21, 2017 addCommandHandler("group", function(thePlayer) if exports.acl:isPlayerInGroup(thePlayer, "ev") or exports.acl:isPlayerInGroup(thePlayer, "admin") then triggerClientEvent(thePlayer, "createWindow", getRootElement()) triggerClientEvent(thePlayer, "fillagrid", getRootElement()) triggerClientEvent(thePlayer, "fillcgrid", getRootElement()) triggerClientEvent(thePlayer, "fillugrid", getRootElement()) end end ) function addGroup(thePlayer, group) local playerToAdd = getPlayerAccount(thePlayer) if not exports.acl:isPlayerInGroup(playerToAdd, group)then exports.acl:addAccountToGroup(playerToAdd,group) exports.msj:sendMessage("You've been added to: " ..group.. "!", 0, 150, 0,thePlayer) end end addEvent("addPlayerToGroup", true) addEventHandler("addPlayerToGroup", root, addGroup) function removeGroup(thePlayer, group) local playerToRemove = getPlayerAccount(thePlayer) if exports.acl:isPlayerInGroup(playerToAdd, group) then exports.acl:removeAccountFromGroup(playerToRemove,group) exports.msj:sendMessage("You've been removed from: " ..group.. "!", 0, 150, 0,thePlayer) end end addEvent("removePlayerFromGroup", true) addEventHandler("removePlayerFromGroup", root, removeGroup) try this Link to comment
Hale Posted June 21, 2017 Share Posted June 21, 2017 Can you please send us the function that is triggering "addPlayerToGroup" event? We don't know what's being sent as arguments. Link to comment
orcun99 Posted June 22, 2017 Author Share Posted June 22, 2017 6 hours ago, S3Nn4oX said: addCommandHandler("group", function(thePlayer) if exports.acl:isPlayerInGroup(thePlayer, "ev") or exports.acl:isPlayerInGroup(thePlayer, "admin") then triggerClientEvent(thePlayer, "createWindow", getRootElement()) triggerClientEvent(thePlayer, "fillagrid", getRootElement()) triggerClientEvent(thePlayer, "fillcgrid", getRootElement()) triggerClientEvent(thePlayer, "fillugrid", getRootElement()) end end ) function addGroup(thePlayer, group) local playerToAdd = getPlayerAccount(thePlayer) if not exports.acl:isPlayerInGroup(playerToAdd, group)then exports.acl:addAccountToGroup(playerToAdd,group) exports.msj:sendMessage("You've been added to: " ..group.. "!", 0, 150, 0,thePlayer) end end addEvent("addPlayerToGroup", true) addEventHandler("addPlayerToGroup", root, addGroup) function removeGroup(thePlayer, group) local playerToRemove = getPlayerAccount(thePlayer) if exports.acl:isPlayerInGroup(playerToAdd, group) then exports.acl:removeAccountFromGroup(playerToRemove,group) exports.msj:sendMessage("You've been removed from: " ..group.. "!", 0, 150, 0,thePlayer) end end addEvent("removePlayerFromGroup", true) addEventHandler("removePlayerFromGroup", root, removeGroup) try this don't work 5 hours ago, Hale said: Can you please send us the function that is triggering "addPlayerToGroup" event? We don't know what's being sent as arguments. Spoiler uniongroups = {"admin", "subadmin" } confedgroups = {"staff", "housing"} rpgroups = {"ssmember", "nsamember", "aramember", "ZİP", "usocmember", "TEST"} function openWindow() showCursor(true) window = guiCreateWindow(555, 381, 220, 288, "BD:RPG - Group management", false) guiWindowSetSizable(window, false) groupGrid = guiCreateGridList(10, 70, 201, 176, false, window) guiGridListAddColumn(groupGrid, "Groups:", 0.9) addButton = guiCreateButton(10, 254, 95, 25, "EKLE", false, window) remButton = guiCreateButton(110, 254, 95, 25, "SİL", false, window) closeButton = guiCreateButton(184, 31, 27, 23, "X", false, window) name = guiCreateMemo(0.05, 0.09, 0.75, 0.11, "KADI:", true, window) end addEvent("createWindow", true) addEventHandler("createWindow", root, openWindow) function fillUnionGrids() for i,v in ipairs(uniongroups) do guiGridListSetItemText(groupGrid, guiGridListAddRow(groupGrid), 1, v, false, false) end end addEvent("fillugrid", true) addEventHandler("fillugrid", root, fillUnionGrids) function fillConfGrids() for i,v in ipairs(confedgroups) do guiGridListSetItemText(groupGrid, guiGridListAddRow(groupGrid), 1, v, false, false) end end addEvent("fillcgrid", true) addEventHandler("fillcgrid", root, fillConfGrids) function fillAdminGrids() for i,v in ipairs(rpgroups) do guiGridListSetItemText(groupGrid, guiGridListAddRow(groupGrid), 1, v, false, false) end end addEvent("fillagrid", true) addEventHandler("fillagrid", root, fillAdminGrids) function close() if (source == closeButton) then guiSetVisible(window, false) showCursor(false) end end addEventHandler("onClientGUIClick", root, close) function addThePlayer(thePlayer) if (source==addButton) then triggerServerEvent("addPlayerToGroup", getRootElement(), guiGetText(name), guiGridListGetSelectedItem(groupGrid)) end end addEventHandler("onClientGUIClick", root, addThePlayer) function removeThePlayer(thePlayer) if (source==remButton) then triggerServerEvent("addPlayerFromGroup", getRootElement(), guiGetText(name), guiGridListGetSelectedItem(groupGrid)) end end addEventHandler("onClientGUIClick", root, removeThePlayer) Link to comment
orcun99 Posted June 22, 2017 Author Share Posted June 22, 2017 (edited) someone help pls? https://prnt.sc/fmqhvb there is sql gruops Edited June 22, 2017 by orcun99 Link to comment
pa3ck Posted June 22, 2017 Share Posted June 22, 2017 51 minutes ago, orcun99 said: someone help pls? https://prnt.sc/fmqhvb there is sql gruops Hale already asked you to provide more details / code, since we can't see what parameters are being passed to the event addPlayerToGroup, we won't be able to help you without it. Link to comment
orcun99 Posted June 22, 2017 Author Share Posted June 22, 2017 (edited) 24 minutes ago, pa3ck said: Hale already asked you to provide more details / code, since we can't see what parameters are being passed to the event addPlayerToGroup, we won't be able to help you without it. function addThePlayer(thePlayer) if (source==addButton) then triggerServerEvent("addPlayerToGroup", getRootElement(), guiGetText(name), guiGridListGetSelectedItem(groupGrid)) endendaddEventHandler("onClientGUIClick", root, addThePlayer) all code: client.lua Spoiler edgroups = {"staff", "housing"} rpgroups = {"ssmember", "nsamember", "aramember", "ZİP", "usocmember", "TEST"} function openWindow() showCursor(true) window = guiCreateWindow(555, 381, 220, 288, "BD:RPG - Group management", false) guiWindowSetSizable(window, false) groupGrid = guiCreateGridList(10, 70, 201, 176, false, window) guiGridListAddColumn(groupGrid, "Groups:", 0.9) addButton = guiCreateButton(10, 254, 95, 25, "EKLE", false, window) remButton = guiCreateButton(110, 254, 95, 25, "SİL", false, window) closeButton = guiCreateButton(184, 31, 27, 23, "X", false, window) name = guiCreateMemo(0.05, 0.09, 0.75, 0.11, "KADI:", true, window) end addEvent("createWindow", true) addEventHandler("createWindow", root, openWindow) function fillUnionGrids() for i,v in ipairs(uniongroups) do guiGridListSetItemText(groupGrid, guiGridListAddRow(groupGrid), 1, v, false, false) end end addEvent("fillugrid", true) addEventHandler("fillugrid", root, fillUnionGrids) function fillConfGrids() for i,v in ipairs(confedgroups) do guiGridListSetItemText(groupGrid, guiGridListAddRow(groupGrid), 1, v, false, false) end end addEvent("fillcgrid", true) addEventHandler("fillcgrid", root, fillConfGrids) function fillAdminGrids() for i,v in ipairs(rpgroups) do guiGridListSetItemText(groupGrid, guiGridListAddRow(groupGrid), 1, v, false, false) end end addEvent("fillagrid", true) addEventHandler("fillagrid", root, fillAdminGrids) function close() if (source == closeButton) then guiSetVisible(window, false) showCursor(false) end end addEventHandler("onClientGUIClick", root, close) function addThePlayer(thePlayer) if (source==addButton) then triggerServerEvent("addPlayerToGroup", getRootElement(), guiGetText(name), guiGridListGetSelectedItem(groupGrid)) end end addEventHandler("onClientGUIClick", root, addThePlayer) function removeThePlayer(thePlayer) if (source==remButton) then triggerServerEvent("addPlayerFromGroup", getRootElement(), guiGetText(name), guiGridListGetSelectedItem(groupGrid)) end end addEventHandler("onClientGUIClick", root, removeThePlayer) server.lua Spoiler addCommandHandler("group", function(thePlayer) if exports.acl:isPlayerInGroup(thePlayer, "ev") or exports.acl:isPlayerInGroup(thePlayer, "admin") then triggerClientEvent(thePlayer, "createWindow", getRootElement()) triggerClientEvent(thePlayer, "fillagrid", getRootElement()) triggerClientEvent(thePlayer, "fillcgrid", getRootElement()) triggerClientEvent(thePlayer, "fillugrid", getRootElement()) end end ) function addGroup(thePlayer, group) local playerToAdd = getPlayerAccount(thePlayer) if not exports.acl:isPlayerInGroup(playerToAdd, group)then exports.acl:addAccountToGroup(playerToAdd,group) exports.msj:sendMessage("You've been added to: " ..group.. "!", 0, 150, 0,thePlayer) end end addEvent("addPlayerToGroup", true) addEventHandler("addPlayerToGroup", root, addGroup) function removeGroup(thePlayer, group) local playerToRemove = getPlayerAccount(thePlayer) if exports.acl:isPlayerInGroup(playerToAdd, group) then exports.acl:removeAccountFromGroup(playerToRemove,group) exports.msj:sendMessage("You've been removed from: " ..group.. "!", 0, 150, 0,thePlayer) end end addEvent("removePlayerFromGroup", true) addEventHandler("removePlayerFromGroup", root, removeGroup) Edited June 22, 2017 by orcun99 Link to comment
pa3ck Posted June 22, 2017 Share Posted June 22, 2017 triggerServerEvent("addPlayerToGroup", getRootElement(), guiGetText(name), guiGridListGetSelectedItem(groupGrid)) The parameter I highlighted is a string, not a player element.. try this: function addGroup(playerName, group) local thePlayer = getPlayerFromName(playerName) local playerToAdd = getPlayerAccount(thePlayer) if not exports.acl:isPlayerInGroup(playerToAdd, group)then exports.acl:addAccountToGroup(playerToAdd,group) exports.msj:sendMessage("You've been added to: " ..group.. "!", 0, 150, 0,thePlayer) end end Link to comment
orcun99 Posted June 22, 2017 Author Share Posted June 22, 2017 (edited) 28 minutes ago, pa3ck said: triggerServerEvent("addPlayerToGroup", getRootElement(), guiGetText(name), guiGridListGetSelectedItem(groupGrid)) The parameter I highlighted is a string, not a player element.. try this: function addGroup(playerName, group) local thePlayer = getPlayerFromName(playerName) local playerToAdd = getPlayerAccount(thePlayer) if not exports.acl:isPlayerInGroup(playerToAdd, group)then exports.acl:addAccountToGroup(playerToAdd,group) exports.msj:sendMessage("You've been added to: " ..group.. "!", 0, 150, 0,thePlayer) end end grouppanel/server.lua line 14: bad argument @ 'getplayeraccount' [expected at argument 1, got boolean] line14: local playerToAdd = getPlayerAccount(thePlayer) Edited June 22, 2017 by orcun99 Link to comment
pa3ck Posted June 22, 2017 Share Posted June 22, 2017 (edited) The line I added was: local thePlayer = getPlayerFromName(playerName) It is needed to get the player by the name, make sure playerName is the same as the player's name, you'll need to use string.gsub to remove HEX color code from the name as well. Edited June 22, 2017 by pa3ck Link to comment
orcun99 Posted June 26, 2017 Author Share Posted June 26, 2017 (edited) still I need help don't work there is gui http://prntscr.com/fogb5l Edited June 26, 2017 by orcun99 Link to comment
kikos500 Posted June 27, 2017 Share Posted June 27, 2017 triggerServerEvent("addPlayerToGroup", getRootElement(), localPlayer, guiGridListGetSelectedItem(groupGrid)) try this Link to comment
xMKHx Posted June 27, 2017 Share Posted June 27, 2017 addCommandHandler("group", function(source) if exports.acl:isPlayerInGroup(source, "ev") or exports.acl:isPlayerInGroup(source, "admin") then triggerClientEvent(source, "createWindow", getRootElement()) triggerClientEvent(source, "fillagrid", getRootElement()) triggerClientEvent(source, "fillcgrid", getRootElement()) triggerClientEvent(source, "fillugrid", getRootElement()) end end ) function addGroup(client, group) local acc = getPlayerAccount ( client ) local accname = getAccountName ( acc ) if not exports.acl:isPlayerInGroup(accname, group)then exports.acl:addAccountToGroup(accname,group) exports.msj:sendMessage("You've been added to: " ..group.. "!", 0, 150, 0, client) end end addEvent("addPlayerToGroup", true) addEventHandler("addPlayerToGroup", resourceRoot, addGroup) function removeGroup(client, group) local playerToRemove = getPlayerAccount(client) if exports.acl:isPlayerInGroup(accname, group) then exports.acl:removeAccountFromGroup(playerToRemove,group) exports.msj:sendMessage("You've been removed from: " ..group.. "!", 0, 150, 0, client) end end addEvent("removePlayerFromGroup", true) addEventHandler("removePlayerFromGroup", resourceRoot, removeGroup) Use this and if there any problem gimme the debug Link to comment
orcun99 Posted June 27, 2017 Author Share Posted June 27, 2017 7 hours ago, xMKHx said: addCommandHandler("group", function(source) if exports.acl:isPlayerInGroup(source, "ev") or exports.acl:isPlayerInGroup(source, "admin") then triggerClientEvent(source, "createWindow", getRootElement()) triggerClientEvent(source, "fillagrid", getRootElement()) triggerClientEvent(source, "fillcgrid", getRootElement()) triggerClientEvent(source, "fillugrid", getRootElement()) end end ) function addGroup(client, group) local acc = getPlayerAccount ( client ) local accname = getAccountName ( acc ) if not exports.acl:isPlayerInGroup(accname, group)then exports.acl:addAccountToGroup(accname,group) exports.msj:sendMessage("You've been added to: " ..group.. "!", 0, 150, 0, client) end end addEvent("addPlayerToGroup", true) addEventHandler("addPlayerToGroup", resourceRoot, addGroup) function removeGroup(client, group) local playerToRemove = getPlayerAccount(client) if exports.acl:isPlayerInGroup(accname, group) then exports.acl:removeAccountFromGroup(playerToRemove,group) exports.msj:sendMessage("You've been removed from: " ..group.. "!", 0, 150, 0, client) end end addEvent("removePlayerFromGroup", true) addEventHandler("removePlayerFromGroup", resourceRoot, removeGroup) Use this and if there any problem gimme the debug https://prnt.sc/fonl5i https://prnt.sc/fonkyy 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