• TTT Flashbang errors
    8 replies, posted
Hey guys I have a problem with my converted flashbang for TTT! Everytime when i try to throw the flashbang i got an error. [ERROR] gamemodes/terrortown/entities/weapons/weapon_tttbasegrenade/shared.lua:210: attempt to call method 'SetThrower' (a nil value) 1. CreateGrenade - gamemodes/terrortown/entities/weapons/weapon_tttbasegrenade/shared.lua:210 2. Throw - gamemodes/terrortown/entities/weapons/weapon_tttbasegrenade/shared.lua:187 3. unknown - gamemodes/terrortown/entities/weapons/weapon_tttbasegrenade/shared.lua:125 Code: (Weapons/shared.lua) [CODE] if (SERVER) then --the init.lua stuff goes in here AddCSLuaFile ("shared.lua") end if (CLIENT) then --the cl_init.lua stuff goes in here SWEP.PrintName = "Flashbang" SWEP.SlotPos = 2 SWEP.IconLetter = "g" SWEP.NameOfSWEP = "weapon_ttt_flashbang" --always make this the name of the folder the SWEP is in. end SWEP.Primary.NumNades = 3 --number of throwable grenades at your disposal SWEP.Grenade = "ttt_thrownflashbang" --self explanitory local here = true SWEP.Author = "Converted by STF | CupCakeR" SWEP.Spawnable = true SWEP.AdminSpawnable = true SWEP.Base = "weapon_tttbasegrenade" SWEP.ViewModel = "models/weapons/v_eq_flashbang.mdl" SWEP.WorldModel = "models/weapons/w_eq_flashbang.mdl" --//TTT-CONVERT\\-- SWEP.Kind = WEAPON_EQUIP2 SWEP.CanBuy = {ROLE_TRAITOR} -- only traitors can buy SWEP.LimitedStock = true -- only buyable once --//END\\-- SWEP.Primary.ClipSize = -1 SWEP.Primary.DefaultClip = -1 SWEP.Primary.Automatic = true SWEP.Primary.Ammo = "none" SWEP.Secondary.ClipSize = -1 SWEP.Secondary.DefaultClip = -1 SWEP.Secondary.Automatic = false SWEP.Secondary.Ammo = "none" SWEP.IronSightsPos = Vector (7.3161, 0, 0.6718) SWEP.IronSightsAng = Vector (7.2937, 9.6773, 51.2462) function SWEP:GetGrenadeName() return "ttt_thrownflashbang" end [/CODE] Code: (Weapons, shared.lua) [CODE] local DIETIMER = 1.5; --time in seconds, for the grenade to transition from full white to clear local EFFECT_DELAY = 0.5; --time, in seconds when the effects still are going on, even when the whiteness of the flash is gone (set to -1 for no effects at all =]). local pos, endflash, endflash2; if (CLIENT) then function ENT:Initialize() pos = self:GetPos() timer.Simple(2, function() local beeplight = DynamicLight( self:EntIndex() ) if ( beeplight ) then beeplight.Pos = pos beeplight.r = 255 beeplight.g = 255 beeplight.b = 255 beeplight.Brightness = 6 beeplight.Size = 1000 beeplight.Decay = 1000 beeplight.DieTime = CurTime() + 0.15 end end) end function ENT:Think() pos = self:GetPos() end function ENT:Draw() self.Entity:DrawModel() end function ENT:IsTranslucent() return true end function SimulateFlash_REALCS_NOT_ANYTHINGELSE() if LocalPlayer():GetNetworkedFloat("RCS_flashed_time") > CurTime()then local pl = LocalPlayer(); local e = pl:GetNetworkedFloat("RCS_flashed_time"); --when it dies away local s = pl:GetNetworkedFloat("RCS_flashed_time_start"); --when it started local alpha; if(e-CurTime()>DIETIMER)then alpha = 255; else local pf = 1-(CurTime() - (e-DIETIMER))/(e - (e-DIETIMER)); alpha = pf*255; end surface.SetDrawColor(255,255,255,math.Round(alpha)); surface.DrawRect(0,0,surface.ScreenWidth(),surface.ScreenHeight()); end end hook.Add("HUDPaint", "SimulateFlash_REALCS_NOT_ANYTHINGELSE", SimulateFlash_REALCS_NOT_ANYTHINGELSE); --motion blur and other junk local function SimulateBlur_REALCS_NOT_ANYTHINGELSE() local pl = LocalPlayer(); local e = pl:GetNetworkedFloat("RCS_flashed_time") + EFFECT_DELAY; --when it dies away local s = pl:GetNetworkedFloat("RCS_flashed_time_start"); --when it started if (e > CurTime() && e-EFFECT_DELAY-CurTime()<=DIETIMER )then local pf = 1-(CurTime() - (e-DIETIMER))/(DIETIMER); DrawMotionBlur(0, pf/((DIETIMER+EFFECT_DELAY)/DIETIMER), 0); //DrawBloom( 3, pf*5, 6, 6, 12, 0, 255, 255, 255 ); elseif(e > CurTime())then DrawMotionBlur( 0, 0.01, 0); else DrawMotionBlur( 0, 0, 0); end end hook.Add( "RenderScreenspaceEffects", "SimulateBlur_REALCS_NOT_ANYTHINGELSE", SimulateBlur_REALCS_NOT_ANYTHINGELSE ) end ENT.Type = "anim" function ENT:OnRemove() end function ENT:PhysicsUpdate() end function ENT:PhysicsCollide(data,phys) if data.Speed > 50 then self.Entity:EmitSound(Sound("weapons/flashbang/grenade_hit1.wav")) end local lollol = -data.Speed * data.HitNormal * .1 + (data.OurOldVelocity * -0.6) phys:ApplyForceCenter(lollol) end [/CODE] Code: (Entities, init.lua) [CODE] local FLASH_INTENSITY = 2250; --the higher the number, the longer the flash will be whitening your screen AddCSLuaFile("shared.lua") include("shared.lua") local function simplifyangle(angle) while(angle>=180) do angle = angle - 360; end while(angle <= -180) do angle = angle + 360; end return angle; end function ENT:Explode() self.Entity:EmitSound(Sound("weapons/flashbang/flashbang_explode"..math.random(1,2)..".wav")); for _,pl in pairs(player.GetAll()) do local ang = (self.Entity:GetPos() - pl:GetShootPos()):GetNormalized():Angle() local tracedata = {}; tracedata.start = pl:GetShootPos(); tracedata.endpos = self.Entity:GetPos(); tracedata.filter = pl; local tr = util.TraceLine(tracedata); local pitch = simplifyangle(ang.p - pl:EyeAngles().p); local yaw = simplifyangle(ang.y - pl:EyeAngles().y); if (!tr.HitWorld) then local dist = pl:GetShootPos():Distance( self.Entity:GetPos() ) local endtime = FLASH_INTENSITY/dist; if (endtime > 6) then endtime = 6; elseif(endtime < 0.4) then endtime = 0.4; end simpendtime = math.floor(endtime); tenthendtime = math.floor((endtime-simpendtime)*10); if( pitch > -45 && pitch < 45 && yaw > -45 && yaw < 45 ) || (pl:GetEyeTrace().Entity && pl:GetEyeTrace().Entity == self.Entity )then --in FOV //pl:PrintMessage(HUD_PRINTTALK, "In FOV"); else //pl:PrintMessage(HUD_PRINTTALK, "Not in FOV"); endtime = endtime/2; end if (pl:GetNetworkedFloat("RCS_flashed_time") > CurTime()) then --if you're already flashed pl:SetNetworkedFloat("RCS_flashed_time", endtime+pl:GetNetworkedFloat("RCS_flashed_time")+CurTime()-pl:GetNetworkedFloat("RCS_flashed_time_start")); --add more to it else --not flashed pl:SetNetworkedFloat("RCS_flashed_time", endtime+CurTime()); end pl:SetNetworkedFloat("RCS_flashed_time_start", CurTime()); end end self.Entity:Remove(); end function ENT:Initialize() self.Entity:SetModel("models/weapons/w_eq_flashbang_thrown.mdl") self.Entity:PhysicsInit( SOLID_VPHYSICS ) self.Entity:SetMoveType( MOVETYPE_VPHYSICS ) self.Entity:SetSolid( SOLID_VPHYSICS ) self.Entity:DrawShadow( false ) self.Entity:SetCollisionGroup( COLLISION_GROUP_WEAPON ) local phys = self.Entity:GetPhysicsObject() if (phys:IsValid()) then phys:Wake() end timer.Simple(2, function() if self.Entity then self:Explode() end end ) end function ENT:Think() end function ENT:OnTakeDamage() self:Explode() end function ENT:Use() end function ENT:StartTouch() end function ENT:EndTouch() end function ENT:Touch() end [/CODE]
[QUOTE=Handsome Matt;43260603]Your entity "ttt_thrownflashbang" is missing the method SetThrower.[/QUOTE] How can i fix it?
How? I'm a lua noob :(
[QUOTE=Handsome Matt;43260637]Add the method to the entity.[/QUOTE] Yes, yes. adding SetThrower() function will definitely fix it.
-snip- [editline]21st December 2013[/editline] In which file i have to add SetThrower()?
[QUOTE=KingCentKing;43260654]Line 210 right?[/QUOTE] Doesn't matter which line. You have to add SetThrower() function ...look... you obviously downloaded this addon from the internet and want us to fix it for you but this forum doesn't work like this. If you were the author of this code you would notice that SetThrower() function doesn't exist and you are trying to call it. It's like telling taxi driver to take you to some non-existant place.
[QUOTE=Netheous;43260670]Doesn't matter which line. You have to add SetThrower() function ...look... you obviously downloaded this addon from the internet and want us to fix it for you but this forum doesn't work like this. If you were the author of this code you would notice that SetThrower() function doesn't exist and you are trying to call it. It's like telling taxi driver to take you to some non-existant place.[/QUOTE] Okay, nice example :D Thank you, i'll try it now! [editline]21st December 2013[/editline] THANK YOU IT WORKS!! I LOVE YOU!!!! #No_Gayyyy!!
Sorry, you need to Log In to post a reply to this thread.