Paplo Posted August 14, 2013 Share 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 Link to comment
tosfera Posted August 14, 2013 Share Posted August 14, 2013 Why do you want to recreate a system that's already made? Link to comment
Castillo Posted August 14, 2013 Share Posted August 14, 2013 You are using "xmlOpenFile" but the function is "xmlLoadFile". Link to comment
Paplo Posted August 15, 2013 Author Share Posted August 15, 2013 You are using "xmlOpenFile" but the function is "xmlLoadFile". thanks it work ^^ Link to comment
Paplo Posted August 15, 2013 Author Share 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) ?? Link to comment
xXMADEXx Posted August 15, 2013 Share 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); Link to comment
Paplo Posted August 15, 2013 Author Share 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 Link to comment
Paplo Posted August 15, 2013 Author Share Posted August 15, 2013 WARNING: whounban/server.lua:15 Bad 'element' pointer @ 'getElementType'(1) Link to comment
Moderators IIYAMA Posted August 15, 2013 Moderators Share Posted August 15, 2013 If the element(player) isn't in the server, how the hell can you get the type of it? Link to comment
Paplo Posted August 15, 2013 Author Share 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 Link to comment
tosfera Posted August 15, 2013 Share 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 Link to comment
Paplo Posted August 15, 2013 Author Share 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) Link to comment
tosfera Posted August 15, 2013 Share Posted August 15, 2013 it is getElementType. Lua is like alot of languages case sensitive. 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