Ulysses

General => Developers Corner => Topic started by: Linkis20 on November 18, 2013, 02:23:31 AM

Title: *Solved*Can someone help me with hooks or timers for an minigame im making.
Post by: Linkis20 on November 18, 2013, 02:23:31 AM
Hey
I'm an developer for The Blade TTT Server (http://steamcommunity.com/groups/S-Blade) and i am bit stuck on something with my code.

I'm making an Mini game for ttt that runs with ulx.
So far i code an Team Death-match where half of the people in the server become traitor and the other half detectives.

I'm now making the second Mini game called hidden.
This is where 1 player becomes an traitor and others detectives and the traitor is clocked and has to kill everyone.
So far a lot is working, player becomes an traitor others detectives and the traitor gets an knife.
Now where i am stuck on is this next part.

What i want is if the traitor uses the knife to kill an detective that he gets an new knife.
This part i am trying to code but every time the player get not an new knife.

This is the function i made for it.
Code: [Select]
function giveplayerknife()
--minigameplayer == The Player that is the traitor
minigameplayer:SetCredits(0)
minigameplayer:StripWeapons()
minigameplayer:Give("weapon_ttt_knife")
end

so i tried making an timer for it.

Code: [Select]
timer.Create("Give_Knife_Timer", 10, 0, giveplayerknife)
with
timer.Start("Give_Knife_Timer")
and
timer.Stop("Give_Knife_Timer")

This does nothing for some reason so i to do it with an hook:

Code: [Select]
hook.Add("weapon_ttt_knife:OnRemove()", "Give_Knife_Hook", giveplayerknife)
This is not working too.

So what i am asking here is:
What is the best way of doing this?
What am i doing wrong? (The hook maybe?)
How can i make it work?

Thanks for reading this.

Zero.
Title: Re: Can someone help me with hooks or timers for an minigame im making.
Post by: Decicus on November 18, 2013, 03:28:28 AM
You could always make a new knife by copy/pasting the code from "weapon_ttt_knife" into something like "weapon_ttt_hiddenknife" (or any name you want), then modify the new knife's code to not drop. You wouldn't actually need to make a new knife spawn, because it doesn't drop at all.
I did something similar, and I found it easier this way by just creating a new knife that doesn't drop on kill.
Title: Re: Can someone help me with hooks or timers for an minigame im making.
Post by: Linkis20 on November 18, 2013, 09:47:03 AM
Tx i never that about creating an weapon for it :P