--[[
Hello downloader:>
When you want to set something to the "character data", you need to do the following things
local accountName = getAccountName(getPlayerAccount(source))
local characterindex = getCharacterIndexByCharacterName (accountName,charactername)
local root = xmlLoadFile ("players.xml")
local playerRoot = xmlFindChild (root,"player",findPlayerIndexByName(accountName))
if (characterindex) then
local characterRoot = xmlNodeGetChildren (playerRoot,tonumber(characterindex)-1)
xmlNodeSetAttirbute (characterRoot,"tag",thingyouwanttosave) -- You can load with this
local loadedpart = xmlNodeGetAttirbute (characterRoot,"tag") -- You can load with this
end
]]--
addEvent ("lolmodLoginPlayer",true)
addEventHandler ("lolmodLoginPlayer",getRootElement(),
function(username,password)
local account = getAccount (username,password)
if (account) then
logIn (source,account,password)
local root = xmlLoadFile ("players.xml")
if (xmlFindChild (root,"player",findPlayerIndexByName (tostring(username)))) then
local playerNode = xmlFindChild (root,"player",findPlayerIndexByName (tostring(username)))
triggerClientEvent ("lolmodOpenInfoWindow",source,"Welcome back! click your character to start!")
local character = xmlNodeGetChildren (playerNode)
if (character[3]) then
triggerClientEvent (source,"lolmodOpenCharacterSelectWindow",source,username,xmlNodeGetAttribute(character[1],"name"),xmlNodeGetAttribute(character[2],"name"),xmlNodeGetAttribute(character[3],"name"))
elseif (character[2]) then
triggerClientEvent (source,"lolmodOpenCharacterSelectWindow",source,username,xmlNodeGetAttribute(character[1],"name"),xmlNodeGetAttribute(character[2],"name"))
elseif (character[1]) then
triggerClientEvent (source,"lolmodOpenCharacterSelectWindow",source,username,xmlNodeGetAttribute(character[1],"name"))
else
triggerClientEvent (source,"lolmodOpenCharacterSelectWindow",source,username)
end
else
local playerNode = xmlCreateChild (root,"player")
xmlNodeSetAttribute (playerNode,"name",tostring(username))
triggerClientEvent ("lolmodOpenInfoWindow",source,"Welcome!\nWe see it's your first time here, welcome to Lolmode!\nYou haven't got a character yet, but you can make one when you click New Character!\nGood luck in the game!")
triggerClientEvent (source,"lolmodOpenCharacterSelectWindow",source,username)
xmlSaveFile (root)
end
xmlUnloadFile (root)
else
triggerClientEvent (source,"lolmodOpenInfoWindow",source,"Sorry, your login values are invalid!\n\nMake sure the account is exist, and if the password is spelled well.\nThere also are some illegal strings, these you mayn't have in your name. Only A-Z a-z _ - and 0-9 (When you found a string which isn't in, we aren't responsible for when you lose all data!)\nsorry for the inconvenience.")
end
end)
-- © JasperNL=D
addEvent ("lolmodRegisterPlayer",true)
addEventHandler ("lolmodRegisterPlayer",getRootElement(),
function(username,password)
local account = getAccount (username)
if (account) then
triggerClientEvent ("lolmodOpenInfoWindow",source,"We're sorry, but this account is already in use!\nPlease take another one \n\nNOTE: This is not your in-game name! so every name is good :D")
else
addAccount (username,password)
triggerClientEvent ("lolmodOpenInfoWindow",source,"That's all! Your account is registered! You can log in now by clicking the Log In! button! then you can create a character which you play the game with!\nGood luck!")
end
end)
-- © JasperNL=D
addEvent ("lolmodSpawnCharacter",true)
addEventHandler ("lolmodSpawnCharacter",getRootElement(),
function(charactername)
if (charactername) then
local accountName = getAccountName(getPlayerAccount(source))
local characterindex = getCharacterIndexByCharacterName (accountName,charactername)
local root = xmlLoadFile ("players.xml")
local playerRoot = xmlFindChild (root,"player",findPlayerIndexByName(accountName))
if (characterindex) then
local characterRoot = xmlNodeGetChildren (playerRoot,tonumber(characterindex)-1)
spawnPlayer (source,tonumber(xmlNodeGetAttribute (characterRoot,"px")),tonumber(xmlNodeGetAttribute (characterRoot,"py")),tonumber(xmlNodeGetAttribute (characterRoot,"pz")),0,tonumber(xmlNodeGetAttribute (characterRoot,"skin")),tonumber(xmlNodeGetAttribute (characterRoot,"pi")),tonumber(xmlNodeGetAttribute (characterRoot,"pd")),nil)
toggleControl (source,"chatbox",true)
createBlipAttachedTo (source,0,2,tonumber(xmlNodeGetAttribute (characterRoot,"cr")),tonumber(xmlNodeGetAttribute (characterRoot,"cg")),tonumber(xmlNodeGetAttribute (characterRoot,"cb")),255)
setPlayerMoney (source,tonumber(xmlNodeGetAttribute (characterRoot,"cash")))
setPlayerNametagText (source,tostring(xmlNodeGetAttribute (characterRoot,"name")))
setPlayerNametagColor (source,tonumber(xmlNodeGetAttribute (characterRoot,"cr")),tonumber(xmlNodeGetAttribute (characterRoot,"cg")),tonumber(xmlNodeGetAttribute (characterRoot,"cb")))
setPedArmor (source,tonumber(xmlNodeGetAttribute (characterRoot,"armor")))
setElementHealth (source,tonumber(xmlNodeGetAttribute (characterRoot,"health")))
local weapons = xmlFindChild (characterRoot,"weapons",0)
if (weapons) then
local weapon = xmlNodeGetAttributes (weapons)
giveWeapon (source,weapon["w"],weapon["wammo"],true)
end
setCameraTarget (source,source)
outputChatBox (getPlayerNametagText (source) .. "#FF0000 has joined the game [Logged In]",getRootElement(),255,0,0,true)
local cash = xmlNodeGetAttribute (characterRoot,"cash")
local bank = xmlNodeGetAttribute (characterRoot,"bank")
local housenumber = xmlNodeGetAttribute (characterRoot,"house")
if not (housenumber) then
local housenumber = nil
local housenumber = "No house Availible"
end
triggerClientEvent (source,"lolmodHideCharacterSelectWindow",source)
triggerClientEvent (source,"lolmodRefreshBankInfoMenu",source,cash,bank,housenumber)
xmlUnloadFile (root)
end
else
triggerClientEvent ("lolmodOpenInfoWindow",source,"You need to select a character first!")
end
end)
-- © JasperNL=D
addEvent ("createNewCharacter",true)
addEventHandler ("createNewCharacter",getRootElement(),
function(skin,colred,colgreen,colblue,charactername)
local accountName = getAccountName (getPlayerAccount(source))
if (getCharacterCount (accountName) < 3) then
if not (checkCharacterNameIsFake(charactername) == "FAKE") then
local root = xmlLoadFile ("players.xml")
local playerRoot = xmlFindChild (root,"player",findPlayerIndexByName (tostring(accountName)))
local newCharacter = xmlCreateChild (playerRoot,"character")
xmlNodeSetAttribute (newCharacter,"name",charactername)
xmlNodeSetAttribute (newCharacter,"skin",skin)
xmlNodeSetAttribute (newCharacter,"cr",colred)
xmlNodeSetAttribute (newCharacter,"cg",colgreen)
xmlNodeSetAttribute (newCharacter,"cb",colblue)
xmlNodeSetAttribute (newCharacter,"px",2000.51)
xmlNodeSetAttribute (newCharacter,"py",1567.37)
xmlNodeSetAttribute (newCharacter,"pz",15.367185)
xmlNodeSetAttribute (newCharacter,"pi",0)
xmlNodeSetAttribute (newCharacter,"pd",0)
xmlNodeSetAttribute (newCharacter,"cash",1000)
xmlNodeSetAttribute (newCharacter,"bank",1500)
setTimer (logOut,1000,1,source)
xmlSaveFile (root)
xmlUnloadFile (root)
else
triggerClientEvent ("lolmodOpenInfoWindow",source,"Sorry, this character name is already in use.")
end
else
triggerClientEvent ("lolmodOpenInfoWindow",source,"Sorry, the character max is 3 characters!\nYou have: 3 characters!\nYou can't add new ones any more!")
end
end)
-- © JasperNL=D
function getCharacterIndexByCharacterName (playeraccountname,charactername)
local root = xmlLoadFile ("players.xml")
local playerRoot = xmlFindChild (root,"player",findPlayerIndexByName (playeraccountname))
local allCharacters = xmlNodeGetChildren (playerRoot)
j = 0
for i,v in ipairs (allCharacters) do
j = j+1
if (xmlNodeGetAttribute (v,"name") == charactername) then
return j
end
end
xmlUnloadFile (root)
end
-- © JasperNL=D
function getCharacterCount (playeraccountname)
local root = xmlLoadFile ("players.xml")
local playerRoot = xmlFindChild (root,"player",findPlayerIndexByName (playeraccountname))
local allCharacters = xmlNodeGetChildren (playerRoot)
if (allCharacters) then
k = 0
for i,v in ipairs (allCharacters) do
i keep getting this error mesage and i have attempted it
[2011-01-08 05:07:27] WARNING: lolmode\gui_s.lua:152: Bad argument @ 'xmlNodeFindChild'
[2011-01-08 05:07:27] WARNING: lolmode\gui_s.lua:153: Bad argument @ 'xmlNodeGetChildren'
[2011-01-08 05:07:27] ERROR: lolmode\gui_s.lua:155: bad argument #1 to 'ipairs' (table expected, got boolean)
[2011-01-08 05:07:42] WARNING: lolmode\gui_s.lua:168: Bad argument @ 'xmlNodeFindChild'
[2011-01-08 05:07:42] WARNING: lolmode\gui_s.lua:169: Bad argument @ 'xmlNodeGetChildren'
[2011-01-08 05:07:42] WARNING: lolmode\gui_s.lua:123: Bad argument @ 'xmlNodeFindChild'
[2011-01-08 05:07:42] WARNING: lolmode\gui_s.lua:124: Bad argument @ 'xmlCreateChild'
[2011-01-08 05:07:42] WARNING: lolmode\gui_s.lua:125: Bad argument @ 'xmlNodeSetAttribute'
[2011-01-08 05:07:42] WARNING: lolmode\gui_s.lua:126: Bad argument @ 'xmlNodeSetAttribute'
[2011-01-08 05:07:42] WARNING: lolmode\gui_s.lua:127: Bad argument @ 'xmlNodeSetAttribute'
[2011-01-08 05:07:42] WARNING: lolmode\gui_s.lua:128: Bad argument @ 'xmlNodeSetAttribute'
[2011-01-08 05:07:42] WARNING: lolmode\gui_s.lua:129: Bad argument @ 'xmlNodeSetAttribute'
[2011-01-08 05:07:42] WARNING: lolmode\gui_s.lua:130: Bad argument @ 'xmlNodeSetAttribute'
[2011-01-08 05:07:42] WARNING: lolmode\gui_s.lua:131: Bad argument @ 'xmlNodeSetAttribute'
[2011-01-08 05:07:42] WARNING: lolmode\gui_s.lua:132: Bad argument @ 'xmlNodeSetAttribute'
[2011-01-08 05:07:42] WARNING: lolmode\gui_s.lua:133: Bad argument @ 'xmlNodeSetAttribute'
[2011-01-08 05:07:42] WARNING: lolmode\gui_s.lua:134: Bad argument @ 'xmlNodeSetAttribute'
[2011-01-08 05:07:42] WARNING: lolmode\gui_s.lua:135: Bad argument @ 'xmlNodeSetAttribute'
[2011-01-08 05:07:42] WARNING: lolmode\gui_s.lua:136: Bad argument @ 'xmlNodeSetAttribute'