Paplo Posted August 14, 2013 Posted August 14, 2013 -- this will create the xml file in which info will be holded. addEventHandler ("onResourceStart", getResourceRootElement (getThisResource ()), function () local fileInfo = xmlCreateFile ("unbaninfo.xml", "info"); assert (fileInfo, "Fail to create xml file"); xmlSaveFile (fileInfo); xmlUnloadFile (fileInfo); end); -- this will save info about the player who connects to the server. addEventHandler ("onUnban", getRootElement (), function ( theBan, responsibleElement ) -- get player info. if getElementType( responsibleElement ) then local name = getPlayerName( responsibleElement ); local whounban = getBanSerial(theBan) or getBanIP(theBan) -- open the file local fileInfo = xmlOpenFile ("unbaninfo.xml"); -- create a new node for this player. local node = xmlCreateChild (fileInfo, "player"); -- save info. xmlNodeSetAttribute (node, "name", name); xmlNodeSetAttribute (node, "whounban", whounban); xmlSaveFile (fileInfo); -- this will save all the changes done in the file. xmlUnloadFile (fileInfo); -- close file handle. end end); whats wrong? if body unban he not save in file xml
tosfera Posted August 14, 2013 Posted August 14, 2013 Why do you want to recreate a system that's already made?
Castillo Posted August 14, 2013 Posted August 14, 2013 You are using "xmlOpenFile" but the function is "xmlLoadFile".
Paplo Posted August 15, 2013 Author Posted August 15, 2013 You are using "xmlOpenFile" but the function is "xmlLoadFile". thanks it work ^^
Paplo Posted August 15, 2013 Author Posted August 15, 2013 in my server it work but in server online he said WARNING: whounban/server.lua:15 Bad 'element' pointer @ 'getElementType'(1) ??
xXMADEXx Posted August 15, 2013 Posted August 15, 2013 ((Not Tested)) -- this will create the xml file in which info will be holded. addEventHandler ("onResourceStart", getResourceRootElement (getThisResource ()), function () local fileInfo = xmlCreateFile ("unbaninfo.xml", "info"); assert (fileInfo, "Fail to create xml file"); xmlSaveFile (fileInfo); xmlUnloadFile (fileInfo); end); -- this will save info about the player who connects to the server. addEventHandler ("onUnban", getRootElement (), function ( theBan, responsibleElement ) -- get player info. if responsibleElement and getElementType( responsibleElement ) == 'player' then local name = getPlayerName( responsibleElement ); local whounban = getBanSerial(theBan) or getBanIP(theBan) -- open the file local fileInfo = xmlOpenFile ("unbaninfo.xml"); -- create a new node for this player. local node = xmlCreateChild (fileInfo, "player"); -- save info. xmlNodeSetAttribute (node, "name", name); xmlNodeSetAttribute (node, "whounban", whounban); xmlSaveFile (fileInfo); -- this will save all the changes done in the file. xmlUnloadFile (fileInfo); -- close file handle. end end);
Paplo Posted August 15, 2013 Author Posted August 15, 2013 ((Not Tested)) -- this will create the xml file in which info will be holded. addEventHandler ("onResourceStart", getResourceRootElement (getThisResource ()), function () local fileInfo = xmlCreateFile ("unbaninfo.xml", "info"); assert (fileInfo, "Fail to create xml file"); xmlSaveFile (fileInfo); xmlUnloadFile (fileInfo); end); -- this will save info about the player who connects to the server. addEventHandler ("onUnban", getRootElement (), function ( theBan, responsibleElement ) -- get player info. if responsibleElement and getElementType( responsibleElement ) == 'player' then local name = getPlayerName( responsibleElement ); local whounban = getBanSerial(theBan) or getBanIP(theBan) -- open the file local fileInfo = xmlOpenFile ("unbaninfo.xml"); -- create a new node for this player. local node = xmlCreateChild (fileInfo, "player"); -- save info. xmlNodeSetAttribute (node, "name", name); xmlNodeSetAttribute (node, "whounban", whounban); xmlSaveFile (fileInfo); -- this will save all the changes done in the file. xmlUnloadFile (fileInfo); -- close file handle. end end); not work
Paplo Posted August 15, 2013 Author Posted August 15, 2013 WARNING: whounban/server.lua:15 Bad 'element' pointer @ 'getElementType'(1)
Moderators IIYAMA Posted August 15, 2013 Moderators Posted August 15, 2013 If the element(player) isn't in the server, how the hell can you get the type of it?
Paplo Posted August 15, 2013 Author Posted August 15, 2013 If the element(player) isn't in the server, how the hell can you get the type of it? if getElementType( responsibleElement ) then --Check if a player unbanned the IP/Serial
tosfera Posted August 15, 2013 Posted August 15, 2013 If the element(player) isn't in the server, how the hell can you get the type of it? if getElementType( responsibleElement ) then --Check if a player unbanned the IP/Serial the getElementType returns a element's type, not a boolean. change it to; if ( getelementType ( responsibleElement ) == "player" ) then
Paplo Posted August 15, 2013 Author Posted August 15, 2013 If the element(player) isn't in the server, how the hell can you get the type of it? if getElementType( responsibleElement ) then --Check if a player unbanned the IP/Serial the getElementType returns a element's type, not a boolean. change it to; if ( getelementType ( responsibleElement ) == "player" ) then addEventHandler ("onResourceStart", getResourceRootElement (getThisResource ()), function () local fileInfo = xmlCreateFile ("unbaninfo.xml", "info"); assert (fileInfo, "Fail to create xml file"); xmlSaveFile (fileInfo); xmlUnloadFile (fileInfo); end); addEventHandler ("onUnban", getRootElement (), function ( theBan, responsibleElement ) if ( getelementType ( responsibleElement ) == "player" ) then local name = getPlayerName( responsibleElement ); local whounban = getBanSerial(theBan) or getBanIP(theBan) local fileInfo = xmlLoadFile ("unbaninfo.xml"); -- create a new node for this player. local node = xmlCreateChild (fileInfo, "player"); -- save info. xmlNodeSetAttribute (node, "name", name); xmlNodeSetAttribute (node, "whounban", whounban); xmlSaveFile (fileInfo); -- this will save all the changes done in the file. xmlUnloadFile (fileInfo); -- close file handle. end end ); ERROR:whounban/server.lua:11:attempt to call global'getelemetType'(a nil value)
tosfera Posted August 15, 2013 Posted August 15, 2013 it is getElementType. Lua is like alot of languages case sensitive.
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