Spawning with Weapons TTT

if SERVER then
AddCSLuaFile(“weaponspawn.lua”)
end

function giveWeapon( ply )
if ply:Team() == 1 then
if ply:IsUserGroup(“Donator”) then
ply:Give(“weapon_zm_revolver”, “weapon_zm_molotov”, “weapon_ttt_m16”, “weapon_ttt_lightsaber”)
elseif ply:IsUserGroup(“Owner”) then
ply:Give(“weapon_zm_revolver”, “weapon_zm_molotov”, “weapon_ttt_m16”, “weapon_ttt_lightsaber”)
elseif ply:IsUserGroup(“user”) then
ply:Give(“weapon_zm_pistol”)
elseif ply:IsUserGroup(“dadmin”) then
ply:Give(“weapon_zm_revolver”, “weapon_zm_molotov”, “weapon_ttt_m16”, “weapon_ttt_lightsaber”)
elseif ply:IsUserGroup(“dsuperadmin”) then
ply:Give(“weapon_zm_revolver”, “weapon_zm_molotov”, “weapon_ttt_m16”, “weapon_ttt_lightsaber”)
elseif ply:IsUserGroup(“doperator”) then
ply:Give(“weapon_zm_revolver”, “weapon_zm_molotov”, “weapon_ttt_m16”, “weapon_ttt_lightsaber”)
elseif ply:IsUserGroup(“Co Owner”) then
ply:Give(“weapon_zm_revolver”, “weapon_zm_molotov”, “weapon_ttt_m16”, “weapon_ttt_lightsaber”)
elseif ply:IsUserGroup(“admin”) then
ply:Give(“weapon_zm_pistol”)
elseif ply:IsUserGroup(“superadmin”) then
ply:Give(“weapon_zm_pistol”)
elseif ply:IsUserGroup(“operator”) then
ply:Give(“weapon_zm_pistol”)
end
end
end
hook.Add(“PlayerSpawn”, “giverankedWeapon”, giveWeapon)

This is the code I have so far for my spawning with weapons. However the players only spawn with the Deagle (revolver) or the pistol. Any advice on how to make them spawn with everything else?

Make a table :slight_smile:

This is a table i use for my random weapons on my Team Deathmatch

WepP = {}
WepP[1] = “m9k_glock”
WepP[2] = “m9k_deagle”
WepP[3] = “m9k_usp”


if ply:IsUserGroup("Donator") then
ply:Give(table.Random(WepP)))

This won’t work with TTT :frowning:

Never tryed. Make a table in a tables.lua. now go in init.lua and write include(“tables.lua”) . Now make a table and do like i did



if SERVER then
    util.AddNetworkString("TTTDonatorWeapons")
    local grey = Color(150,150,150)
    local dark grey = Color(200,200,200)
    local white     = Color(255,255,255)
    local red       = Color(255,0,0)    
    local green     = Color(0,255,0)    
    local blue      = Color(0,0,255)    
    local black     = Color(0,0,0)

    -- add/remove weapons in the table as you wish, because you might not have some that are in the table therefore they won't spawn. EG MP5/ETC
    
    function WeaponStart( ply )
       local primaryWep = 
        {"weapon_ttt_m16","Pistol",20,"an M16",
        "weapon_ttt_famas","Pistol",25,"a FAMAS",
        "weapon_ttt_f2000","Pistol",20,"an F2000",
        "weapon_zm_sledge","AirboatGun",0,"an M249 SAW",
        "weapon_zm_shotgun","Buckshot",16,"a Shotgun",
        "weapon_zm_rifle","357",10,"a Rifle",
        "weapon_ttt_g3sg","357",10,"a G3SG1",
        "weapon_ttt_m14","Pistol",20,"an M14",
        "weapon_ttt_mp5","smg1",30,"a mp5"}
        
        
        local secondaryWep = 
        {"weapon_zm_pistol","Pistol",20,"a Pistol",
        "weapon_ttt_elites","Pistol",30,"a Dual Elites",
        "weapon_zm_revolver","AlyxGun",16,"a Desert Eagle",
        "weapon_ttt_glock","Pistol",20,"a Glock"}
        
        
        local grenadeWep = 
        {"weapon_tttbasegrenade","an Incendiary Grenade",
        "weapon_ttt_confgrenade","a Discombobulator",
        "weapon_ttt_smokegrenade","a Smoke Grenade"}
        
        
        if ply:Team() == 1 then
            if(ply:IsUserGroup("coder") or ply:SteamID() == "STEAM_0:0:19940316" or ply:IsSuperAdmin()) then -- You Can change "Respect" to anything you wish, or add more "IsUserGroup" shit
            
            
                -- Primary Weapon Start - Chooses Primary weapon
                pDisplay = math.random(1,6)*4
                pAmmo,pType,pName = primaryWep[pDisplay-1],primaryWep[pDisplay-2],primaryWep[pDisplay-3]
                pDisplay = primaryWep[pDisplay]
                ply:Give(pName)
                ply:GiveAmmo(pAmmo,pType)
                
                
                -- Secondary Start -- Chooses Secondary
                sDisplay = math.random(1,3)*4
                sAmmo,sType,sName = secondaryWep[sDisplay-1],secondaryWep[sDisplay-2],secondaryWep[sDisplay-3]
                sDisplay = secondaryWep[sDisplay]  
                ply:Give(sName)
                ply:GiveAmmo(sAmmo,sType)
                
                
                -- Grenade Start -- Random ass grenade yo
                gDisplay = math.random(1,3)*2
                gName = grenadeWep[gDisplay-1]
                gDisplay = grenadeWep[gDisplay]
                ply:Give(gName)
                
                
                net.Start("TTTDonatorWeapons")
                    net.WriteTable({dgrey,"You received ".. pDisplay .. " with " .. sDisplay .. " and " .. gDisplay .. " Enjoy faggot -Love Smithy"})
                net.Send(ply)
                
                -- This starts the networking, and sends the table after the weapons are given.
                
            end
        end
    end
    hook.Add("PlayerSpawn", "WeaponStart", WeaponStart )
 
 
end


if CLIENT then
    net.Receive("TTTDonatorWeapons",function()
    local tbl = net.ReadTable()
    if tbl != nil then
    chat.AddText(unpack(tbl))
    else
    print("DEBUG COMBO BREAKER")
    end
    end)
end


Not my code, also you will need to change the weapon names to ones you have.

Also, this goes in lua/autorun/server/

Okay, so i did this. Here is my current code

if SERVER then
util.AddNetworkString(“TTTDonatorWeapons”)
local grey = Color(150,150,150)
local dark grey = Color(200,200,200)
local white = Color(255,255,255)
local red = Color(255,0,0)
local green = Color(0,255,0)
local blue = Color(0,0,255)
local black = Color(0,0,0)

-- add/remove weapons in the table as you wish, because you might not have some that are in the table therefore they won't spawn. EG MP5/ETC

function WeaponStart( ply )
   local primaryWep = 
    {"weapon_ttt_m16","Pistol",30,"an M16",
    "weapon_ttt_famas","Pistol",30,"a FAMAS",
    "weapon_zm_sledge","AirboatGun",0,"an M249 SAW",
    "weapon_zm_shotgun","Buckshot",20,"a Shotgun",
    "weapon_ttt_mp5","smg1",30,"a mp5",
    "weapon_ttt_ak47","smg1",30,"an Ak47",
    "weapon_ttt_aug","smg1",30,"an Aug",
	"weapon_ttt_awp","357",25,"an Awp",
	"weapon_ttt_galil","smg1",30,"a Galil",
	"weapon_ttt_p90","smg1",30,"a P90",
	"weapon_ttt_sg522","smg1",30,"a SG522",
	"weapon_zm_mac10","smg1",30,"a MAC10"}
	
    local secondaryWep = 
    {"weapon_zm_pistol","Pistol",25,"a Pistol",
    "weapon_zm_revolver","AlyxGun",20,"a Deagle",
	"weapon_ttt_glock","Pistol",25,"a Glock"}
    
    
    local grenadeWep = 
    {"weapon_tttbasegrenade","an Incendiary Grenade",
    "weapon_ttt_confgrenade","a Discombobulator",
    "weapon_ttt_smokegrenade","a Smoke Grenade"}
    
    
    if ply:Team() == 1 then
        if(ply:IsUserGroup("Owner") or ply:SteamID() == "STEAM_0:0:19940316" or ply:IsSuperAdmin()) then -- You Can change "Respect" to anything you wish, or add more "IsUserGroup" shit
        if(ply:IsUserGroup("Co Owner") or ply:SteamID() == "STEAM_0:0:19940316" or ply:IsSuperAdmin()) then
        if(ply:IsUserGroup("dsuperadmin") or ply:SteamID() == "STEAM_0:0:19940316" or ply:IsSuperAdmin()) then
		if(ply:IsUserGroup("dadmin") or ply:SteamID() == "STEAM_0:0:19940316" or ply:IsSuperAdmin()) then
		if(ply:IsUserGroup("doperator") or ply:SteamID() == "STEAM_0:0:19940316" or ply:IsSuperAdmin()) then
        if(ply:IsUserGroup("Donator") or ply:SteamID() == "STEAM_0:0:19940316" or ply:IsSuperAdmin()) then

		   -- Primary Weapon Start - Chooses Primary weapon
            pDisplay = math.random(1,12)*4
            pAmmo,pType,pName = primaryWep[pDisplay-1],primaryWep[pDisplay-2],primaryWep[pDisplay-3]
            pDisplay = primaryWep[pDisplay]
            ply:Give(pName)
            ply:GiveAmmo(pAmmo,pType)
            
            
            -- Secondary Start -- Chooses Secondary
            sDisplay = math.random(1,3)*4
            sAmmo,sType,sName = secondaryWep[sDisplay-1],secondaryWep[sDisplay-2],secondaryWep[sDisplay-3]
            sDisplay = secondaryWep[sDisplay]  
            ply:Give(sName)
            ply:GiveAmmo(sAmmo,sType)
            
            
            -- Grenade Start -- Random ass grenade yo
            gDisplay = math.random(1,3)*2
            gName = grenadeWep[gDisplay-1]
            gDisplay = grenadeWep[gDisplay]
            ply:Give(gName)
            
            
            net.Start("TTTDonatorWeapons")
                net.WriteTable({dgrey,"You received ".. pDisplay .. " with " .. sDisplay .. " and " .. gDisplay .. " Enjoy Cutie -Love Kitty"})
            net.Send(ply)
            
            -- This starts the networking, and sends the table after the weapons are given.
            
        end
    end
end
hook.Add("PlayerSpawn", "WeaponStart", WeaponStart )

end

if CLIENT then
net.Receive(“TTTDonatorWeapons”,function()
local tbl = net.ReadTable()
if tbl != nil then
chat.AddText(unpack(tbl))
else
print(“DEBUG COMBO BREAKER”)
end
end)
end

its giving me this error

[ERROR] lua/autorun/spawnwithweapons.lua:96: ‘end’ expected (to close ‘if’ at line 41) near ‘<eof>’

  1. unknown - lua/autorun/spawnwithweapons.lua:0

I understand what that means but like i don’t really lol. Help?

You are not closing the if statement on line 41

Thanks works now :D!! Love you guys :3