ednatmp Posted November 2, 2016 Share Posted November 2, 2016 Hi all, several weeks ago I was trying to solve a problem which i can not find solution. I've tried everything and nothing has worked. I need something to check if the user account is banner from the arena, and this code does not work... The console give me this error: [2016-11-02 14:58:26] WARNING: MassiveGaming\general\arenaban_s.lua:35: Bad argument @ 'xmlNodeGetAttribute' [Expected xml-node at argument 1] [2016-11-02 14:58:26] WARNING: MassiveGaming\general\arenaban_s.lua:40: Bad argument @ 'xmlUnloadFile' [Expected xml-node at argument 1] arenaban_s.lua (server side) function checkArenaBan(player, account, arena) if fileExists("general/banlist.xml") == false then return false end local banlist = xmlLoadFile("general/banlist.xml") for i, m in ipairs(xmlNodeGetChildren(banlist)) do if xmlNodeGetAttribute(m, "account") == account and xmlNodeGetAttribute(m, "arena") == arena then xmlUnloadFile(banlist) local returned = "true" triggerClientEvent(player, "checkArenaBan", player, returned) else xmlUnloadFile(banlist) local returned = "false" triggerClientEvent(player, "checkArenaBan", player, returned) end end end addEvent("checkArenaBan", true) addEventHandler("checkArenaBan", getRootElement(), checkArenaBan) lobby_c.lua (client side) local isPlayerBannedFromArena = "false" addEvent("checkArenaBan", true) addEventHandler("checkArenaBan", getLocalPlayer(), function (returned) if returned == "true" then isPlayerBannedFromArena = "true" else isPlayerBannedFromArena = "false" end end) other part of lobby_c.lua (client side) triggerServerEvent("checkArenaBan", _local, _local, getAccountNamePlayer(_local), getElementID(arena.Element)) if isPlayerBannedFromArena == "true" then addNotification("Usted está prohibido en esta arena.", "error") return end Link to comment
raynner Posted November 2, 2016 Share Posted November 2, 2016 (edited) I really have no idea if it will resolve but try to change that. -- remove this. addEvent("checkArenaBan", true) addEventHandler("checkArenaBan", getLocalPlayer(), function (returned) if returned == "true" then isPlayerBannedFromArena = "true" else isPlayerBannedFromArena = "false" end end) -- and use this addEvent("checkArenaBan", true) addEventHandler("checkArenaBan", getLocalPlayer(), function (returned) if returned == "true" then isPlayerBannedFromArena = true else isPlayerBannedFromArena = false end end) -- be sure to check this way now if isPlayerBannedFromArena == true then --.... Another error in your code is this. function checkArenaBan(player, account, arena) if fileExists("general/banlist.xml") == false then return false end local banlist = xmlLoadFile("general/banlist.xml") for i, m in ipairs(xmlNodeGetChildren(banlist)) do if xmlNodeGetAttribute(m, "account") == account and xmlNodeGetAttribute(m, "arena") == arena then xmlUnloadFile(banlist) local returned = "true" triggerClientEvent(player, "checkArenaBan", player, returned) else xmlUnloadFile(banlist) local returned = "false" triggerClientEvent(player, "checkArenaBan", player, returned) end end end addEvent("checkArenaBan", true) addEventHandler("checkArenaBan", getRootElement(), checkArenaBan) -- error. local returned = "true" or local returned = "false" -- you must remove the "local". -- right. returned = "true" and returned = "false" -- use this preference. returned = true and returned = false -- be sure to check this way now if returned == true then or if returned == false then --.. you must remove "local".. Edited November 2, 2016 by raynner repair writing Link to comment
ednatmp Posted November 2, 2016 Author Share Posted November 2, 2016 (edited) 55 minutes ago, raynner said: I really have no idea if it will resolve but try to change that. -- remove this. addEvent("checkArenaBan", true) addEventHandler("checkArenaBan", getLocalPlayer(), function (returned) if returned == "true" then isPlayerBannedFromArena = "true" else isPlayerBannedFromArena = "false" end end) -- and use this addEvent("checkArenaBan", true) addEventHandler("checkArenaBan", getLocalPlayer(), function (returned) if returned == "true" then isPlayerBannedFromArena = true else isPlayerBannedFromArena = false end end) -- be sure to check this way now if isPlayerBannedFromArena == true then --.... Another error in your code is this. function checkArenaBan(player, account, arena) if fileExists("general/banlist.xml") == false then return false end local banlist = xmlLoadFile("general/banlist.xml") for i, m in ipairs(xmlNodeGetChildren(banlist)) do if xmlNodeGetAttribute(m, "account") == account and xmlNodeGetAttribute(m, "arena") == arena then xmlUnloadFile(banlist) local returned = "true" triggerClientEvent(player, "checkArenaBan", player, returned) else xmlUnloadFile(banlist) local returned = "false" triggerClientEvent(player, "checkArenaBan", player, returned) end end end addEvent("checkArenaBan", true) addEventHandler("checkArenaBan", getRootElement(), checkArenaBan) -- error. local returned = "true" or local returned = "false" -- you must remove the "local". -- right. returned = "true" and returned = "false" -- use this preference. returned = true and returned = false -- be sure to check this way now if returned == true then or if returned == false then --.. you must remove "local".. Hey dude, thank you, but this still doesn't work properly, same error. Edited November 2, 2016 by Enz0Z Want to add something. Link to comment
raynner Posted November 2, 2016 Share Posted November 2, 2016 Just now, Enz0Z said: Hey dude, thank you, but this still doesn't work properly, same error. I know your error is related to line 5 and 10 and perhaps 6 ... good I'm pretty sure that your mistake is that ... try only proofread your script and use "local" has correctly places I n said more are still wrong as lobby_c.lua (client side) line 1 arenaban_s.lua (server side) line 1 function checkArenaBan(player, account, arena) account = nil value.. therefore "account" line 5 as well. -- error here. triggerServerEvent("checkArenaBan", _local, _local, getAccountNamePlayer(_local), getElementID(arena.Element)) -- try to create a variable to " getAccountNamePlayer(_local) " account = getAccountNamePlayer(_local) . -- and also arena = getElementID(arena.Element) -- use triggerServerEvent("checkArenaBan", _local, _local, account, arena) Another thing I could not help but notice is that you did something totally wrong in my eyes ... you are wearing triggerServerEvent() to call the function lobby_c.lua (client side) another serious error. GetAccountName() -- It can only be used on Server Sid use this will work better. getAccountName(getPlayerAccount(Player Here)) Link to comment
ednatmp Posted November 2, 2016 Author Share Posted November 2, 2016 13 minutes ago, raynner said: I know your error is related to line 5 and 10 and perhaps 6 ... good I'm pretty sure that your mistake is that ... try only proofread your script and use "local" has correctly places I n said more are still wrong as lobby_c.lua (client side) line 1 arenaban_s.lua (server side) line 1 function checkArenaBan(player, account, arena) account = nil value.. therefore "account" line 5 as well. -- error here. triggerServerEvent("checkArenaBan", _local, _local, getAccountNamePlayer(_local), getElementID(arena.Element)) -- try to create a variable to " getAccountNamePlayer(_local) " account = getAccountNamePlayer(_local) . -- and also arena = getElementID(arena.Element) -- use triggerServerEvent("checkArenaBan", _local, _local, account, arena) Another thing I could not help but notice is that you did something totally wrong in my eyes ... you are wearing triggerServerEvent() to call the function lobby_c.lua (client side) another serious error. GetAccountName() -- It can only be used on Server Sid use this will work better. getAccountName(getPlayerAccount(Player Here)) Okay, im gonna tested right now. Im triggering server function from client side, and triggering client function from client side, i think its correct, and one more thing, im using a custom "account system", coded by me! Link to comment
raynner Posted November 2, 2016 Share Posted November 2, 2016 3 minutes ago, Enz0Z said: Okay, im gonna tested right now. Im triggering server function from client side, and triggering client function from client side, i think its correct, and one more thing, im using a custom "account system", coded by me! Oh ok .. just gave you information from the MTA Wiki functions .. Link to comment
ednatmp Posted November 2, 2016 Author Share Posted November 2, 2016 9 minutes ago, raynner said: Oh ok .. just gave you information from the MTA Wiki functions .. Well, i tested again, and still same error, i don't know what is it... Link to comment
raynner Posted November 2, 2016 Share Posted November 2, 2016 2 minutes ago, Enz0Z said: Well, i tested again, and still same error, i don't know what is it... as I said review your script and see if this using "local" correctly .. EX: local banlist can be the error check .. and my eyes his mistake is where I spoke using account's function's in client sid Link to comment
MIKI785 Posted November 3, 2016 Share Posted November 3, 2016 (edited) To be honest i don't know what is the issue there. Try doing a debug in your loop, something like this: for i, m in ipairs(xmlNodeGetChildren(banlist)) do outputChatBox(tostring(i) .. ": " .. tostring(m)) And give us the output. Edited November 3, 2016 by MIKI785 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