Injured Script

I am aware this script is missing some things, such as the player being immobilized when injured, but could you tell me if it looks like it’s going to work when it’s done? And if there are any errors please tell me about them.



AddCSLuaFile( "kermite\lua\weapons\kermite_pist_glock19\shared.lua" )

include( 'kermite\lua\weapons\kermite_pist_glock19\shared.lua' )

function takeInjury( ply )

		if ply:Alive() then
				ply:ChatPrint('You have been injured!')
				ply:DrawViewModel( false )
				ply:DrawWorldModel( false )
				ply:StripWeapons()
				ply:SetColor( 255, 255, 255, 0 )
				plyDown = ents.Create("ragdoll")
				plyDown:SetPos( ply:GetPos() )
				plyDown:SetModel( ply:GetModel() )
				plyDown:Spawn()
				isPlayerIncapacitated = true
		end
end

function ENT:Use( ply, plyDown )
		if ply:Team() == 1 then
			beRevived( plyDown )
		end
		else
			Msg("You don't have proper training")
		end
end

function beRevived( ply )
		if ply:Team() == 2 then
			ply:DrawViewModel( true )
			ply:DrawWorldModel( true )
			ply:Give( "glock19" )
			ply:SetPos( plyDown:GetPos() )
end


You know, since people aren’t quite as good as a Lua interpreter, it’s easy to tell if it works by actually running it. But you are going to have errors, as your last two functions have some syntax errors going with your placement of "end"s as well as a few other things, like you never define “plyDown”.

so I need to include it in the parameters for beRevived? But in any case, thanks for helping me though. :slight_smile:

I dont get why people post “Will this code work?” why cant you just test it?