Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
529
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.02 KB | None | 0 0
  1.  
  2. util.AddNetworkString( "RP.NetStrings.SteamRewards" )
  3.  
  4. local function Rewards_Setup()
  5. sql.Query("CREATE TABLE IF NOT EXISTS myrp_steamrewards(steam char(20) NOT NULL, value INTEGER NOT NULL, PRIMARY KEY(steam));")
  6. print"table created!"
  7. end
  8. hook.Add("InitPostEntity","REWARDS_InitSetupDatabase", Rewards_Setup)
  9.  
  10. local function GroupJoin(ply)
  11. if not IsValid(ply) then return end
  12. sql.Query("INSERT INTO myrp_steamrewards VALUES(" .. sql.SQLStr(ply:SteamID64()) .. ", " .. 1 .. ");")
  13. UpdateDefaultStatsSteamRewards(ply)
  14. DarkRP.notifyAll( 1, 4, ply:Nick() .. " has joined the steam group and has been rewarded 20,000$ RP Cash!" )
  15. end
  16.  
  17. local function GroupLeave(ply)
  18. if not IsValid(ply) then return end
  19. sql.Query("DELETE FROM myrp_steamrewards WHERE steam = " .. sql.SQLStr(ply:SteamID64()) .. ";")
  20. end
  21.  
  22. local function IsInGroup(ply)
  23. if not IsValid(ply) then return end
  24. local r = sql.QueryValue("SELECT value FROM myrp_steamrewards WHERE steam = " .. sql.SQLStr(ply:SteamID64()) .. ";")
  25. if r and (tonumber(r) == 1) then return true
  26. else return false end
  27. end
  28.  
  29. local function ClearAllRecords()
  30. sql.Query("DELETE FROM myrp_steamrewards ;")
  31. end
  32.  
  33. local function CommunityCheckStatus( ply, bt )
  34. if !IsValid(ply) then return end
  35. local id = util.SteamIDTo64( ply:SteamID() )
  36. http.Fetch( STEAM_REWARDS.CONFIG.SteamGroup .. "memberslistxml/?xml=1&lolwat="..os.time(), function( body, _, _, _ )
  37. if string.find( body, id ) && !IsInGroup(ply) then
  38. ply:ChatPrint( "You have successfully joined our Steam Group!" )
  39. GroupJoin(ply)
  40. ply:addMoney( 20000 )
  41. end
  42. end,
  43. function( error )
  44. ply:ChatPrint( "Something went terribly wrong!" )
  45. print( error )
  46. end
  47. )
  48. end
  49.  
  50. local function UpdateDefaultStatsSteamRewards(ply)
  51.  
  52. local IsUser = ( ply:GetUserGroup() == STEAM_REWARDS.CONFIG.UserRankString )
  53. local RankPropCount = STEAM_REWARDS.CONFIG.PropLimitTable[ ply:GetUserGroup() ]
  54.  
  55. // If we are a user, set our new prop limit
  56. if IsUser then
  57.  
  58. // If we are in the group, set the prop limit to 40!
  59. if IsInGroup(ply) then
  60. ply.rewards_MaxProps = 40
  61. else
  62. // If we are NOT in the group, then we go down to 15!
  63. ply.rewards_MaxProps = 10
  64. end
  65.  
  66. elseif !IsUser && RankPropCount then
  67.  
  68. // If we are NOT a user, then we just set our prop limit count to what we have set in the Config!
  69. ply.rewards_MaxProps = RankPropCount
  70.  
  71. end
  72.  
  73. end
  74.  
  75. local function PlayerSpawnPropMaxPropsSB( ply, model )
  76.  
  77. local PropCount = ply:GetCount( "props" )
  78. local hitLimit = ( PropCount >= ply.rewards_MaxProps )
  79.  
  80. if hitLimit && !ply:IsSuperAdmin() then
  81.  
  82. DarkRP.notify( ply, 1, 4, "You have hit the max prop limit!" )
  83. return false
  84.  
  85. elseif hitLimit && ply:IsSuperAdmin() then
  86.  
  87. DarkRP.notify( ply, 1, 4, "Fuck limits, you're a Super Admin!" )
  88. return true
  89.  
  90. end
  91.  
  92. end
  93.  
  94. // Set the new Prop Limit
  95. hook.Add("InitPostEntity", "RP.UpdateDefaultMaxPropsSB", function()
  96. RunConsoleCommand("sbox_maxprops", "9999")
  97. hook.Add("PlayerSpawnProp", "RP.PlayerSpawnPropMaxPropsSB", PlayerSpawnPropMaxPropsSB )
  98. hook.Add("PlayerInitialSpawn", "RP.UpdateDefaultStatsSteamRewards", UpdateDefaultStatsSteamRewards )
  99. end)
  100.  
  101.  
  102. DarkRP.defineChatCommand("joinsteamgroup", function(ply)
  103. //if !IsInGroup(ply) then return end
  104. net.Start( "RP.NetStrings.SteamRewards" )
  105. net.Send( ply )
  106. end)
  107.  
  108. hook.Add("playerCanChangeTeam", "SteamGroupMemberCheck.playerCanChangeTeam", function(ply, t, force)
  109.  
  110. local TEAM = RPExtraTeams[t]
  111.  
  112. if ( ply:GetUserGroup() == STEAM_REWARDS.CONFIG.UserRankString ) && table.HasValue( STEAM_REWARDS.CONFIG.RestrictedJobs, TEAM.name ) && !IsInGroup(ply) then
  113. net.Start( "RP.NetStrings.SteamRewards" )
  114. net.Send( ply )
  115. return false, "You must of joined our Steam Group & been validated to join this job!"
  116. end
  117.  
  118. end)
  119.  
  120. timer.Create( "RP.Timers.CheckPlayerSteamRewards", 10, 0, function()
  121. for i = 1, #player.GetAll() do
  122. local v = player.GetAll()[i]
  123. if IsValid(v) then
  124. CommunityCheckStatus( v, false )
  125. end
  126. end
  127. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement