ULX

Author Topic: *Solved*Can someone help me with hooks or timers for an minigame im making.  (Read 2705 times)

0 Members and 3 Guests are viewing this topic.

Offline Linkis20

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
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: [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.
« Last Edit: November 18, 2013, 09:48:58 AM by Linkis20 »

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: Can someone help me with hooks or timers for an minigame im making.
« Reply #1 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.
« Last Edit: November 18, 2013, 03:42:38 AM by Decicus »
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline Linkis20

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
Re: Can someone help me with hooks or timers for an minigame im making.
« Reply #2 on: November 18, 2013, 09:47:03 AM »
Tx i never that about creating an weapon for it :P