Hello guys! i just want some help to add the popcorn on the pointshop!
I already put it, but it's not working
here is the popcorn (pointshop): [url]http://www.mediafire.com/download/55pp75yctlbwx51/ps_popcorn.zip[/url]
That's what i get (When i buy popcorn)
I get an empty hand O_O (but i still can eat it, and throw it!)
[IMG]http://image.noelshack.com/fichiers/2014/25/1403376904-empty1.jpg[/IMG]
And i get this error in the console (when i throw it!)
[IMG]http://image.noelshack.com/fichiers/2014/25/1403376917-popcorn2.jpg[/IMG]
[editline]21st June 2014[/editline]
Here is the popcorn.lua file:
[code]
ITEM.Name = 'Popcorn'
ITEM.Price = 10
ITEM.Model = 'models/teh_maestro/popcorn.mdl'
ITEM.WeaponClass = 'weapon_popcorn' --Just a guess idk the SWEP name
ITEM.SingleUse = true
function ITEM:OnBuy(ply)
ply:Give(self.WeaponClass)
ply:SelectWeapon(self.WeaponClass)
end
function ITEM:OnSell(ply)
ply:StripWeapon(self.WeaponClass)
end
[/code]
Look this tread : [url]http://facepunch.com/showthread.php?t=1399701[/url]
i already look that thread, and his code is not working :(
It's a problem with the SWEP, your going to need to provide the SWEP (shared.lua + cl_init.lua)
shared.lua:
[lua]
ENT.Base = "base_anim"
ENT.Type = "anim"
ENT.PrintName = "Thrown Popcorn"
ENT.Model = Model( "models/Teh_Maestro/popcorn.mdl" )
[/lua]
cl_init.lua
[lua]
include("shared.lua")
local function kernel_init(particle, vel)
particle:SetColor(255,255,255,255)
particle:SetVelocity( vel or VectorRand():GetNormalized() * 15)
particle:SetGravity( Vector(0,0,-200) )
particle:SetLifeTime(0)
particle:SetDieTime(math.Rand(5,10))
particle:SetStartSize(2)
particle:SetEndSize(0)
particle:SetStartAlpha(255)
particle:SetEndAlpha(0)
particle:SetCollide(true)
particle:SetBounce(0.25)
particle:SetRoll(math.pi*math.Rand(0,1))
particle:SetRollDelta(math.pi*math.Rand(-10,10))
end
function ENT:Initialize()
self.emitter = ParticleEmitter(self:GetPos())
if self and self:EntIndex() != 0 then
local kt = "kernel_timer"..self:EntIndex()
timer.Create(kt,0.01,0,function()
if !self.emitter then
timer.Stop(kt)
return
end
if math.Rand(0,1) < 0.33 then
local particle = self.emitter:Add( "particle/popcorn-kernel", self:GetPos() + VectorRand():GetNormalized() * 4 )
if particle then
kernel_init(particle)
end
end
end)
timer.Simple(10, function ()
timer.Destroy(kt)
if self and self.emitter then
self.emitter:Finish()
end
end)
end
net.Receive("Popcorn_Explosion",function ()
if !self then return end
local pos = net.ReadVector()
local norm = net.ReadVector()
local bucketvel = net.ReadVector()
local entid = net.ReadFloat()
timer.Destroy("kernel_timer"..entid)
local emitter = self.emitter or ParticleEmitter(pos)
for i = 1,150 do
local particle = emitter:Add( "particle/popcorn-kernel", pos )
if particle then
local dir = VectorRand():GetNormalized()
kernel_init(particle, ((-norm)+dir):GetNormalized() * math.Rand(0,200) + bucketvel*0.5 )
end
end
emitter:Finish()
end)
end
[/lua]
We need the SWEP's lua files. Not the ENT's.
Oh sorry ! :(
here you go bro:
shared.lua
[lua]
SWEP.ViewModel = "models/Teh_Maestro/popcorn.mdl"
SWEP.WorldModel = "models/Teh_Maestro/popcorn.mdl"
SWEP.Spawnable = true
SWEP.AdminSpawnable = false
SWEP.Author = "Antimony51"
SWEP.Instructions = "Left Click: Eat Popcorn\nRight Click: Throw Bucket"
SWEP.Primary.Clipsize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "none"
SWEP.Secondary.Clipsize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
SWEP.DrawAmmo = false
SWEP.Slot = 1
SWEP.SlotPos = 1
SWEP.HoldType = "shotgun"
function SWEP:Deploy()
end
function SWEP:Think()
if (self.Owner.ChewScale or 0) > 0 then
if SERVER then
if (CurTime() >= self.Owner.BiteStart+0.625 and self.Owner.BitesRem > 0) then
self.Owner.BiteStart = CurTime()
self.Owner.BitesRem = self.Owner.BitesRem - 1
net.Start("Popcorn_Eat")
net.WriteEntity(self.Owner)
net.WriteFloat(math.Round(math.Rand(4,8)+self.Owner.BitesRem*8))
net.Broadcast()
end
end
self.Owner.ChewScale = math.Clamp((self.Owner.ChewStart+self.Owner.ChewDur - CurTime())/self.Owner.ChewDur,0,1)
end
end
function SWEP:Initialize()
util.PrecacheSound("crisps/eat.wav")
end
function SWEP:PrimaryAttack()
if SERVER then
self.Owner:EmitSound( "crisps/eat.wav", 60)
self.Owner.BiteStart = 0
self.Owner.BitesRem = 3
net.Start("Popcorn_Eat_Start")
net.WriteEntity(self.Owner)
net.Broadcast()
end
self.Owner.ChewScale = 1
self.Owner.ChewStart = CurTime()
self.Owner.ChewDur = SoundDuration("crisps/eat.wav")
self.Weapon:SetNextPrimaryFire(CurTime() + 12 )
end
function SWEP:SecondaryAttack()
local bucket, att, phys, tr
self.Weapon:SetNextSecondaryFire(CurTime() + 16)
if (self.Owner:IsAdmin()) then
self.Weapon:SetNextSecondaryFire(CurTime())
end
if CLIENT then
return
end
self.Owner:EmitSound( "weapons/slam/throw.wav" )
self.Owner:ViewPunch( Angle( math.Rand(-8,8), math.Rand(-8,8), 0 ) )
bucket = ents.Create( "sent_popcorn_thrown" )
bucket:SetOwner( self.Owner )
bucket:SetPos( self.Owner:GetShootPos( ) )
bucket:Spawn()
bucket:Activate()
phys = bucket:GetPhysicsObject( )
if IsValid( phys ) then
phys:SetVelocity( self.Owner:GetPhysicsObject():GetVelocity() )
phys:AddVelocity( self.Owner:GetAimVector( ) * 128 * phys:GetMass( ) )
phys:AddAngleVelocity( VectorRand() * 128 * phys:GetMass( ) )
end
--[[
if !self.Owner:IsAdmin() then
self.Owner:StripWeapon("weapon_popcorn")
end
--]]
end
[/lua]
and:
cl_init.lua
[lua]
include('shared.lua')
SWEP.PrintName = "Popcorn SWEP"
SWEP.Slot = 1
SWEP.SlotPos = 1
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = false
SWEP.WepSelectIcon = surface.GetTextureID( "vgui/entities/weapon_popcorn" )
function SWEP:GetViewModelPosition( pos , ang)
pos,ang = LocalToWorld(Vector(20,-10,-15),Angle(0,0,0),pos,ang)
return pos, ang
end
local function kernel_init(particle, vel)
particle:SetColor(255,255,255,255)
particle:SetVelocity( vel or VectorRand():GetNormalized() * 15)
particle:SetGravity( Vector(0,0,-200) )
particle:SetLifeTime(0)
particle:SetDieTime(math.Rand(5,10))
particle:SetStartSize(1)
particle:SetEndSize(0)
particle:SetStartAlpha(255)
particle:SetEndAlpha(0)
particle:SetCollide(true)
particle:SetBounce(0.25)
particle:SetRoll(math.pi*math.Rand(0,1))
particle:SetRollDelta(math.pi*math.Rand(-4,4))
end
function SWEP:Initialize()
end
net.Receive("Popcorn_Eat",function ()
local ply = net.ReadEntity()
local size = net.ReadFloat()
local attachid = ply:LookupAttachment("eyes")
local emitter = ParticleEmitter(ply:GetPos())
local angpos = ply:GetAttachment(attachid)
local fwd
local pos
if (ply != LocalPlayer()) then
fwd = (angpos.Ang:Forward()-angpos.Ang:Up()):GetNormalized()
pos = angpos.Pos + fwd*3
else
fwd = ply:GetAimVector():GetNormalized()
pos = ply:GetShootPos() + gui.ScreenToVector( ScrW()/2, ScrH()/4*3 )*10
end
for i = 1,size do
if !ply then return end
local particle = emitter:Add( "particle/popcorn-kernel", pos )
if particle then
local dir = VectorRand():GetNormalized()
kernel_init(particle, ((fwd)+dir):GetNormalized() * math.Rand(0,40))
end
end
emitter:Finish()
end)
net.Receive("Popcorn_Eat_Start",function ()
local ply = net.ReadEntity()
ply.ChewScale = 1
ply.ChewStart = CurTime()
ply.ChewDur = SoundDuration("crisps/eat.wav")
end)
function GAMEMODE:MouthMoveAnimation (ply)
local FlexNum = ply:GetFlexNum() - 1
if ( FlexNum <= 0 ) then return end
local chewing = false
local weight
if ((ply.ChewScale or 0) > 0) then
local x = CurTime()-ply.ChewStart
weight = 0.5*math.sin(x*(2*math.pi/0.625)-0.5*math.pi)+0.5
chewing = true
end
for i=0, FlexNum-1 do
local Name = ply:GetFlexName( i )
if ( Name == "jaw_drop" || Name == "right_part" || Name == "left_part" || Name == "right_mouth_drop" || Name == "left_mouth_drop" ) then
if ( ply:IsSpeaking() ) then
ply:SetFlexWeight( i, math.Clamp( ply:VoiceVolume() * 2, 0, 2 ) )
elseif ((ply.ChewScale or 0) > 0) then
ply.ChewScale = math.Clamp((ply.ChewStart+ply.ChewDur - CurTime())/ply.ChewDur,0,1)
if (Name == "jaw_drop" ) then
ply:SetFlexWeight( i, weight*(ply.ChewScale*2) )
else
ply:SetFlexWeight( i, weight*((ply.ChewScale*2)-1.25) )
end
else
ply:SetFlexWeight( i, 0 )
end
end
end
end
[/lua]
[URL="http://steamcommunity.com/sharedfiles/filedetails/?id=171935748"]http://steamcommunity.com/sharedfiles/filedetails/?id=171935748[/URL]
Read the description.
[quote]
To add to pointshop, extract this into addons...
[url]http://www.mediafire.com/download/55pp75yctlbwx51/ps_popcorn.zip[/url]
It is set to 10 points by default.
[/quote]
That's what i did bro !
and i get errors !!!!
Because his popcorn pointshop is outdated :'( It's possible that it is no longer compatible with the nevest version of pointshop.
[editline]22nd June 2014[/editline]
I get this error:
[url]http://i.imgur.com/QGofUFF.png[/url]
[QUOTE=Anyome;45181635]That's what i did bro !
and i get errors !!!!
Because his popcorn pointshop is outdated :'( It's possible that it is no longer compatible with the nevest version of pointshop.
[editline]22nd June 2014[/editline]
I get this error:
[url]http://i.imgur.com/QGofUFF.png[/url][/QUOTE]
Contact the author who fixed it up previously.
The author is not supporting it anymore he's done with it, i already contacted him :(
Talked to him over steam, fixed it for him.
Thanks to Sm63 ! Fixed ;)
But i still have this problem:
[IMG]http://image.noelshack.com/fichiers/2014/25/1403443750-popcornn9.jpg[/IMG]
I can't see the popcorn on my hand, but i can throw it and eat it ! Sm63 any idea? :(
[QUOTE=Anyome;45183135]Thanks to Sm63 ! Fixed ;)
But i still have this problem:
[IMG]http://image.noelshack.com/fichiers/2014/25/1403443750-popcornn9.jpg[/IMG]
I can't see the popcorn on my hand, but i can throw it and eat it ! Sm63 any idea? :([/QUOTE]
I think its a gmod thing, not really a swep thing
You can reposition the view-model in SWEP:GetViewModelPosition( pos, ang )...
Overwrite the function in your SWEP and see if you can reposition it. If not, try using the world-model, scale it, and position it. Draw the C hands manually to they appear.
Acecool, thanks for your answer, i tried this but i still get an empty hand :(
[lua]
function SWEP:GetViewModelPosition( pos , ang)
pos,ang = LocalToWorld(Vector(20,-10,-15),Angle(0,0,0),pos,ang)
return pos, ang
end
[/lua]
LocalToWorld but calling from global so that may end up being the same coords.. Use Player:LocalToWorld.... so that it is bound to the player to ensure the coords will work with the player.
@Acecool, please give me tha code, you know i'm a noob ! i can't understand what' you're saying
can't you just give me the code to put on the .lua file?
please bro :(
Sorry, you need to Log In to post a reply to this thread.