Hey again people, so after solving my levelup/sqlite issues, I fell on a new one for my force system .
Please take note that I'm still fairly new to lua so any help would be greatly appreciated!
EDIT: Been playing around with the code. If I try to force run the error[CODE][ERROR] gamemodes/example/gamemode/shared.lua:61: attempt to compare number with string
1. unknown - gamemodes/example/gamemode/shared.lua:61[/CODE]
if I try to force jump the error is [CODE]
[ERROR] gamemodes/example/gamemode/shared.lua:28: attempt to compare number with string
1. unknown - gamemodes/example/gamemode/shared.lua:28
[/CODE]
Most recent code
shared. lua [CODE]GM.Name = "Example"
GM.Author = "N/A"
GM.Email = "N/A"
GM.Website = "www.goature.com"
DeriveGamemode("sandbox")
team.SetUp( 6546, "Owner", Color(255, 0, 0) )
team.SetUp( 0, "Citizen", Color(0, 0, 255) )
team.SetUp( 1, "Red", Color(255, 0, 0) )
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)
function GM:KeyPress( ply, KEY )
if( 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( 25 )
ply:SetVelocity( ply:GetUp() * 350 )
ply:EmitSound( "force/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( ply.Char.TakeForce, true )
ply:SetVelocity( ply:GetUp() * 10 )
end )
ply.JumpPhase = 2
elseif( ply:GetForce() >= 5 and ply.JumpPhase == 2 ) then
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 )
end
ply:TakeForce( ply.Char.TakeForce, 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( "force/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( ply.Char.TakeForce, 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" )
end
if( KEY == IN_JUMP ) then
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
[/CODE]
force.lua [CODE]local Player= FindMetaTable("Player")
function Player:GetForce()
return self:GetNWInt("force")
end
function Player:TakeForce( NumForce, DontRegen )
self:AddForce(self:GetForce() - NumForce)
if( DontRegen != true ) then
if( timer.IsTimer( "ForceBackUpTimer" ) ) then
timer.Destroy( "ForceBackUpTimer" )
timer.Create( "ForceBackUpTimer", 0.1, 0, function()
self:AddForce( 1 )
self:SetNWInt( "force", self:GetForce() )
self:SetNWInt( "MaxForce", self:GetMaxForce() )
if( self:GetForce() >= self:GetMaxForce()) then
timer.Destroy( "ForceBackUpTimer" )
end
end )
else
timer.Create( "ForceBackUpTimer", 0.1, 0, function()
self:AddForce( 1 )
self:SetNWInt( "force", self:GetForce() )
self:SetNWInt( "MaxForce", self:GetMaxForce() )
if( self:GetForce() >= self:GetMaxForce()) then
timer.Destroy( "ForceBackUpTimer" )
end
end )
end
end
//self:SetNWInt( "force", self:GetNWInt("force") )
end
function Player:AddForce( NumForce )
self:SetForce(self:GetForce() + NumForce)
end
function Player:GetMaxForce()
return self:GetNWInt("MaxForce")
end
function Player:GetTakeForce()
return self:TakeForce() or 1
end
function Player:SetForce( NumForce )
self.num = NumForce
end[/CODE]
-snip-
Buy a new pc
-snip-
Solved thanks to PortalGod for spending countless of time on helping me and explaining stuff to me!
Sorry, you need to Log In to post a reply to this thread.