• Print

Author Topic: Question about Pointshop 1 abilities  (Read 4931 times)

0 Members and 1 Guest are viewing this topic.

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Question about Pointshop 1 abilities
« on: October 07, 2016, 06:38:42 pm »
Was wondering if there was a way to set a "cooldown" on an item, like they can only buy an item once per map. I have two things I custom made in my Pointshop, a Detective Round and Traitor Round; their purpose is obvious. Now, what I wanted to do was make it so it could only be bought once per map (or once per x minutes or x rounds), is there anything built into Pointshop that can accomplish this?
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Question about Pointshop 1 abilities
« Reply #1 on: October 07, 2016, 07:11:27 pm »
No clue pointshop 1 vs pointshop 2.
Found this -
http://pointshop.burt0n.net/items/functions

If the same hooks exist, I don't see why you couldn't set a normal timer variable like any other cooldown, or no more until map reload method using item:onbuy, have canplayerbuy return false if the variable is set.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Question about Pointshop 1 abilities
« Reply #2 on: October 07, 2016, 07:12:22 pm »
Hm... I'll give it a shot.


Have a quick question about CurTime... if I were to use something like
Code: Lua
  1. timer.Simple( ( cvars.Number( "mp_timelimit" ) - CurTime() ) -- blah blah
would that return the amount of time left in the current map?
« Last Edit: October 07, 2016, 07:27:47 pm by iViscosity »
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Question about Pointshop 1 abilities
« Reply #3 on: October 07, 2016, 07:35:06 pm »
Code: Lua
  1. ITEM.Name = 'Detective Round'
  2. ITEM.Price = 10000
  3. ITEM.Material = 'vgui/ttt/icon_det.vmt'
  4. ITEM.SingleUse = true
  5.  
  6. ITEM.SubCategory = 'Temporary Powerups'
  7.  
  8. function ITEM:OnBuy( ply )
  9.  
  10.         hook.Add( "TTTBeginRound", "Give D Round", function()
  11.  
  12.                 if !( ply:HasItem( 'detective_round' ) ) then return end
  13.                
  14.                 if ply:GetRole() == ROLE_INNOCENT then
  15.  
  16.                         timer.Simple( 1, function()
  17.  
  18.                                 ply:SetRole( ROLE_DETECTIVE )
  19.  
  20.                                 if !( ULib == nil ) then
  21.  
  22.                                         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." )
  23.  
  24.                                 end
  25.                                 ply:AddCredits( 1 )
  26.                                 ply:TakeItem( 'detective_round' )
  27.                                
  28.                         end )
  29.  
  30.                 elseif ply:GetRole() == ROLE_TRAITOR then
  31.  
  32.                         timer.Simple( 1, function()
  33.  
  34.                                 if !( ULib == nil ) then
  35.  
  36.                                         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." )
  37.  
  38.                                 end
  39.                                
  40.                                 ply:PS_SellItem( 'detective_round' )
  41.                                 ply:TakeItem( 'detective_round' )
  42.  
  43.                         end )
  44.  
  45.                 elseif ply:GetRole() == ROLE_DETECTIVE then
  46.  
  47.                         if !( ULib == nil ) then
  48.  
  49.                                 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." )
  50.  
  51.                         end
  52.                                
  53.                         ply:PS_SellItem( 'detective_round' )
  54.  
  55.                 end
  56.  
  57.         end )
  58.  
  59.         ply:SetPData( "purchased", "true" )
  60.  
  61.         timer.Create( "Delay In Purchase", 60, ( cvars.Number( "mp_timelimit" ) - CurTime() ), function()
  62.  
  63.                 ply:RemovePData( "purchased" )
  64.  
  65.         end )
  66.  
  67. end
  68.  
  69. function ITEM:CanPlayerBuy( ply )
  70.  
  71.         if ply:GetPData( "purchased" ) == "true" then
  72.                
  73.                 return false
  74.  
  75.         else
  76.  
  77.                 return true
  78.  
  79.         end
  80.  
  81. end

Is this the kind of timer I'd use? I think I did it right. I used PData because I'm familiar with it, and I'd assume that
Code: Lua
  1. cvars.Number( "mp_timelimit" - CurTime()
would return the rest of time left in the map, if I'm not wrong.
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Question about Pointshop 1 abilities
« Reply #4 on: October 07, 2016, 09:28:17 pm »
So, really, the question of my last comment is 'am I wrong?'
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Question about Pointshop 1 abilities
« Reply #5 on: October 07, 2016, 11:31:55 pm »
Have a quick question about CurTime... if I were to use something like
Code: Lua
  1. timer.Simple( ( cvars.Number( "mp_timelimit" ) - CurTime() ) -- blah blah
would that return the amount of time left in the current map?

Not quite.
mp_timelimit is minutes, CurTime is seconds. You'd need conversion.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

  • Print