ITEM.Name = 'Detective Round'
ITEM.Price = 10000
ITEM.Material = 'vgui/ttt/icon_det.vmt'
ITEM.SingleUse = true
ITEM.SubCategory = 'Temporary Powerups'
function ITEM:OnBuy( ply )
hook.Add( "TTTBeginRound", "Give D Round", function()
if !( ply:HasItem( 'detective_round' ) ) then return end
if ply:GetRole() == ROLE_INNOCENT then
timer.Simple( 1, function()
ply:SetRole( ROLE_DETECTIVE )
if !( ULib == nil ) then
ULib.tsayColor( ply, "", Color( 255, 255, 255 ), "You have been made a ", Color( 25, 25, 200 ), "Detective ", Color( 255, 255, 255 ), "by your Pointshop item." )
end
ply:AddCredits( 1 )
ply:TakeItem( 'detective_round' )
end )
elseif ply:GetRole() == ROLE_TRAITOR then
timer.Simple( 1, function()
if !( ULib == nil ) then
ULib.tsayColor( ply, "", Color( 255, 255, 255 ), "Your", Color( 25, 25, 200 ), " Detective ", Color( 255, 255, 255 ), "round was refunded due to being a ", Color( 200, 25, 25 ), "Traitor", Color( 255, 255, 255 ), ". Please purchase the item again." )
end
ply:PS_SellItem( 'detective_round' )
ply:TakeItem( 'detective_round' )
end )
elseif ply:GetRole() == ROLE_DETECTIVE then
if !( ULib == nil ) then
ULib.tsayColor( ply, "", Color( 255, 255, 255 ), "Your", Color( 25, 25, 200 ), " Detective ", Color( 255, 255, 255 ), "round was refunded due to being a ", Color( 25, 25, 200 ), "Detective", Color( 255, 255, 255 ), ". Please purchase the item again." )
end
ply:PS_SellItem( 'detective_round' )
end
end )
ply:SetPData( "purchased", "true" )
timer.Create( "Delay In Purchase", 60, ( cvars.Number( "mp_timelimit" ) - CurTime() ), function()
ply:RemovePData( "purchased" )
end )
end
function ITEM:CanPlayerBuy( ply )
if ply:GetPData( "purchased" ) == "true" then
return false
else
return true
end
end