General > Developers Corner

*Solved*Can someone help me with hooks or timers for an minigame im making.

(1/1)

Linkis20:
Hey
I'm an developer for The Blade TTT Server 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: ---function giveplayerknife()
--minigameplayer == The Player that is the traitor
minigameplayer:SetCredits(0)
minigameplayer:StripWeapons()
minigameplayer:Give("weapon_ttt_knife")
end
--- End code ---

so i tried making an timer for it.


--- Code: ---timer.Create("Give_Knife_Timer", 10, 0, giveplayerknife)
with
timer.Start("Give_Knife_Timer")
and
timer.Stop("Give_Knife_Timer")
--- End code ---

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


--- Code: ---hook.Add("weapon_ttt_knife:OnRemove()", "Give_Knife_Hook", giveplayerknife)
--- End code ---

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.

Decicus:
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.

Linkis20:
Tx i never that about creating an weapon for it :P

Navigation

[0] Message Index

Go to full version