All pastes #1711986 Raw Edit

Gmod9 SWEP

public lua v1 · immutable
#1711986 ·published 2009-12-12 10:19 UTC
rendered paste body
	-- =============================================	-- // Updated ( V1.04 )  12 Dec. | 11:17:05 // 	-- =============================================_OpenScript( "includes/defines.lua" );_OpenScript( "includes/vector3.lua" );_OpenScript( "includes/misc.lua" );_OpenScript( "includes/backcompat.lua" );	-- ===================	-- // HUD Functions //	-- ===================	function GMod_Text(ID, Text, xpos, ypos, T, FI, FO, R, G, B, A)_GModText_Start( "HudHintTextLarge" );	 _GModText_SetPos( xpos, ypos );	 _GModText_SetColor( R, G, B, A );	 _GModText_SetTime( T, FI, FO );	 _GModText_SetText( Text );	 _GModText_SetDelay( 0 );_GModText_Send( Owner, ID );endfunction GMod_Rect(ID, xpos, ypos, xscale, yscale, T, FI, FO, R, G, B, A)_GModRect_Start( "gmod/white" );	 _GModRect_SetPos( xpos, ypos, xscale, yscale );	 _GModRect_SetColor( R, G, B, A );	 _GModRect_SetTime( T, FI, FO );	 _GModRect_SetDelay( 0 );_GModRect_Send( Owner, ID );end	-- ===============	-- // Variables //	-- ===============local barshow_on = 1;local barshow_off = 0;local Fforce = 500;local tmp = _CurTime() + 0.4;local regenrate = 1;local set = 1;local showset = 1;local toggle = 1;local toggle_tmp = _CurTime() + 0.4;local barshow_off_tmp = _CurTime() + 0.6;	-- ======================	-- // Health Variables //	-- ======================local regenratehz = 1;local regenratehe = 0;	-- =====================	-- // Armor Variables //	-- =====================local regenrateaz = 1;local regenrateae = 0;	-- ================	-- // SCRIPT !!! //	-- ================function onPickup( playerid )local iHealth = _PlayerInfo( playerid, "health" );local mathh = iHealth / 5000;local mathz = iHealth / 10;GMod_Rect( 1, 0.030, 0.520, 0.27, 0.10, 9999, 0.2, 0.2, 0, 0, 0, 180 );GMod_Rect( 2, 0.090, 0.530, mathh, 0.02, 9999, 0.2, 0.2, 83, 176, 235, 255 );GMod_Text( 3, mathz.. "%", 0.040, 0.530, 9999, 0.2, 0.2, 255, 255, 255, 255 );GMod_Text( 4, "Force : " ..Fforce, 0.040, 0.560, 9999, 0.2, 0.2, 255, 255, 255, 255 );if (toggle == 1) thenGMod_Text( 5 , "Regeneration : ON", 0.040 , 0.590, 9999, 0.0, 0.0, 255, 255, 255, 255 );endif (toggle == 0) thenGMod_Text( 5 , "Regeneration : OFF", 0.040 , 0.590, 9999, 0.0, 0.0, 255, 255, 255, 255 );end	endfunction onDrop()	_EntRemove(MyIndex);	endfunction onRemove()	endfunction Deploy()	-- ================================================	-- // Show HUD when Player switch to this weapon //	-- ================================================local iHealth = _PlayerInfo(Owner,"health");local mathh = iHealth / 5000;local mathz = iHealth / 10;GMod_Rect( 1, 0.030, 0.520, 0.27, 0.10, 9999, 0.2, 0.2, 0, 0, 0, 180 );GMod_Rect( 2, 0.090, 0.530, mathh, 0.02, 9999, 0.2, 0.2, 83, 176, 235, 255 );GMod_Text( 3, mathz.. "%", 0.040, 0.530, 9999, 0.2, 0.2, 255, 255, 255, 255 );GMod_Text( 4, "Force : " ..Fforce, 0.040, 0.560, 9999, 0.2, 0.2, 255, 255, 255, 255 );if (toggle == 1) thenGMod_Text( 5 , "Regeneration : ON", 0.040 , 0.590, 9999, 0.0, 0.0, 255, 255, 255, 255 );endif (toggle == 0) thenGMod_Text( 5 , "Regeneration : OFF", 0.040 , 0.590, 9999, 0.0, 0.0, 255, 255, 255, 255 );endendfunction Holster()	-- ============================================	-- // Hide HUD when player leave this weapon //	-- ============================================_GModRect_Hide( Owner, 1, 0.3 );_GModRect_Hide( Owner, 2, 0.3 );_GModText_Hide( Owner, 3, 0.3 );_GModText_Hide( Owner, 4, 0.3 );_GModText_Hide( Owner, 5, 0.3 );showset = 1;endfunction onInit()	_SWEPSetSound( MyIndex, "single_shot", "Weapon_USP.Single" )endfunction onThink()	-- ===========================	-- // Make the regeneration //	-- ===========================local iArmor = _PlayerInfo(Owner,"armor");local iHealth = _PlayerInfo(Owner,"health");if (regenrate == 1) thenif (regenratehh == 1) theniHealth = iHealth + 100;	_PlayerSetHealth( Owner, iHealth );endif (regenratehz == 1) theniHealth = iHealth + 10;	_PlayerSetHealth( Owner, iHealth );endif (regenratehe == 1) theniHealth = iHealth + 1;	_PlayerSetHealth( Owner, iHealth );	endendlocal mathh = iHealth / 5000;local mathz = iHealth / 10;if (set == 1) then    if (mathz == 100) then		-- ===========================	-- // Show Regeneration HUD //	-- ===========================GMod_Text( 3, mathz.. "%", 0.040, 0.530, 9999, 0.0, 0.0, 255, 255, 255, 255 );GMod_Rect( 2, 0.090, 0.530, mathh, 0.02, 9999, 0.0, 0.0, 83, 176, 235, 255 );set = 0;	endend	if (barshow_on == 1) then	GMod_Rect( 2, 0.090, 0.530, mathh, 0.02, 1, 0.0, 0.0, 83, 176, 235, 255 );GMod_Text( 3, mathz.. "%", 0.040, 0.530, 1, 0.0, 0.0, 255, 255, 255, 255 );set = 1;endif ( _CurTime() > barshow_off_tmp ) then	if (barshow_off == 1) then		if (mathz < 100) then	GMod_Rect( 2, 0.090, 0.530, mathh, 0.02, 1, 0.2, 0.2, 83, 176, 235, 255 );GMod_Text( 3, mathz.. "%", 0.040, 0.530, 1, 0.2, 0.2, 255, 255, 255, 255 );set = 1;barshow_off_tmp = _CurTime() + 0.4;		end	endend	-- =================	-- // Some Config //	-- =================	if (iHealth < 980) then	regenratehz = 1;	regenratehe = 0;		if (toggle == 1) then		barshow_on = 1;	end		elseif (iHealth < 1000) then	regenratehz = 0;	regenratehe = 1;		if (toggle == 1) then		barshow_on = 1;	end		elseif (iHealth > 999) then	regenratehz = 0;	regenratehe = 0;	barshow_on = 0;	endif (regenrate == 1) thenif (regenrateaz == 1) theniArmor = iArmor + 10;	_PlayerSetArmor( Owner, iArmor );endif (regenrateae == 1) theniArmor = iArmor + 1;	_PlayerSetArmor( Owner, iArmor );end	if (iArmor < 80) then	regenrateaz = 1;	regenrateae = 0;		elseif (iArmor < 100) then	regenrateaz = 0;	regenrateae = 1;			end	if (iArmor == 100) then	regenrateaz = 0;	regenrateae = 0;			end	endendfunction onPrimaryAttack()	-- ====================	-- // Make the Force //	-- ====================local vPlayerAng = _PlayerGetShootAng( Owner );	local vPlayerVel = vecMul( vPlayerAng, vector3( Fforce, Fforce, Fforce ) );		_EntSetVelocity( Owner, vPlayerVel );		endfunction onSecondaryAttack()	-- ===============================	-- // Change the power of Force //	-- ===============================if (Fforce == 500) then		Fforce = 1500;GMod_Text( 4 , "Force : " ..Fforce , 0.040 , 0.560, 9999, 0.0, 0.0, 255, 255, 255, 255 );return false;endif (Fforce == 1500) then		Fforce = 3000;GMod_Text( 4 , "Force : " ..Fforce , 0.040 , 0.560, 9999, 0.0, 0.0, 255, 255, 255, 255 );return false;endif (Fforce == 3000) then		Fforce = 5000;GMod_Text( 4 , "Force : " ..Fforce , 0.040 , 0.560, 9999, 0.0, 0.0, 255, 255, 255, 255 );return false;endif (Fforce == 5000) then		Fforce = 500;		GMod_Text( 4 , "Force : " ..Fforce , 0.040 , 0.560, 9999, 0.0, 0.0, 255, 255, 255, 255 );return false;	endendfunction onReload()	-- =======================================	-- // Toggles the Regeneration ON / OFF //	-- =======================================if ( _CurTime() > toggle_tmp) thenif (toggle == 1) then	GMod_Text( 5 , "Regeneration : OFF" , 0.040 , 0.590, 9999, 0.0, 0.0, 255, 255, 255, 255 );		toggle = 0;			toggle_tmp = _CurTime() + 0.6;				barshow_on = 0;					barshow_off = 1;						regenrate = 0;			return false;endif (toggle == 0) then	GMod_Text( 5 , "Regeneration : ON", 0.040 , 0.590, 9999, 0.0, 0.0, 255, 255, 255, 255 );		toggle = 1;			toggle_tmp = _CurTime() + 0.6;				barshow_on = 1;					barshow_off = 0;						regenrate = 1;			return false;	endendend	-- ========================	-- // Some Weapon Script //	-- ========================-- ==========================================-- Basic Weapon Display Settings:-- ==========================================function getHUDMaterial()		return "gmod/SWEP/default"; end -- This weapon's picture in the HUD weapons browserfunction getDeathIcon()			return "swep_default"; end 	-- The picture of the gun you killed someone with in upper right hand corner (swep_default is the Pac-Man-like logo for Gmod)function getWeaponSwapHands() 	return true; end 		-- Return true for right-handed in CSS, false for right-handed in HL2.function getWeaponFOV() 		return 55; end 			-- Feild of veiw (a higher number makes the gun appear further away from you)function getWeaponSlot() 		return 1; end 			-- Weapon slot (0-5) 0=crowbar, 1=pistol, 2=smg, 3=shotgun, 4=grenade, 5=pheropod (bugbait)function getWeaponSlotPos() 	return 7; end 				-- Slot position (0-infinity, make sure it won't cover up existing weapons though) 0=crowbar, 1=stunstick, 2=grav gun, 3=physgun, etc.function getViewModel() 		return "models/weapons/v_hands.mdl"; end 	-- The view model (What it looks like when it's in your hands)function getWorldModel()		return "models/weapons/w_knife_ct.mdl"; end 	-- The world model (What it looks like when it is spawned on the ground)function getAnimPrefix()		return "pistol"; end 		-- The animations for the viewmodel (Kind of like how you hold it)  (pistol, smg, ar2, shotgun, rpg, phys, crossbow, melee, slam, grenade)function getPrintName() 		return "ADMIN Gun"; end 		-- What the weapon is called in the HUD weapons browserfunction getClassName() 		return "weapon_admingun"; end 		-- What the weapons is called by the console when it reports a kill-- ==========================================-- Basic Attributes:-- ==========================================function getFiresUnderwater() 	return true; end 	-- Can it shoot underwater?function getReloadsSingly() 	return false; end 	-- Reload after each shot? (like a shotgun)-- ==========================================-- Primary Fire Settings:-- ==========================================function getDamage() 				return 0; end 			-- Primary fire damage, per bulletfunction getPrimaryShotDelay() 		return 0.001; end 		-- Delay between primary fire shots (in seconds)function getPrimaryIsAutomatic() 	return true; end 		-- Is primary fire automatic? (can you hold down the mouse and it will fire repeatedly?)function getNumShotsPrimary()		return 0; end 			-- Number of bullets per shot (The HL2 shotgun uses 7)function getMaxClipPrimary() 		return 30; end 			-- How much primary ammo each clip can hold before you have to reload ( -1 = Infinate)function getDefClipPrimary() 		return 930; end 		-- How much primary ammo is in the gun when it's spawned (Should be more than the clip can hold) ( -1 = Infinate)function getPrimaryAmmoType() 		return "XBowBolt"; end	-- Primary ammo type; NOTE - this only matters when you plan on picking up  more ammo for the gun later! It does not effect the performance of the gun whatsoever. (Pistol, 357, Buckshot, SMG1, smg1_grenade, AR2, AR2AltFire, XBowBolt, rpg_round, grenade, slam)function getPrimaryScriptOverride()	return 3; end 			-- 0 = Don't override (shoot bullets, make sound and flash), 1 = Just make flash/sounds (no bullets), 2 = Just animations, 3 = Do nothing (Still calls onPrimaryAttack)function getTracerFreqPrimary()		return 1; end 			-- How often a primary ammo bullet is a tracer round (0 = no tracers, 1 = every bullet is a tracer, 2 = every other bullet is a tracer, etc.)function getBulletSpread() 			return vector3(0.0, 0.0, 0.0); end 	-- Bullet spread, not view shake (X=down, Y=left, Z=clockwise spin)function getViewKick() 				return vector3(0.0, 0.0, 0.0); end -- Veiw kick for each shot(X=down, Y=left, Z=clockwise spin) (You can use negatives to make it go the opposite direction)function getViewKickRandom() 		return vector3(0.0, 0.0, 0.0); end 	-- Veiw kick random (X=up or down, Y=left or right, Z=clockwise or counterclockwise spin)-- ==========================================-- Secondary Fire Settings:-- ==========================================function getDamageSecondary()			return 0; end 		-- Secondary fire damage, per bulletfunction getSecondaryShotDelay() 		return 0.1; end 		-- Delay between secondary fire shots (in seconds)function getSecondaryIsAutomatic() 		return false; end 	-- Is secondary fire automatic? (Can you hold down the mouse and it will fire repeatedly?)function getNumShotsSecondary()			return 0; end 		-- Number of bullets per shot (the HL2 shotgun's secondary fire uses 14 for secondary fire)function getMaxClipSecondary() 			return 255; end 		-- How much secondary ammo each clip can hold before you have to reload ( -1 = Infinate)function getDefClipSecondary() 			return 255; end 		-- How much secondary ammo is in the gun when it's spawned (Should be more than the clip can hold) ( -1 = Infinate)function getSecondaryAmmoType() 		return "XBowBolt"; end 		-- Secondary ammo type; NOTE - this only matters when you plan on picking up  more ammo for the gun later! It does not effect the performance of the gun whatsoever. (Pistol, 357, Buckshot, SMG1, smg1_grenade, AR2, AR2AltFire, XBowBolt, rpg_round, grenade, slam)function getSecondaryScriptOverride() 	return 3; end 		-- 0 = Don't override (shoot bullets, make sound and flash), 1 = Just make flash/sounds (no bullets), 2 = Just animations, 3 = Do nothing (Still calls onSecondaryAttack)function getTracerFreqSecondary()		return 1; end 		-- How often a secondary ammo bullet is a tracer round (0 = no tracers, 1 = every bullet is a tracer, 2 = every other bullet is a tracer, etc.)function getBulletSpreadSecondary()		return vector3(0.0, 0.0, 0.0); end 	-- Secondary fire bullet spread, not view shake (X=down, Y=left, Z=clockwise spin)function getViewKickSecondary() 		return vector3(0.0, 0.0, 0.0); end 	-- View kick for secondary fire (X=down, Y=left, Z=clockwise spin) (You can use negatives to make it go the opposite direction)function getViewKickRandomSecondary() 	return vector3(0.0, 0.0, 0.0); end 	-- Veiw kick random for secondary fire (X=up or down, Y=left or right, Z=clockwise or counterclockwise spin)--	>>>>>>>>><<<<<<<<--      >>/////////////<<-- 	>> Made by Jan <<-- 	>>/////////////<<--	>>>>>>>>><<<<<<<<