Hello, i have created a Game mode using a couple of tutorials on YouTube, and i have came across a problem. The problem is when you die in game you do not respawn with weapons even know I set it to. (I have looked for hours on Google and the wiki for help but cant find any)
init.lua
[CODE]
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( "shared.lua" )
include( "player.lua" )
function GM:PlayerConnect( name, ip )
end
function GM:PlayerInitialSpawn( ply )
ply:SetGamemodeTeam( 0 )
end
function GM:playerSpawn( ply )
ply:GiveGamemodeWeapons()
end
function GM:PlayerAuthed( ply, steamID, uniqueID )
end
function SetTeam0( ply )
RunConsoleCommand( "kill" )
ply:SetGamemodeTeam( 0 )
end
function SetTeam1( ply )
RunConsoleCommand( "kill" )
ply:SetGamemodeTeam( 1 )
end
concommand.Add( "team_0", SetTeam0 )
concommand.Add( "team_1", SetTeam1 )
[/CODE]
player.lua
[CODE]
local ply = FindMetaTable("Player")
local teams = {}
teams[0] = {name = "Blue", color = Vector( .2, .2, 1.0 ), weapons = {"m9k_m4a1", "m9k_colt1911"} }
teams[1] = {name = "Red", color = Vector( 1.0, .2, .2 ), weapons = {"m9k_ak47", "m9k_colt1911"} }
function ply:SetGamemodeTeam( n )
if not teams[n] then return end
self:SetTeam( n )
self:SetPlayerColor ( teams[n].color )
self:GiveGamemodeWeapons()
return true
end
function ply:GiveGamemodeWeapons()
local n = self:Team()
self:StripWeapons()
for k, wep in pairs(teams[n].weapons) do
self:Give(wep)
end
end
[/CODE]
They are the two lua files that cover that area (Lemme know if you need to see the others)
Messy code!
[CODE]function deathgiveweapon() -- Called when a player dies <3 ---> GM:PlayerDeath
ply:Give("weapon_crowbar") -- ADD AS MUCH AS YOU WANT
ply:Give("weapon_physgun")
end
hook.Add( "PlayerDeath", "giveweaponondeath", deathgiveweapon ) --- GM:PlayerDeath Hook[/CODE]
[QUOTE=PropGamer123;42889849]Messy code!
[CODE]Random Code that is not really needed. Although it works[/CODE][/QUOTE]
Here's something a bit more simpler.
[CODE]
function GM:PlayerSpawn ( ply )
ply:Give("weapon_crowbar")
ply:Give("weapon_smg1")
ply:GiveAmmo(9999999, "smg1")
end
[/CODE]
You can always go ahead and add as many items as you want to this. Have fun!
Sorry, you need to Log In to post a reply to this thread.