SHARE
TWEET

Untitled

a guest May 15th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- using local db now; much shorter code
  2.  
  3. --[[
  4. loadPlayerData( Player ply )
  5.     will load the player's data
  6. ]]
  7. local function loadPlayerData( ply )
  8.     local data = {
  9.         unspent = ply:GetPData( "skillsys_unspent", 0 ),
  10.         speed = ply:GetPData( "skillsys_speed", 0 ),
  11.         jump = ply:GetPData( "skillsys_jump", 0 ),
  12.         health = ply:GetPData( "skillsys_health", 0 ),
  13.         armor = ply:GetPData( "skillsys_armor", 0 )
  14.     }
  15.  
  16.     ply._skills = _ssys.Skill( ply, data )
  17.     ply._skills:Network()
  18.    
  19.     local s = ply._skills
  20.     local totalSkillPts = s._unspent + s._speed + s._jump + s._health + s._armor
  21.  
  22.     if ( totalSkillPts < ply:getLevel() ) then
  23.         local dif = ply:getLevel() - totalSkillsPts
  24.         ply._skills:AddUnspent( dif )
  25.     end
  26.  
  27.     ply._defaultspeed = ply:GetRunSpeed()
  28.     ply._defaultjump = ply:GetJumpPower()
  29.  
  30.     ply._skills:UpdateOwnerSpeed()
  31.     ply._skills:UpdateOwnerJump()
  32.     ply._skills:UpdateOwnerHealth()
  33.     ply._skills:UpdateOwnerArmor()
  34. end
  35. hook.Add( "PlayerInitialSpawn", "skillsys_ply_skills_init", loadPlayerData )
  36.  
  37. --[[
  38. exportPlayerData( Player ply )
  39.     will export the player's data
  40. ]]
  41. local function exportPlayerData( ply )
  42.     ply:SetPData( "skillsys_unspent", ply._skills:GetUnspent() )
  43.     ply:SetPData( "skillsys_speed", ply._skills:GetSpeed() )
  44.     ply:SetPData( "skillsys_jump", ply._skills:GetJump() )
  45.     ply:SetPData( "skillsys_health", ply._skills:GetHealth() )
  46.     ply:SetPData( "skillsys_armor", ply._skills:GetArmor() )
  47. end
  48. hook.Add( "PlayerDisconnected", "skillsys_ply_skills_export", exportPlayerData )
  49.  
  50. concommand.Add( "displayPts", function( ply )
  51.     print( "\tUnspent: " .. ply._skills._unspent )
  52.     print( "\tSpeed: " .. ply._skills._speed )
  53.     print( "\tJump: " .. ply._skills._jump )
  54.     print( "\tHealth: " .. ply._skills._health )
  55.     print( "\tArmor: " .. ply._skills._armor )
  56. end )
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top