Lua TTT - Traitor Item - Modding help

Hi there.
I am scritping a Traitor weapon for the Garry´s Mod Gamemode TTT and I am “almost” finished. The function (Primary Attack) is missing. But I cannot find help in the GMod Wiki, so I want to try to find help in this forum. This is want I need:

If the Player do Left-Click with the weapon, this shall happen:

  • A Message will be shown up on the screen of each player
  • Another Message will be shown up in the chat (visible for each player)
  • A Sound file will be played.
  • 10 Seconds after the Sound: 4 C4 Bombs shall spawn randomly on the map
  • The C4 Bombs shall explode one after another not at the same time (Otherwise the servers will chrash

And one question at the end: Goes this code in the shared.lua ?

Thanks for your help.

PS: I don´t need the full code, but this is my first big script.

Thanks again and have a nice day.

This is really the only difficult part of your script.
(Unless someone more knowledgeable than me can chime in) you’ll need to have pre-determined positions where the C4 could spawn, and then pick 4 random ones from said positions.

As for everything else:
Know how to use the net library
Screen message - (Net library)

GM:HUDPaint + http://wiki.garrysmod.com/page/draw/Text OR

PrintMessage
Chat message -

PrintMessage
Sound - (Net library)

surface.PlaySound
Spawning the C4s -

timer.Simple +

ents.Create (“ttt_c4”) You will also need to use ent:Arm( ply, n ).
ply is the player that fired the weapon and n is an integer variable that should start at 1 and end at 4. (i.e. - For the first C4, it’s 1, for the second, it’s 2, etc.)

Thanks for your help. The “difficult” has a solution now. I will not spawn 4 C4 Bombs. I let explode 4 entities on the map. I know everything is an entity but I will define Props and Players and let 4 of them explode randomly.