Can you send the client a [b]Lua[/b] module with AddCSLuaFile?
[QUOTE=ralle105;35003473][lua]local function ChangeHead(ent)
if ent:IsPlayer() then
local ply = ent
function ply:BuildBonePositions()
local bone = self:LookupBone("ValveBiped.Bip01_Head1")
local vm = self:GetBoneMatrix(bone)
vm:Scale(Vector(0.01, 0.01, 0.01))
self:SetBoneMatrix(bone, vm)
end
local new = ClientsideModel("models/player/urban.mdl")
new:SetParent(ply)
new:AddEffects(EF_BONEMERGE | EF_NOSHADOW)
function new:BuildBonePositions()
for i = 0, self:GetBoneCount()-1 do
if self:GetBoneName(i) == "ValveBiped.Bip01_Head1" then
local vm = self:GetBoneMatrix(i)
vm:Scale(Vector(100, 100, 100)) -- 1/0.01
self:SetBoneMatrix(i, vm)
elseif self:GetBoneName(i) != "__INVALIDBONE__" then
local vm = self:GetBoneMatrix(i)
vm:Scale(Vector(0.01, 0.01, 0.01))
self:SetBoneMatrix(i, vm)
end
end
end
end
end
hook.Add("OnEntityCreated", "ChangeHead", ChangeHead)[/lua][/QUOTE]
Thanks for your help, but I don't see any part of the new model anymore.
How would I send a little tip bubble that pops up on the right of the screen? I want it to show up just clientside, but I am not sure how to use this:
[url]http://luasearch.overvprojects.nl/?keywords=AddWorldTip[/url]
Any help would be great.
Thanks.
I need someone to help me figure out how to set the turrets direction to the direction the owner is looking, I still need it to stand on the ground though so it doesnt fall over.
Help would be appreciated!
[lua]
local SpawnPos = tr.HitPos + tr.HitNormal*2
if util.PointContents(SpawnPos) & CONTENTS_SOLID > 0 then return false end
local ang = tr.HitNormal:Angle()
ang.y = ang.y + Angle(0,LocalPlayer():EyeAngles().y,0)//Wrong
local ply = self.Owner
local ent = ents.Create("npc_turret_floor")
ent:SetPos(SpawnPos)
ent:SetAngles(ang)
ent:SetOwner(ply)
[/lua]
You can try: ply:GetAimVector():Angle()
[QUOTE=Banana Lord.;35012256]Can you send the client a [b]Lua[/b] module with AddCSLuaFile?[/QUOTE]
I don't see why not.
Is it possible to play a scene on model in DModelPanel?
[CODE]local icon = vgui.Create( "DModelPanel", window )
icon:SetModel( "models/breen.mdl" )
icon.Entity:ResetSequence("scenes/Breencast/collaboration.vcd");
[/CODE]
^ won't work.
[CODE]local icon = vgui.Create( "DModelPanel", window )
icon:SetModel( "models/breen.mdl" )
icon.Entity:PlayScene("scenes/Breencast/collaboration.vcd");
[/CODE]
^ won't work too.
Is it possible getting a entities position?
[lua]
print("\n\nAI_MARKET_SELLER POSITION: " .. Market:GetPos())
[/lua]
attempt to concatenate a userdata value.
Ah, thanks. Finally got it printing :P
[editline]6th March 2012[/editline]
Okay, this is weird. It does create the entity, and set it's position, but somehow the NPC doesn't show up on the location?
[lua]
function GM:InitPostEntity( )
local sPos = ents.FindByClass( LastStand.Config.SellerEntity )
if ( #sPos < 1 ) then return end
local Market = ents.Create( "npc_citizen" )
Market:SetPos( Vector( -372.880798, 108.543587, 128.031250 ) ) --sPos[ math.random( 1, #sPos ) ]:GetPos( )
Market:SetAngles( Angle( 0, 90, 0 ) )
Market:Spawn( )
Market:Activate( )
if ( !Market:IsOnGround( ) ) then
Market:DropToFloor( )
end
Market:SetName( "ai_market_seller" )
Market:SetModel( LastStand.Config.SellerModel )
print("\n\nAI_MARKET_SELLER POSITION: " .. tostring(Market:GetPos()))
end
[/lua]
-snip- I cant read..
Are you sure the model is correct though?
Can somebody let me know how I would go about sending a global tip ( the little pop up bubble to the left ) out to all people on the server?
[QUOTE=Trivkz;35021971]-snip- I cant read..
Are you sure the model is correct though?[/QUOTE]
LastStand.Config.SellerModel = "models/alyx.mdl" // Market NPC Model
Wouldn't it return a error model if it was wrong?
[QUOTE=Persious;35022121]LastStand.Config.SellerModel = "models/alyx.mdl" // Market NPC Model
Wouldn't it return a error model if it was wrong?[/QUOTE]
It's been ages since I've used Lua, but try setting the model BEFORE you spawn the NPC?
Okay, I'll try that.
[editline]6th March 2012[/editline]
Haha! That worked. Thank you a lot.
[editline]6th March 2012[/editline]
Eh, stumped on another problem.
Why does
[lua]
for k, v in pairs( LastStand.Config.ZombieEntities ) do
v:Remove()
end
[/lua]
return Bad key to string index (number expected got string)
[QUOTE=Persious;35023052]Okay, I'll try that.
[editline]6th March 2012[/editline]
Haha! That worked. Thank you a lot.
[editline]6th March 2012[/editline]
Eh, stumped on another problem.
Why does
[lua]
for k, v in pairs( LastStand.Config.ZombieEntities ) do
v:Remove()
end
[/lua]
return Bad key to string index (number expected got string)[/QUOTE]
Means v is a string.
[QUOTE=Persious;35023620][lua]
LastStand.Config.ZombieEntities = {
"ai_zombie_explode",
"ai_zombie_run",
"ai_zombie_stalker",
"ai_zombie_walk",
"ai_antlion",
}
[/lua][/QUOTE]
You're calling :Remove() on a string..
Did you mean to do this?
[lua]
for k, v in pairs( LastStand.Config.ZombieEntities ) do
for c, d in pairs( ents.FindByClass( v ) ) do
d:Remove()
end
end
[/lua]
Fuck, my bad.
Repost >_>
[lua]local function ChangeHead(ent)
if ent:IsPlayer() then
local ply = ent
function ply:BuildBonePositions()
local bone = self:LookupBone("ValveBiped.Bip01_Head1")
local vm = self:GetBoneMatrix(bone)
vm:Scale(Vector(0.01, 0.01, 0.01))
self:SetBoneMatrix(bone, vm)
end
local new = ClientsideModel("models/player/urban.mdl")
new:SetParent(ply)
new:AddEffects(EF_BONEMERGE | EF_NOSHADOW)
function new:BuildBonePositions()
for i = 0, self:GetBoneCount()-1 do
if self:GetBoneName(i) == "ValveBiped.Bip01_Head1" then
local vm = self:GetBoneMatrix(i)
vm:Scale(Vector(100, 100, 100)) -- 1/0.01
self:SetBoneMatrix(i, vm)
elseif self:GetBoneName(i) != "__INVALIDBONE__" then
local vm = self:GetBoneMatrix(i)
vm:Scale(Vector(0.01, 0.01, 0.01))
self:SetBoneMatrix(i, vm)
end
end
end
end
end
hook.Add("OnEntityCreated", "ChangeHead", ChangeHead)[/lua]
ClientSideModel() is not showing
Can somebody let me know how I would go about sending a global tip ( the little pop up bubble to the left ) out to all people on the server?
snip
[QUOTE=Arkadi;35028161]Repost >_>
[lua]local function ChangeHead(ent)
if ent:IsPlayer() then
local ply = ent
function ply:BuildBonePositions()
local bone = self:LookupBone("ValveBiped.Bip01_Head1")
local vm = self:GetBoneMatrix(bone)
vm:Scale(Vector(0.01, 0.01, 0.01))
self:SetBoneMatrix(bone, vm)
end
local new = ClientsideModel("models/player/urban.mdl")
new:SetParent(ply)
new:AddEffects(EF_BONEMERGE | EF_NOSHADOW)
function new:BuildBonePositions()
for i = 0, self:GetBoneCount()-1 do
if self:GetBoneName(i) == "ValveBiped.Bip01_Head1" then
local vm = self:GetBoneMatrix(i)
vm:Scale(Vector(100, 100, 100)) -- 1/0.01
self:SetBoneMatrix(i, vm)
elseif self:GetBoneName(i) != "__INVALIDBONE__" then
local vm = self:GetBoneMatrix(i)
vm:Scale(Vector(0.01, 0.01, 0.01))
self:SetBoneMatrix(i, vm)
end
end
end
end
end
hook.Add("OnEntityCreated", "ChangeHead", ChangeHead)[/lua]
ClientSideModel() is not showing[/QUOTE]
ClientsideModels get garbage collected, do ply.whatever = new to prevent this.
Can somebody let me know how I would go about sending a global tip ( the little pop up bubble to the left ) out to all people on the server?
I've been making custom SWEPS (never coded anything before) and i cant seem to get the reload sounds working...
Also when the recoil affects the gun, the bullets still shoot in the same place :(
[lua]//General Settings \\
SWEP.CSMuzzleFlashes = true
SWEP.AdminSpawnable = true // Is the swep spawnable for admin
SWEP.ViewModelFOV = 64 // How much of the weapon do u see ?
SWEP.ViewModel = "models/weapons/v_rif_aa3.mdl" // The viewModel, the model you se when you are holding it-.-
SWEP.WorldModel = "models/weapons/w_rif_aa3.mdl" // The worlmodel, The model yu when it's down on the ground
SWEP.AutoSwitchTo = false // when someone walks over the swep, chould i automatectly change to your swep ?
SWEP.Slot = 3 // Deside wich slot you want your swep do be in 1 2 3 4 5 6
SWEP.HoldType = "smg" // How the swep is hold Pistol smg greanade melee
SWEP.PrintName = "AUG A3" // your sweps name
SWEP.Author = "Elitefroggy" // Your name
SWEP.Spawnable = true // Can everybody spawn this swep ? - If you want only admin keep this false and adminsapwnable true.
SWEP.ViewModelFlip = true
SWEP.AutoSwitchFrom = false // Does the weapon get changed by other sweps if you pick them up ?
SWEP.FiresUnderwater = false // Does your swep fire under water ?
SWEP.Weight = 5 // Chose the weight of the Swep
SWEP.DrawCrosshair = false // Do you want it to have a crosshair ?
SWEP.Category = "Elitefroggy's SWEPS" // Make your own catogory for the swep
SWEP.SlotPos = 3 // Deside wich slot you want your swep do be in 1 2 3 4 5 6
SWEP.DrawAmmo = true // Does the ammo show up when you are using it ? True / False
SWEP.ReloadSound = "none" // Reload sound, you can use the default ones, or you can use your one; Example; "sound/myswepreload.waw"
SWEP.Instructions = "Left click to fire, 'r' to reload." // How do pepole use your swep ?
SWEP.Contact = "xbox.corman@gmail.com" // How Pepole chould contact you if they find bugs, errors, etc
SWEP.Purpose = "Kills Stuff" // What is the purpose with this swep ?
SWEP.base = "weapon_cs_base"
//General settings\\
//PrimaryFire Settings\\
SWEP.Primary.BulletShot = true
SWEP.Primary.Sound = "none" // The sound that plays when you shoot :]
SWEP.Primary.Damage = 32 // How much damage the swep is doing
SWEP.Primary.TakeAmmo = 1 // How much ammo does it take for each shot ?
SWEP.Primary.ClipSize = 32 // The clipsize
SWEP.Primary.Ammo = "smg1" // ammmo type pistol/ smg1
SWEP.Primary.DefaultClip = 64 // How much ammo does the swep come with `?
SWEP.Primary.Spread = 0 // Does the bullets spread all over, if you want it fire exactly where you are aiming leave it o.1
SWEP.Primary.Cone = 0.15 //cone is the acuracy, the less the cone the more acurate and more cone means big spread
SWEP.MoveSpread = 1.5 //multiplier for spread when you are moving
SWEP.JumpSpread = 5 //multiplier for spread when you are jumping
SWEP.CrouchSpread = 0.5 //multiplier for spread when you are crouching
SWEP.Primary.NumberofShots = 1 // How many bullets you are firing each shot.
SWEP.Primary.Automatic = true // Is the swep automatic ?
SWEP.Primary.Recoil = 5 // How much we should punch the view
SWEP.Primary.Delay = 0.1 // How long time before you can fire again
SWEP.Primary.Force = 10 // The force of the shot
SWEP.Primary.Recoil = 1.5
//PrimaryFire settings\\
//Secondary Fire Variables\\
SWEP.IronSightsPos = Vector (2.7843, -3.0914, 0.0344)
SWEP.IronSightsAng = Vector (0, 0, 0)
SWEP.Secondary.Sound = "none" // The sound that plays when you shoot
SWEP.Secondary.Damage = 0 // How much damage the swep is doing
SWEP.Secondary.TakeAmmo = 0 // How much ammo does it take for each shot ?
SWEP.Secondary.ClipSize = -1 // The clipsize
SWEP.Secondary.Ammo = "none" // ammmo type pistol/ smg1
SWEP.Secondary.DefaultClip = -1 // How much ammo does the swep come with `?
SWEP.Secondary.Spread = 0 // Does the bullets spread all over, if you want it fire exactly where you are aiming leave it o.1
SWEP.Secondary.NumberofShots = 0 // How many bullets you are firing each shot.
SWEP.Secondary.Automatic = false // Is the swep automatic ?
SWEP.Secondary.Recoil = 0 // How much we should punch the view
SWEP.Secondary.Delay = 0 // How long time before you can fire again
SWEP.Secondary.Force = 0 // The force of the shot
//Secondary Fire Variables\\
local IRONSIGHT_TIME = 0.25
/*---------------------------------------------------------
Name: GetViewModelPosition
Desc: Allows you to re-position the view model
---------------------------------------------------------*/
function SWEP:GetViewModelPosition( pos, ang )
if ( !self.IronSightsPos ) then return pos, ang end
local bIron = self.Weapon:GetNetworkedBool( "Ironsights" )
if ( bIron != self.bLastIron ) then
self.bLastIron = bIron
self.fIronTime = CurTime()
if ( bIron ) then
self.SwayScale = 0.3
self.BobScale = 0.1
else
self.SwayScale = 1.0
self.BobScale = 1.0
end
end
local fIronTime = self.fIronTime or 0
if ( !bIron && fIronTime < CurTime() - IRONSIGHT_TIME ) then
return pos, ang
end
local Mul = 1.0
if ( fIronTime > CurTime() - IRONSIGHT_TIME ) then
Mul = math.Clamp( (CurTime() - fIronTime) / IRONSIGHT_TIME, 0, 1 )
if (!bIron) then Mul = 1 - Mul end
end
local Offset = self.IronSightsPos
if ( self.IronSightsAng ) then
ang = ang * 1
ang:RotateAroundAxis( ang:Right(), self.IronSightsAng.x * Mul )
ang:RotateAroundAxis( ang:Up(), self.IronSightsAng.y * Mul )
ang:RotateAroundAxis( ang:Forward(), self.IronSightsAng.z * Mul )
end
local Right = ang:Right()
local Up = ang:Up()
local Forward = ang:Forward()
pos = pos + Offset.x * Right * Mul
pos = pos + Offset.y * Forward * Mul
pos = pos + Offset.z * Up * Mul
return pos, ang
end
/*---------------------------------------------------------
SetIronsights
---------------------------------------------------------*/
function SWEP:SetIronsights( b )
self.Weapon:SetNetworkedBool( "Ironsights", b )
end
SWEP.NextSecondaryAttack = 0
/*---------------------------------------------------------
SecondaryAttack
---------------------------------------------------------*/
function SWEP:SecondaryAttack()
if ( !self.IronSightsPos ) then return end
if ( self.NextSecondaryAttack > CurTime() ) then return end
bIronsights = !self.Weapon:GetNetworkedBool( "Ironsights", false )
self:SetIronsights( bIronsights )
self.NextSecondaryAttack = CurTime() + 0.3
end
/*---------------------------------------------------------
DrawHUD
Just a rough mock up showing how to draw your own crosshair.
[QUOTE=Duskling;35040314]Can somebody let me know how I would go about sending a global tip ( the little pop up bubble to the left ) out to all people on the server?[/QUOTE]
Usermessages and the draw/surface library.
I'd store a variable clientside that is an empty string and have it draw with the HUDPaint hook.
Then, I'd use a usermessage that sets the variable clientside and send it to all players.
To make sure the people who joined after the message get it, I would store the tip serverside and send it to the new player on PlayerInitialSpawn.
Hope that helps :smile:
Is there a way to check if an Entity can take damage?
Something similar to this
[code]
barrel:IsBreakable() -- false
woodenCrate:IsBreakable() -- true
[/code]
[lua]
local isBreakable = entity:Health() > 0
[/lua]
Sorry, you need to Log In to post a reply to this thread.