Hello everybody, me again with my force system errors and stuff.
So I’ve worked around trying to make a force choke system(like Darth Vader) and it’s working but I get this error and it’s somewhat annoying me
gamemode/shared.lua:34: attempt to index global 'umsg'
(a nil value)
Here’s the code of my shared.lua
GM.Name = "NoName"
GM.Author = "Sparks"
GM.Email = "N/A"
GM.Website = ""
DeriveGamemode("sandbox")
team.SetUp( 6546, "Owner", Color(255, 255, 255) )
team.SetUp( 0, "Citizen", Color(255, 255, 255) )
team.SetUp( 1, "Red", Color(255, 255, 255) )
function GM:Initialize()
self.BaseClass.Initialize( self )
end
--[[hook.Add("GetFallDamage", "NoFallDamage", function(ply, dmg, oldw, neww )
if neww:GetClass() == "weapon_lightsaber" then
return 0
end
end)--]]
--[[hook.Add("GetFallDamage", "FallDamage" , function()
return 0
end)--]]
function GM:KeyPress(ply, KEY )
local ent = ply:GetEyeTrace().Entity
ent = ply
if ( KEY == IN_USE ) then
if ent:IsPlayer() then
umsg.Start("exp_choke",ent)
umsg.Bool(true)
umsg.End()
timer.Simple(0.1,function()
umsg.Start("exp_choke",ent)
umsg.Bool(false)
umsg.End()
end)
ply:SetMoveType(MOVETYPE_NOCLIP)
ply:Lock()
timer.Create(ply:SteamID().."forcechoke",0.01,50,function()
ply:SetPos(ply:GetPos() + Vector(0,0,1))
end)
timer.Create(ply:SteamID().."forcechoke2",1,5,function()
if ply:Health() <= 10 then
ply:Kill()
timer.Destroy(ply:SteamID().."forcechoke2")
else
ply:SetHealth(ply:Health()-10)
ply:SendLua("surface.PlaySound(\"player/pl_drown1.wav\")")
umsg.Start("exp_choke",ent)
umsg.Bool(true)
umsg.End()
timer.Simple(0.1,function()
umsg.Start("exp_choke",ent)
umsg.Bool(false)
umsg.End()
end)
end
end)
timer.Simple(5,function()
ply:UnLock()
ply:SetMoveType(MOVETYPE_WALK)
end)
end
usermessage.Hook("exp_choke",ent)
elseif( KEY == IN_JUMP ) then
if ply:Team() == 6546 then
ply.ConstJump = true
if( ply:IsOnGround() ) then
ply.JumpPhase = 1
elseif( ply:GetForce() >= 25 and ply.JumpPhase == 1 ) then
ply.NoFallDamage = true
ply:TakeForce( 0 )
ply:SetVelocity( ply:GetUp() * 500 )
ply:EmitSound( "starwarssound/jump.wav" )
timer.Create( "ForceJumpConstTimer", 0.01, 0, function()
if( ( ply:GetForce() < 5 ) or !ply.ConstJump ) then
//ply:PrintMessage( HUD_PRINTCENTER, "No moar jump :C" )
ply:SetVelocity( Vector( 0, 0, 0 ) )
timer.Destroy( "ForceJumpConstTimer" )
ply:TakeForce( 0 )
ply.JumpPhase = false
end
ply:TakeForce( 0, true )
ply:SetVelocity( ply:GetUp() * 10 )
end )
ply.JumpPhase = 2
elseif( ply:GetForce() >= 5 and ply.JumpPhase == 2 ) then
timer.Create( "ForceJumpConstTimer", 1, 0, function()
if( ( ply:GetForce() < 5 ) or !ply.ConstJump ) then
//ply:PrintMessage( HUD_PRINTCENTER, "No moar jump :C" )
ply:SetVelocity( Vector( 0, 0, 0 ) )
timer.Destroy( "ForceJumpConstTimer" )
ply:TakeForce( 0 )
end
ply:TakeForce( 0, true )
ply:SetVelocity( ply:GetUp() * 10 )
end )
end
end
elseif( KEY == IN_SPEED and ply:KeyDown( IN_FORWARD ) ) then
ply.ConstSprint = true
if( ply:Team() == 6546 ) then
if( ply:GetForce() >= 10 and !ply:IsOnGround() ) then
elseif( ply:GetForce() >= 10 and ply:IsOnGround() ) then
ply:EmitSound( "starwarssound/speed.wav" )
timer.Create( "ForceSprintConstTimer", 0.01, 0, function()
if( ( ply:GetForce() < 5 ) or !ply.ConstSprint or !ply:IsOnGround() ) then
//ply:PrintMessage( HUD_PRINTCENTER, "No moar force :S" )
ply:SetVelocity( Vector( 0, 0, 0 ) )
timer.Destroy( "ForceSprintConstTimer" )
ply:TakeForce( 0 )
end
ply:TakeForce( 0.1, true )
ply:SetVelocity( ply:GetForward() * 200 )
end )
end
end
end
end
function GM:KeyRelease( ply, KEY )
if( KEY == IN_SPEED ) then
ply.ConstSprint = false
timer.Destroy( "ForceSprintConstTimer" )
if( KEY == IN_JUMP ) then
end
ply.ConstJump = false
timer.Destroy( "ForceJumpConstTimer" )
end
end
--[[function GM:EntityTakeDamage( ent, inflictor, attacker, amount, dmginfo )
if( ent:IsPlayer() and dmginfo:IsFallDamage() and ent.NoFallDamage ) then
return true
end
end
function GM:OnPlayerHitGround( ply )
ply.NoFallDamage = false
end
--]]
Any help would be greatly appreciated ^^