AHSS Posted March 26, 2011 Share Posted March 26, 2011 i got this code -- when a player login (the function is not the problem cuz other codes work and other loads work) local w1 = xmlNodeGetAttribute(pfile, "weapon1") local w2 = xmlNodeGetAttribute(pfile, "weapon2") local w3 = xmlNodeGetAttribute(pfile, "weapon3") local w4 = xmlNodeGetAttribute(pfile, "weapon4") local w5 = xmlNodeGetAttribute(pfile, "weapon5") local w6 = xmlNodeGetAttribute(pfile, "weapon6") local w7 = xmlNodeGetAttribute(pfile, "weapon7") local w8 = xmlNodeGetAttribute(pfile, "weapon8") local w9 = xmlNodeGetAttribute(pfile, "weapon9") local w10 = xmlNodeGetAttribute(pfile, "weapon10") local w11 = xmlNodeGetAttribute(pfile, "weapon11") local w12 = xmlNodeGetAttribute(pfile, "weapon12") local a1 = xmlNodeGetAttribute(pfile, "ammo1") local a2 = xmlNodeGetAttribute(pfile, "ammo2") local a3 = xmlNodeGetAttribute(pfile, "ammo3") local a4 = xmlNodeGetAttribute(pfile, "ammo4") local a5 = xmlNodeGetAttribute(pfile, "ammo5") local a6 = xmlNodeGetAttribute(pfile, "ammo6") local a7 = xmlNodeGetAttribute(pfile, "ammo7") local a8 = xmlNodeGetAttribute(pfile, "ammo8") local a9 = xmlNodeGetAttribute(pfile, "ammo9") local a10 = xmlNodeGetAttribute(pfile, "ammo10") local a11 = xmlNodeGetAttribute(pfile, "ammo11") local a12 = xmlNodeGetAttribute(pfile, "ammo12") giveWeapon(source, tonumber(w1), tonumber(a1)) giveWeapon(source, tonumber(w2), tonumber(a2)) giveWeapon(source,tonumber(w3), tonumber(a3)) giveWeapon(source, tonumber(w4), tonumber(a4)) giveWeapon(source, tonumber(w5), tonumber(a5)) giveWeapon(source, tonumber(w6), tonumber(a6)) giveWeapon(source, tonumber(w7), tonumber(a7)) giveWeapon(source, tonumber(w8), tonumber(a8)) giveWeapon(source, tonumber(w9), tonumber(a9)) giveWeapon(source, tonumber(w10), tonumber(a10)) giveWeapon(source, tonumber(w11), tonumber(a11)) giveWeapon(source, tonumber(w12), tonumber(a12)) thats it also the saving code is not the problem cuz i see the save file has (weapon1="id") so the saving work oh almost forgot it also gives me a warning on each giveWeapon i got why please help Link to comment
Moderators Citizen Posted March 26, 2011 Moderators Share Posted March 26, 2011 Maybe the source is wrong ? Link to comment
AHSS Posted March 26, 2011 Author Share Posted March 26, 2011 i did this function savestats() --then here the code in the first post end that what i did why its not working all the problem that i dont get the weapon PS: THE SAVING IS WORKING Link to comment
Moderators Citizen Posted March 26, 2011 Moderators Share Posted March 26, 2011 But here it's not the saving but the loading not ? if all xmlNodeGetAttribute works, the problem is the source. if the source is correct, it's your xmlNodeGetAttribute but you said: oh almost forgot it also gives me a warning on each giveWeapon i got so the problem is not in the xmlNodeGetAttribute => so it's the source Write the warning here plz and tell me how do you call this function Link to comment
AHSS Posted March 26, 2011 Author Share Posted March 26, 2011 ok ok i will give u all the codes first the saving (it works it do saves and i see it in the file) PS: GPN function is a function that i did it gets the player name and store it in pname function savepstats() GPN(source) local pfile = xmlLoadFile("RPG-Files/"..pname..".xml") if(pfile) then local pmoney = getPlayerMoney(source) local pteam = getPlayerTeam" class="kw2">getPlayerTeam(source) local pskin = getPedSkin(source) local alevel = getElementData(source, "alevel") local pip = getPlayerIP(source) xmlNodeSetAttribute(pfile, "money", pmoney) if(pteam) then local pteamname = getTeamName(pteam) xmlNodeSetAttribute(pfile, "teamname", pteamname) else xmlNodeSetAttribute(pfile, "teamname", "null") end xmlNodeSetAttribute(pfile, "skin", pskin) xmlNodeSetAttribute(pfile, "alevel", tostring(alevel)) xmlNodeSetAttribute(pfile, "ip", pip) for slot=0, 12 do if (getPedWeapon(source, slot) ~= 0) then local weapon = getPedWeapon(source, slot) local ammo = getPedTotalAmmo(source, slot) xmlNodeSetAttribute(pfile, "weapon"..slot, weapon) xmlNodeSetAttribute(pfile, "ammo"..slot, ammo) end end xmlSaveFile(pfile) end end addEventHandler("onPlayerQuit", getRootElement(), savepstats) ok now loading iam making a auto login system when a player connects he login automatically here is the code : function JoinHandler() GPN(source) local pfile = xmlLoadFile("RPG-Files/"..pname..".xml") if(pfile) then outputChatBox("#00FF00 You are registered and automatically logged in", source, 0, 0, 0, true) local pmoney = xmlNodeGetAttribute(pfile, "money") local pteamname = xmlNodeGetAttribute(pfile, "teamname") if(pteamname ~= "null") then local pteam = getTeamFromName(pteamname) setPlayerTeam" class="kw6">setPlayerTeam(source, pteam) end local pskin = xmlNodeGetAttribute(pfile, "skin") local alevel = xmlNodeGetAttribute(pfile, "alevel") local w1 = xmlNodeGetAttribute(pfile, "weapon1") local w2 = xmlNodeGetAttribute(pfile, "weapon2") local w3 = xmlNodeGetAttribute(pfile, "weapon3") local w4 = xmlNodeGetAttribute(pfile, "weapon4") local w5 = xmlNodeGetAttribute(pfile, "weapon5") local w6 = xmlNodeGetAttribute(pfile, "weapon6") local w7 = xmlNodeGetAttribute(pfile, "weapon7") local w8 = xmlNodeGetAttribute(pfile, "weapon8") local w9 = xmlNodeGetAttribute(pfile, "weapon9") local w10 = xmlNodeGetAttribute(pfile, "weapon10") local w11 = xmlNodeGetAttribute(pfile, "weapon11") local w12 = xmlNodeGetAttribute(pfile, "weapon12") local a1 = xmlNodeGetAttribute(pfile, "ammo1") local a2 = xmlNodeGetAttribute(pfile, "ammo2") local a3 = xmlNodeGetAttribute(pfile, "ammo3") local a4 = xmlNodeGetAttribute(pfile, "ammo4") local a5 = xmlNodeGetAttribute(pfile, "ammo5") local a6 = xmlNodeGetAttribute(pfile, "ammo6") local a7 = xmlNodeGetAttribute(pfile, "ammo7") local a8 = xmlNodeGetAttribute(pfile, "ammo8") local a9 = xmlNodeGetAttribute(pfile, "ammo9") local a10 = xmlNodeGetAttribute(pfile, "ammo10") local a11 = xmlNodeGetAttribute(pfile, "ammo11") local a12 = xmlNodeGetAttribute(pfile, "ammo12") givePlayerMoney(source, pmoney) setPedSkin(source, pskin) giveWeapon(source, tonumber(w1), tonumber(a1)) giveWeapon(source, tonumber(w2), tonumber(a2)) giveWeapon(source,tonumber(w3), tonumber(a3)) giveWeapon(source, tonumber(w4), tonumber(a4)) giveWeapon(source, tonumber(w5), tonumber(a5)) giveWeapon(source, tonumber(w6), tonumber(a6)) giveWeapon(source, tonumber(w7), tonumber(a7)) giveWeapon(source, tonumber(w8), tonumber(a8)) giveWeapon(source, tonumber(w9), tonumber(a9)) giveWeapon(source, tonumber(w10), tonumber(a10)) giveWeapon(source, tonumber(w11), tonumber(a11)) giveWeapon(source, tonumber(w12), tonumber(a12)) setElementData(source, "alevel", tostring(alevel)) if(alevel == "1" or alevel == "2" or alevel == "3" or alevel == "4") then outputChatBox("#41A317 Admin "..pname.." has logged in . Admin level "..alevel.." !", getRootElement(), 0, 0, 0, true) end else outputChatBox("#FFFFFF You are not registered please use /register ", source, 0, 0, 0, true) end end addEventHandler("onPlayerJoin", getRootElement(), JoinHandler) so this is it problem is that the weapons is not given to the player but every thing else works like saving the player team and loading it works money also works so the problem is in weapons all i get is warnings WARINING: it gives me bad argument @ "giveWeapon" Link to comment
Moderators Citizen Posted March 26, 2011 Moderators Share Posted March 26, 2011 local pfile = xmlLoadFile("RPG-Files/"..pname..".xml") where pname is defined ? But you said that the warnings are in the giveWeapon so pname is defined but where ? ( it's not the full code ?? ) Try with this: local pname = getPlayerFromName( source ) local pfile = xmlLoadFile("RPG-Files/"..pname..".xml") Link to comment
Castillo Posted March 27, 2011 Share Posted March 27, 2011 You should use xmlUnloadFile after saving it! if i'm right it can cause problems. 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