• What do you need help with V4
    639 replies, posted
  • Avatar of TheTeekz
  • "..and how would we go about doing this? :smile:" he asked, feeling like a lua noob. :suicide:
  • Avatar of TheTeekz
  • It uses giveplayeritem, as far as we can tell. I could probably find the code again and post it, if it would help? We're currently running the GoFish mod.
  • Avatar of pennerlord
  • [QUOTE=TheTeekz;35374300]It uses giveplayeritem, as far as we can tell. I could probably find the code again and post it, if it would help? We're currently running the GoFish mod.[/QUOTE] Yeah, the code would help us.
  • Avatar of TheTeekz
  • [lua] function giveplayeritem(ply,cmd,args) local amount = tonumber(args[2]) if ply:GetNetworkedInt("cash") >= amount then ply:Give(args[1]) ply:SetNetworkedInt("cash", ply:GetNetworkedInt("cash") - amount) umsg.Start("MoneyChanged",ply) umsg.Short(ply:GetNetworkedInt("cash")) umsg.End() else ply:PrintMessage( HUD_PRINTTALK, "You Do Not Have Enough Money") end end concommand.Add("giveplayeritem", giveplayeritem) [/lua] I believe that's the section of the code that deals with purchasing from the shop.
  • Avatar of pennerlord
  • [lua]local amount = tonumber(args[2])[/lua] With this code the client can control the price. You should use a shared/serverside table for the prices and get the price for the item from that table. Give me a few minutes and I will give you an example... [editline].[/editline] Here's a really basic example. It should give you an idea about what I'm talking. [lua] local ShopTable = {} ShopTable["weapon_357"] = 100 -- Price = 100 <insert currency here> local function GivePlayerItem(ply, cmd, args) local item = args[1] local price = ShopTable[item] if not item or not price then return end -- check if this item is a valid item -- your code here end concommand.Add("YourCommand", GivePlayerItem) [/lua]
  • ok, does anyone know where the download is for the custom Trouble in Terrorist Town -Traitor turret is. it looks like a normal combine turret but it has health and only shoots non-traitors. I really want to use it to learn from, and mod it, i've seen other servers with it and i can't find it anywhere. Anyone know where it is? thanks guys!
  • Avatar of TheTeekz
  • [QUOTE=pennerlord;35374751]With this code the client can control the price. You should use a shared/serverside table for the prices and get the price for the item from that table.[/QUOTE] Thanks for the example. :smile: I feel that I should note that the shop code I posted above was from the initialization script (init.lua) of the gamemode we're using, and the items/prices in the shop are already set in a different script in the same directory, (shared.lua). Could we reference these somehow, instead of creating a new table?
  • Avatar of pennerlord
  • [QUOTE=TheTeekz;35375217]Thanks for the example. :smile: I feel that I should note that the shop code I posted above was from the initialization script (init.lua) of the gamemode we're using, and the items/prices in the shop are already set in a different script in the same directory, (shared.lua). Could we reference these somehow, instead of creating a new table?[/QUOTE] Sure, you can, as long as the table is global.
  • Avatar of LilRobot
  • -snip- i'll just go make a topic in the questions section for more direct help
  • Avatar of TheTeekz
  • [QUOTE=pennerlord;35375752]Sure, you can, as long as the table is global.[/QUOTE] Great, thanks for the assistance. :)
  • Avatar of Hugabuga
  • [QUOTE=Drakehawke;35373216]Are you trying to add some sounds as single words and some as multiple words? If so, you can either fiddle around with checking type(sound.Text) or just change your single word ones so they are enclosed in {} eg SoundPlayer.AddSound( { "hi" }, "directory" )[/QUOTE] I did enclose all the words, and never used type() - Mind explaining how it works?
  • Avatar of Drakehawke
  • [QUOTE=Persious;35377166]I did enclose all the words, and never used type() - Mind explaining how it works?[/QUOTE] type( 123 ) == "number" type( "abc" ) == "string" type( Vector() ) == "vector" type( LocalPlayer() ) == "player" type( Entity( 0 ) ) == "entity" etc However if you enclosed the words in parenthesis correctly it should work, mind telling us which line the error occurred on?
  • Avatar of LilRobot
  • i've fixed up most of the problems i had detailed the only issues now are there's no muzzle flash and the weapon doesn't fire a projectile [code] -- Effect settings SWEP.PrintName = "Wunderwaffe DG-2" -- SWEP.Slot = 0 -- SWEP.SlotPos = 11 -- SWEP.DrawAmmo = true -- SWEP.DrawCrosshair = true -- SWEP.ViewModel = "models/weapons/v_wunderwaffe.mdl" -- SWEP.WorldModel = "models/weapons/c_models/c_wunderwaffe/c_wunderwaffe_hl2.mdl" -- SWEP.ReloadSound = "wunderwaffe_reload.wav" -- SWEP.PickupSound = "richtofen_pickupa.wav" [/code] [code] -- Other settings SWEP.HoldType = "shotgun" SWEP.Weight = 5 -- SWEP.AutoSwitchTo = true -- SWEP.AutoSwitchFrom = false -- SWEP.Spawnable = true -- SWEP.AdminSpawnable = true -- --SWEP.AutoReload = false -- [/code] [code] -- Primary fire settings SWEP.Primary.Sound = "wunderwaffe_fire.wav" -- SWEP.Primary.Damage = 50 -- SWEP.Primary.NumShots = 1 -- SWEP.Primary.Recoil = .5 -- SWEP.Primary.Cone = 0 -- SWEP.Primary.Delay = 1.5 -- SWEP.Primary.ClipSize = 3 -- SWEP.Primary.DefaultClip = 3 -- SWEP.Primary.Tracer = 1 -- SWEP.Primary.Force = 1 -- SWEP.Primary.TakeAmmoPerBullet = true -- SWEP.Primary.Automatic = false -- SWEP.Primary.Ammo = "ar2" -- [/code] so uh, any help?
  • Avatar of Hugabuga
  • [QUOTE=Drakehawke;35377387]type( 123 ) == "number" type( "abc" ) == "string" type( Vector() ) == "vector" type( LocalPlayer() ) == "player" type( Entity( 0 ) ) == "entity" etc However if you enclosed the words in parenthesis correctly it should work, mind telling us which line the error occurred on?[/QUOTE] There simply is no error, but it doesn't emit the sound. I have no clue what's causing it.
  • Avatar of Drakehawke
  • [QUOTE=Persious;35383981]There simply is no error[/QUOTE] [quote=Persious]Hook 'SoundPlayer.ChatFunction' Failed: bad argument #1 to 'pairs' (table expected, got nil)[/quote] :S
  • Avatar of LilRobot
  • i ironed out a lot of the problems with my weapon. now my only question is, is it possible to make it have a radius explosion or zap type thing where a bullet hits?
  • Avatar of pennerlord
  • [QUOTE=LilRobot;35384079]i ironed out a lot of the problems with my weapon. now my only question is, is it possible to make it have a radius explosion or zap type thing where a bullet hits?[/QUOTE] Yes, there is a way. For example: [lua] local tr = self.Owner:GetEyeTrace() local effectdata = EffectData() effectdata:SetOrigin(tr.HitPos) effectdata:SetStart(self.Owner:GetShootPos()) effectdata:SetAttachment(1) effectdata:SetEntity(self) util.Effect("ToolTracer", effectdata) [/lua]
  • Avatar of LilRobot
  • thanks for that, but what i meant was kind of like an explosion where the bullet hits as in, an explosion that kills things, preferably dissolves them.
  • Avatar of pennerlord
  • [QUOTE=LilRobot;35385313]thanks for that, but what i meant was kind of like an explosion where the bullet hits as in, an explosion that kills things, preferably dissolves them.[/QUOTE] A real explosion or just the explosion effect?
  • Avatar of LilRobot
  • [QUOTE=pennerlord;35385874]A real explosion or just the explosion effect?[/QUOTE] a real one, the effect i can make myself.
  • Avatar of Kogitsune
  • You'd want to do something like: [code] for k, v in pairs( ents.FindInSphere( hitpos, radius ) ) do info = DamageInfo( ) info:SetDamageType( DMG_BLAST | DMG_DISSOLVE ) info:SetDamage( 15 ) info:SetAttacker( pl ) info:SetInflictor( pl:GetActiveWeapon( ) ) info:SetDamagePos( hitpos ) info:SetDamageForce( ( v:GetPos( ) - hitpos ):GetNormal( ) * force ) v:TakeDamageInfo( info ) end [/code]
  • Avatar of pennerlord
  • Another way: [lua] local explosion = ents.Create("env_explosion") explosion:SetPos(pos) explosion:SetKeyValue("iMagnitude", 100) -- damage explosion:SetKeyValue("iRadiusOverride", 250) -- radius explosion:Spawn() explosion:Fire("explode", "", 0) [/lua]
  • Avatar of LilRobot
  • as for an explosion effect, i'm taking a wild guess that this modifier should work it [lua] local effectsplode = EffectData() effectsplode:SetOrigin(tr.HitPos) effectsplode:SetStart(tr.HitPos()) effectsplode:SetEntity(self) util.Effect("UNKNOWN", effectdata) [/lua] "UNKNOWN" is there because i'm not sure of the explosion effects. do they use particle systems? the only thing i really need right now though is a fix for my holdtype i'm pretty sure i entered it in right.. [lua] SWEP.HoldType = "SMG"; [/lua]
  • Avatar of Drakehawke
  • [QUOTE=Johnny Guitar;35391053]Can't get any derma elements to scroll along with my scrollbar.[/QUOTE] Post code?
  • Avatar of Rory
  • I need an LUA script that will make names different colors. I'd like each level of admin etc to have their name in a separate color. This is for the sandbox game mode.
  • Avatar of Johnny Guitar
  • Whats up with silkicons in the gmod13 update [IMG]http://cloud.steampowered.com/ugc/595840894529618366/D6A978BC34009C4CEC2565476901052B1DD74BFF/[/IMG]
  • Avatar of ralle105
  • [QUOTE=Rory;35392588]I need an LUA script that will make names different colors. I'd like each level of admin etc to have their name in a separate color. This is for the sandbox game mode.[/QUOTE] This isn't a request thread, go the to the requests section.