orcun99

lua problem

Recommended Posts

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 by orcun99

Share this post


Link to post
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

Share this post


Link to post

Can you please send us the function that is triggering "addPlayerToGroup" event? We don't know what's being sent as arguments.

Share this post


Link to post
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)

 

Share this post


Link to post
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.

Share this post


Link to post
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))
    end
end
addEventHandler("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 by orcun99

Share this post


Link to post

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

 

Share this post


Link to post
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 by orcun99

Share this post


Link to post

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 by pa3ck

Share this post


Link to post

triggerServerEvent("addPlayerToGroup", getRootElement(), localPlayer, guiGridListGetSelectedItem(groupGrid))

try this

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post

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.