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? If you want to contact me directly concerning Advanced-Gaming, please contact me at [email protected]
Castillo Posted August 14, 2013 Posted August 14, 2013 You are using "xmlOpenFile" but the function is "xmlLoadFile". San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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); The Ultimate Lua Tutorial! | MTA PHP SDK
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? Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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 If you want to contact me directly concerning Advanced-Gaming, please contact me at [email protected]
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. If you want to contact me directly concerning Advanced-Gaming, please contact me at [email protected]
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