I'm trying to figure out how to allow those who purchase a Detective Round to spawn with a DNA Scanner. Not sure how to get it to work, anyone mind helping me out?
[CODE]ITEM.Name = 'Become Detective'
ITEM.Price = 1500
ITEM.Material = 'VGUI/ttt/icon_det.vmt'
ITEM.OneUse = true
ITEM.Except = true
function ITEM:OnEquip(ply, modifications)
hook.Add("TTTBeginRound", ply:UniqueID() .. "_detective", function()
if ply:GetRoleString() != "detective" then
ply:SetRole(ROLE_DETECTIVE)
ply:AddCredits(GetConVarNumber("ttt_credits_starting"))
end
if SERVER then
ply:PS_TakeItem(self.ID)
end
hook.Remove("TTTBeginRound", ply:UniqueID() .. "_detective")
end)
end
function ITEM:OnHolster(ply)
hook.Remove("TTTBeginRound", ply:UniqueID() .. "_detective")
end
function ITEM:OnSell(ply)
hook.Remove("TTTBeginRound", ply:UniqueID() .. "_detective")
end[/CODE]
You can't put a hook in a function like that; move that to the other TTTBeginRound hook. In the OnEquip, you'll have to send a [URL="http://wiki.garrysmod.com/page/Net_Library_Usage"]net message[/URL] serverside and [URL="http://wiki.garrysmod.com/page/Player/Give"]give the player[/URL] weapon_ttt_wtester.
Fucking hell.
[lua]
ITEM:TTTBeginRound( ply )
[/lua]
will run if the item is equipped.
ply:Give()
Here are some working T and D rounds I posted a while back: [url]http://facepunch.com/showthread.php?t=1408977[/url]
Sorry, you need to Log In to post a reply to this thread.