TTT Pointshop Ranks Cooldown

I would like someone to help me add a cooldown for the ranks that I sell on my pointshop because then people can become Traitor many times in a row.

http://pointshop.burt0n.net/items/functions - specifically ITEM:CanPlayerBuy(ply) and ITEM:OnBuy(ply)
http://ttt.badking.net/guides/hooks - TTTEndRound

These should help you get started - you basically want a variable for the check

Can you code it for me?


if localplayer() buy item_traior
wait (1 round)
end
end
end

for real learn basic lua before you make a server

I do have knowledge. Just not a huge ton. So this goes at the end of the PS file correct?

that’s pseudocode, it won’t work. Facepunch helps you code, it doesn’t do it for you.
Basically what he’s saying is you should make a timer or a round counter after the player buys it, which expires after x amount of rounds/time, and until it expires they can’t buy another one. Like Niandra said, you can use the CanPlayerBuy hook in the item file to prevent them from buying the item - just return false in the hook if their rounds/time hasn’t expired yet.

Pizza gave you pseudocode to help explain how you should write the actual code.

Use the links Niandra gave to you and try to code it yourself. If you struggle then post your code and we will help you

Edit: Damn, Splerge beat me too it :v

I thought that looked weird for LUA. At least I now know that it’s pseduocode. That would’ve helped if you told me it was that first.

[editline]8th November 2015[/editline]

This is the code that i’ve constructed as far in gamemodes/ttt/gamemode/traitor_state.lua



local ForceDelay = 3600 //Delay in seconds, 3600 seconds is a one hour delay. 
local function Set_TTTForceDelay( pl )
    pl.TTTForceDelay = ( os.time() + ForceDelay )
    pl:ChatPrint("You must now wait "..tostring( math.ceil( ForceDelay / 60 ) ).." minutes before forcibly becoming a traitor/detective again.")
end

local function Has_TTTForceDelay( pl )
    if !pl.TTTForceDelay then
        Set_TTTForceDelay( pl )
        return false
    else
        if pl.TTTForceDelay > os.time() then
            local RemainingTime = tostring( math.ceil( (pl.TTTForceDelay - os.time()) / 60 ) )
            pl:ChatPrint("Sorry, you have "..RemainingTime.." minutes before once again forcibly becoming a traitor/detective.")
            return true
        else
            Set_TTTForceDelay( pl )
            return false
        end
    end
end

local function force_traitor(ply)
    if not (ply:IsUserGroup("donator") or
    ply:IsUserGroup("owner") or
    ply:IsUserGroup("admin+") or
    ply:IsUserGroup("donator - moderator")) then return end

    if Has_TTTForceDelay( ply ) then return end

      ply:SetRole(ROLE_TRAITOR)
 
      SendFullStateUpdate()
end
concommand.Add("ttt_force_traitor", force_traitor)

local function force_detective(ply)
    if not (ply:IsUserGroup("donator") or
    ply:IsUserGroup("owner") or
    ply:IsUserGroup("superadmin") or
    ply:IsUserGroup("headofstaff")) then return end

    if Has_TTTForceDelay( ply ) then return end

      ply:SetRole(ROLE_DETECTIVE)
  
      SendFullStateUpdate()
end
concommand.Add("ttt_force_detective", force_detective)

what about your item file?

The PS file uses that command to give the player the item.

It doesn’t work though.