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.
[url]http://pointshop.burt0n.net/items/functions[/url] - specifically ITEM:CanPlayerBuy(ply) and ITEM:OnBuy(ply)
[url]http://ttt.badking.net/guides/hooks[/url] - TTTEndRound
These should help you get started - you basically want a variable for the check
[QUOTE=NiandraLades;49070556][url]http://pointshop.burt0n.net/items/functions[/url] - specifically ITEM:CanPlayerBuy(ply) and ITEM:OnBuy(ply)
[url]http://ttt.badking.net/guides/hooks[/url] - TTTEndRound
These should help you get started - you basically want a variable for the check[/QUOTE]
Can you code it for me?
[QUOTE=MrVideoFreak;49070820]Can you code it for me?[/QUOTE]
[CODE]if localplayer() buy item_traior
wait (1 round)
end
end
end[/CODE]
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?
[QUOTE=MrVideoFreak;49075365]I do have knowledge. Just not a huge ton. So this goes at the end of the PS file correct?[/QUOTE]
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.
[QUOTE=MrVideoFreak;49075365]I do have knowledge. Just not a huge ton. So this goes at the end of the PS file correct?[/QUOTE]
Pizza gave you [URL="https://en.wikipedia.org/wiki/Pseudocode"]pseudocode[/URL] 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
[QUOTE=PizzaDoxy;49072543][CODE]if localplayer() buy item_traior
wait (1 round)
end
end
end[/CODE]
for real learn basic lua before you make a server[/QUOTE]
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
[CODE]
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)[/CODE]
what about your item file?
[QUOTE=Splerge;49075704]what about your item file?[/QUOTE]
The PS file uses that command to give the player the item.
It doesn't work though.
Sorry, you need to Log In to post a reply to this thread.