HeK Posted November 16, 2012 Posted November 16, 2012 This script saves: money, skin, int, dem, health, armor, etc. But the only thing it doesn't save is "TEAM" i have tried doing some stuff, but can't get it to work. function playerLogin (thePreviousAccount, theCurrentAccount, autoLogin) if not (isGuestAccount (getPlayerAccount (source))) then local accountData = getAccountData (theCurrentAccount, "funmodev2-money") if (accountData) then local playerMoney = getAccountData (theCurrentAccount, "funmodev2-money") local playerSkin = getAccountData (theCurrentAccount, "funmodev2-skin") local playerHealth = getAccountData (theCurrentAccount, "funmodev2-health") local playerArmor = getAccountData (theCurrentAccount, "funmodev2-armor") local playerX = getAccountData (theCurrentAccount, "funmodev2-x") local playerY = getAccountData (theCurrentAccount, "funmodev2-y") local playerZ = getAccountData (theCurrentAccount, "funmodev2-z") local playerInt = getAccountData (theCurrentAccount, "funmodev2-int") local playerDim = getAccountData (theCurrentAccount, "funmodev2-dim") local playerWanted = getAccountData (theCurrentAccount, "funmodev2-wantedlevel") local playerTeam = getAccountData (theCurrentAccount, "funmodev2-team") spawnPlayer (source, playerX, playerY, playerZ +1, 0, playerSkin, playerInt, playerDim, playerTeam) setPlayerMoney (source, playerMoney) setTimer (setElementHealth, 500, 1, source, playerHealth) setTimer (setPedArmor, 500, 1, source, playerArmor) setTimer (setPlayerWantedLevel, 500, 1, source, playerWanted) setCameraTarget (source, source) fadeCamera(source, true, 2.0) setPlayerNametagColor (source, R, G, B) else spawnPlayer (source, -2263.802734375, 2303.1708984375, 4.8202133178711, 0,78, 0, 0) setPlayerMoney (source, 100000) setCameraTarget (source, source) fadeCamera(source, true, 2.0) end end end addEventHandler ("onPlayerLogin", getRootElement(), playerLogin) function onLogout () kickPlayer (source, nil, "Logging out is disallowed.") end addEventHandler ("onPlayerLogout", getRootElement(), onLogout) function onQuit (quitType, reason, responsibleElement) if not (isGuestAccount (getPlayerAccount (source))) then account = getPlayerAccount (source) if (account) then savePlayerWeapons(source) local x,y,z = getElementPosition (source) setAccountData (account, "funmodev2-money", tostring (getPlayerMoney (source))) setAccountData (account, "funmodev2-skin", tostring (getPedSkin (source))) setAccountData (account, "funmodev2-health", tostring (getElementHealth (source))) setAccountData (account, "funmodev2-armor", tostring (getPedArmor (source))) setAccountData (account, "funmodev2-x", x) setAccountData (account, "funmodev2-y", y) setAccountData (account, "funmodev2-z", z) setAccountData (account, "funmodev2-int", getElementInterior (source)) setAccountData (account, "funmodev2-dim", getElementDimension (source)) setAccountData (account, "funmodev2-wantedlevel", getPlayerWantedLevel (source)) setAccountData (account, "funmodev2-team", getPlayerTeam (source)) end end end addEventHandler ("onPlayerQuit", getRootElement(), onQuit) function onWasted(totalAmmo, killer, killerWeapon, bodypart, stealth) if not( isGuestAccount (getPlayerAccount(source)) ) then savePlayerWeapons(source) fadeCamera (source, false) setTimer (spawnPlayer, 1000, 1, source, 1606.9819335938, 1817.4609375, 10.8203125, 0, getPedSkin (source), 0, 0, getPlayerTeam(source)) setTimer (setCameraTarget, 1250, 1, source, source) setTimer (fadeCamera, 2000, 1, source, true) end end addEventHandler ("onPlayerWasted", getRootElement(), onWasted) function onSpawn() if not( isGuestAccount (getPlayerAccount(source)) ) then loadPlayerWeapons(source) end end addEventHandler ("onPlayerSpawn", getRootElement(), onSpawn) function savePlayerWeapons(player) local account = getPlayerAccount(player) if isGuestAccount(account) then return end local weaponsString = "" for index = 0, 12 do local weapon = getPedWeapon(player, index) local ammo = getPedTotalAmmo(player, index) if ammo > 0 then weaponsString = weaponsString..";"..weapon..","..ammo end end setAccountData(account, "weapons", weaponsString) end function loadPlayerWeapons(player) local account = getPlayerAccount(player) if isGuestAccount(account) then return end local weaponsString = getAccountData(account, "weapons") takeAllWeapons(player) for index, wData in pairs(split(weaponsString, ";")) do local weapon, ammo = unpack(split(wData, ",")) weapon, ammo = tonumber(weapon), tonumber(ammo) if weapon and weapon ~= 0 and ammo and ammo ~= 0 then giveWeapon(player, weapon, ammo) end end end Zero is a number too.
Castillo Posted November 16, 2012 Posted November 16, 2012 Because you are saving the team element userdata value, not the team name. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
HeK Posted November 16, 2012 Author Posted November 16, 2012 Then how should i do it? Any tips? Zero is a number too.
Castillo Posted November 16, 2012 Posted November 16, 2012 Firstly, intead of save getPlayerTeam result, do getTeamName ( getPlayerTeam ( source ) ) then, you get the team element from it's name with getTeamFromName San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
HeK Posted November 17, 2012 Author Posted November 17, 2012 Well, i really didn't understand, could you make an example or something? Zero is a number too.
Castillo Posted November 17, 2012 Posted November 17, 2012 I already did. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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