• Lua TTT - Traitor Item - Modding help
    2 replies, posted
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.
[QUOTE=OwnedbyCube;51675824]4 C4 Bombs shall spawn [B]randomly[/B] on the map[/QUOTE] 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: [URL="http://wiki.garrysmod.com/page/Category:net"]Know how to use the net library[/URL] Screen message - (Net library) [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/HUDPaint]GM:HUDPaint[/url] + [url]http://wiki.garrysmod.com/page/draw/Text[/url] OR [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/PrintMessage]PrintMessage[/url] Chat message - [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/PrintMessage]PrintMessage[/url] Sound - (Net library) [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/surface/PlaySound]surface.PlaySound[/url] Spawning the C4s - [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/timer/Simple]timer.Simple[/url] + [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ents/Create]ents.Create[/url] ("ttt_c4") You will also need to use ent:Arm( [I][B]ply[/B][/I], [I][B]n[/B][/I] ). [I][B]ply[/B][/I] is the player that fired the weapon and [B][I]n[/I][/B] 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.)
[QUOTE=JasonMan34;51679299]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: [URL="http://wiki.garrysmod.com/page/Category:net"]Know how to use the net library[/URL] Screen message - (Net library) [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/HUDPaint]GM:HUDPaint[/url] + [url]http://wiki.garrysmod.com/page/draw/Text[/url] OR [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/PrintMessage]PrintMessage[/url] Chat message - [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/PrintMessage]PrintMessage[/url] Sound - (Net library) [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/surface/PlaySound]surface.PlaySound[/url] Spawning the C4s - [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/timer/Simple]timer.Simple[/url] + [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ents/Create]ents.Create[/url] ("ttt_c4") You will also need to use ent:Arm( [I][B]ply[/B][/I], [I][B]n[/B][/I] ). [I][B]ply[/B][/I] is the player that fired the weapon and [B][I]n[/I][/B] 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.)[/QUOTE] 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.
Sorry, you need to Log In to post a reply to this thread.