Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- util.AddNetworkString( "RP.NetStrings.SteamRewards" )
- local function Rewards_Setup()
- sql.Query("CREATE TABLE IF NOT EXISTS myrp_steamrewards(steam char(20) NOT NULL, value INTEGER NOT NULL, PRIMARY KEY(steam));")
- print"table created!"
- end
- hook.Add("InitPostEntity","REWARDS_InitSetupDatabase", Rewards_Setup)
- local function GroupJoin(ply)
- if not IsValid(ply) then return end
- sql.Query("INSERT INTO myrp_steamrewards VALUES(" .. sql.SQLStr(ply:SteamID64()) .. ", " .. 1 .. ");")
- UpdateDefaultStatsSteamRewards(ply)
- DarkRP.notifyAll( 1, 4, ply:Nick() .. " has joined the steam group and has been rewarded 20,000$ RP Cash!" )
- end
- local function GroupLeave(ply)
- if not IsValid(ply) then return end
- sql.Query("DELETE FROM myrp_steamrewards WHERE steam = " .. sql.SQLStr(ply:SteamID64()) .. ";")
- end
- local function IsInGroup(ply)
- if not IsValid(ply) then return end
- local r = sql.QueryValue("SELECT value FROM myrp_steamrewards WHERE steam = " .. sql.SQLStr(ply:SteamID64()) .. ";")
- if r and (tonumber(r) == 1) then return true
- else return false end
- end
- local function ClearAllRecords()
- sql.Query("DELETE FROM myrp_steamrewards ;")
- end
- local function CommunityCheckStatus( ply, bt )
- if !IsValid(ply) then return end
- local id = util.SteamIDTo64( ply:SteamID() )
- http.Fetch( STEAM_REWARDS.CONFIG.SteamGroup .. "memberslistxml/?xml=1&lolwat="..os.time(), function( body, _, _, _ )
- if string.find( body, id ) && !IsInGroup(ply) then
- ply:ChatPrint( "You have successfully joined our Steam Group!" )
- GroupJoin(ply)
- ply:addMoney( 20000 )
- end
- end,
- function( error )
- ply:ChatPrint( "Something went terribly wrong!" )
- print( error )
- end
- )
- end
- local function UpdateDefaultStatsSteamRewards(ply)
- local IsUser = ( ply:GetUserGroup() == STEAM_REWARDS.CONFIG.UserRankString )
- local RankPropCount = STEAM_REWARDS.CONFIG.PropLimitTable[ ply:GetUserGroup() ]
- // If we are a user, set our new prop limit
- if IsUser then
- // If we are in the group, set the prop limit to 40!
- if IsInGroup(ply) then
- ply.rewards_MaxProps = 40
- else
- // If we are NOT in the group, then we go down to 15!
- ply.rewards_MaxProps = 10
- end
- elseif !IsUser && RankPropCount then
- // If we are NOT a user, then we just set our prop limit count to what we have set in the Config!
- ply.rewards_MaxProps = RankPropCount
- end
- end
- local function PlayerSpawnPropMaxPropsSB( ply, model )
- local PropCount = ply:GetCount( "props" )
- local hitLimit = ( PropCount >= ply.rewards_MaxProps )
- if hitLimit && !ply:IsSuperAdmin() then
- DarkRP.notify( ply, 1, 4, "You have hit the max prop limit!" )
- return false
- elseif hitLimit && ply:IsSuperAdmin() then
- DarkRP.notify( ply, 1, 4, "Fuck limits, you're a Super Admin!" )
- return true
- end
- end
- // Set the new Prop Limit
- hook.Add("InitPostEntity", "RP.UpdateDefaultMaxPropsSB", function()
- RunConsoleCommand("sbox_maxprops", "9999")
- hook.Add("PlayerSpawnProp", "RP.PlayerSpawnPropMaxPropsSB", PlayerSpawnPropMaxPropsSB )
- hook.Add("PlayerInitialSpawn", "RP.UpdateDefaultStatsSteamRewards", UpdateDefaultStatsSteamRewards )
- end)
- DarkRP.defineChatCommand("joinsteamgroup", function(ply)
- //if !IsInGroup(ply) then return end
- net.Start( "RP.NetStrings.SteamRewards" )
- net.Send( ply )
- end)
- hook.Add("playerCanChangeTeam", "SteamGroupMemberCheck.playerCanChangeTeam", function(ply, t, force)
- local TEAM = RPExtraTeams[t]
- if ( ply:GetUserGroup() == STEAM_REWARDS.CONFIG.UserRankString ) && table.HasValue( STEAM_REWARDS.CONFIG.RestrictedJobs, TEAM.name ) && !IsInGroup(ply) then
- net.Start( "RP.NetStrings.SteamRewards" )
- net.Send( ply )
- return false, "You must of joined our Steam Group & been validated to join this job!"
- end
- end)
- timer.Create( "RP.Timers.CheckPlayerSteamRewards", 10, 0, function()
- for i = 1, #player.GetAll() do
- local v = player.GetAll()[i]
- if IsValid(v) then
- CommunityCheckStatus( v, false )
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement