• What do you need help with? V3
    6,419 replies, posted
Just a quick question, how much more of a performance impact does MySQL storage have over file-based, considering a server which is full (20 players) about 22/7 on average. Also, would it be more efficient using the built-in SQL database?
[QUOTE=FPtje;37647926]do you want the angle between the normal and the vector on the plane? That's always 90. If you want to turn the plane vector into an angle you can just do vector:Angle() The angle will be parallel to the plane.[/QUOTE] I'm talking about the 3D Angle object. If I use Vector:Angle(), the Angle's up-direction may not be parallel to the normal - an angle generated from a vector always lacks a roll component (vectors store only direction, not full 3D orientation). This means that if I generate an Angle from a plane direction vector, it will not be correctly oriented to the normal vector - in that case, the Angle's up-direction can not be guaranteed to be equal to the normal direction. Wiremod's quat library is perfect for this because I can specify an up-direction for the quat, and then generate an Angle from it.
Give me some more background on this, I have the feeling that you're taking the wrong approach. A normal vector is normalized and therefore always indicates a direction, like an angle. The cross product I gave you earlier is also normalized and therefore also a direction vector. The roll of the angle does not matter for the direction, but it does matter for the up, like you said. If you need that up, I'd recommend using vectors instead of angles, whatever you want to do with them. Like I said, I need some background.
I want to set the angle of an entity, which has a plane model ("models/Holograms/plane.mdl"). The plane-model is aligned with the entity's xy plane. The entity is a visual representation of a plane, which is stored in lua as a center position and a normal direction. I need to generate an Angle which I can orient the Entity with (via Entity:SetAngles(Angle)), such that the plane model becomes parallel with the mirror-plane. If I use Normal:Cross(any vector), I get a forward vector for the Entity which, using Vector:Angle(), solves only two values of the desired Angle - pitch and yaw - because Vectors cannot store roll. Without roll defined, the two planes cannot be guaranteed to be parallel. What I need is a way to make parallel the plane model and the mirror plane. I know that quats can solve this (working on a conversion of the Wiremod quat library now) but I asked here in the hope that there was a more lightweight solution - maybe something in the GLua libraries.
-snip- Sorry, solved it myself :/
[QUOTE=Splambob;37651549]I want to set the angle of an entity, which has a plane model ("models/Holograms/plane.mdl"). The plane-model is aligned with the entity's xy plane. The entity is a visual representation of a plane, which is stored in lua as a center position and a normal direction. I need to generate an Angle which I can orient the Entity with (via Entity:SetAngles(Angle)), such that the plane model becomes parallel with the mirror-plane. If I use Normal:Cross(any vector), I get a forward vector for the Entity which, using Vector:Angle(), solves only two values of the desired Angle - pitch and yaw - because Vectors cannot store roll. Without roll defined, the two planes cannot be guaranteed to be parallel. What I need is a way to make parallel the plane model and the mirror plane. I know that quats can solve this (working on a conversion of the Wiremod quat library now) but I asked here in the hope that there was a more lightweight solution - maybe something in the GLua libraries.[/QUOTE] The solution turns out to be hilariously simple (in lines of code): [lua](normal:Angle():Up() * -1):Angle()[/lua] Here's a picture that shows why it works: [img]http://imgur.com/ZUIxv.jpg[/img] I tested it and the Up() of the orange-ish vector is the normal :)
Is it somehow possible to detect when a player is kicked and/or banned and execute a function accordingly? There are no specific hooks for this built in as far as I can find.
[QUOTE=FPtje;37652111]The solution turns out to be hilariously simple (in lines of code): [lua](normal:Angle():Up() * -1):Angle()[/lua] Here's a picture that shows why it works: [img]http://imgur.com/ZUIxv.jpg[/img] I tested it and the Up() of the orange-ish vector is the normal :)[/QUOTE] oh my god i'm an idiot i love you <3 @ above; a server I visit hooks into the admin mod to do this, rather than a gamemode hook. If you know that kicks/bans only happen via admin mod, you could do it that way? Otherwise you could scan the disconnect message for "kicked" (I'll admit I don't know if that's possible, maybe scan the server console output after player disconnects?) Edit; [url=http://holopad.googlecode.com/svn/trunk/lua/holopad/obj_quaternion.lua]here's a gift to apologise for shitting up the thread, it's the quaternion library I was going to use. It's a near-direct conversion of the wiremod E2 library. It's totally untested, if arithmetic operators don't work it's because the __type metamethod doesn't work in GLua.[/url]
[QUOTE=iostream;37652236]Is it somehow possible to detect when a player is kicked and/or banned and execute a function accordingly? There are no specific hooks for this built in as far as I can find.[/QUOTE] code it into the administration plugin you use
[QUOTE=skar;37652919]code it into the administration plugin you use[/QUOTE] [QUOTE=Splambob;37652605]@ above; a server I visit hooks into the admin mod to do this, rather than a gamemode hook.[/QUOTE] Alright, thanks. I guess I'll have to write an administration mod, too :)
[QUOTE=iostream;37652949]Alright, thanks. I guess I'll have to write an administration mod, too :)[/QUOTE] if you're using ulx you can just make a plugin or edit the lua files they give you with the ulx release
[QUOTE=skar;37652965]if you're using ulx you can just make a plugin or edit the lua files they give you with the ulx release[/QUOTE] Yeah, I'm not using anything and don't want something fancy like ULX either.
Porting a fretta and a fretta gamemode to GMod 13, I have seen the changes in library, but I don't know what to do about it D:
As far as I know the entire fretta base gamemode got removed from the beta.
[QUOTE=MDave;37653395]As far as I know the entire fretta base gamemode got removed from the beta.[/QUOTE] Hence why I asked for help porting it... I know it's been removed, but I have put the fretta folder from "garrysmod content.gcf" into my gamemodes folder into my beta gamemodes and apparently it's possible to port properly without the errors you get in console
[QUOTE=Cushie;37648268]Just a quick question, how much more of a performance impact does MySQL storage have over file-based, considering a server which is full (20 players) about 22/7 on average. Also, would it be more efficient using the built-in SQL database?[/QUOTE] Just to bump/rephrase, would using the built-in SQL functions be less or more expensive than file-based storage?
Hey guys, I have this entity spawner here, it works good but I wish to add a 1 minute delay before it spawns a next zombie. [code] if self.Count < self.MaxSpawnable then -- Insert 1 minute delay here local ent = ents.Create(self.SpawnEntity) if ent and ent:IsValid() then ent:SetPos(self:GetPos()) ent:SetModel("models/zed/malezed_0"..table.Random( {4, 6, 8} )..".mdl") ent:Spawn() end if not ent:IsInWorld() then ent:Remove() end self.Count = self.Count + 1 table.insert(self.SpawnedNPCs,ent) end [/code] Thanks :D
[QUOTE=Weapon317;37662114]Hey guys, I have this entity spawner here, it works good but I wish to add a 1 minute delay before it spawns a next zombie. [code] if self.Count < self.MaxSpawnable then -- Insert 1 minute delay here local ent = ents.Create(self.SpawnEntity) if ent and ent:IsValid() then ent:SetPos(self:GetPos()) ent:SetModel("models/zed/malezed_0"..table.Random( {4, 6, 8} )..".mdl") ent:Spawn() end if not ent:IsInWorld() then ent:Remove() end self.Count = self.Count + 1 table.insert(self.SpawnedNPCs,ent) end [/code] Thanks :D[/QUOTE] I believe this is what you're looking for: [url]http://wiki.garrysmod.com/page/timer[/url]
Ok i came to another problem.. is there any way to call a function serverside from a clientside function. Like how usermessages are used to send stuff from server to client and call function by client from the hook, is there a similiar way for client > server so that i could call a function from a client function that will run serverside? if you see what i mean
[QUOTE=TNOMCat;37662400]Ok i came to another problem.. is there any way to call a function serverside from a clientside function. Like how usermessages are used to send stuff from server to client and call function by client from the hook, is there a similiar way for client > server so that i could call a function from a client function that will run serverside? if you see what i mean[/QUOTE] Concommands
[QUOTE=Divran;37662203]I believe this is what you're looking for: [url]http://wiki.garrysmod.com/page/timer[/url][/QUOTE] Yeah I tried to mess abit around with it but then it just doesn't show up in the entity menu, so I am basically asking if someone could show me how its done?
i want to disable damage caused by collisions from an ent while having it collide with npcs. how do i do this? [editline]asd[/editline] i tried setting the physobjects mass to 0, but it crashed the game as soon as the collision occured
[QUOTE=CherryJim;37662556]Concommands[/QUOTE] Yeah, but when im trying to do game.ConsoleCommand("serverfunctionsomething") it gives me a nil for ConsoleCommand because im trying to access it from client
[QUOTE=TNOMCat;37665101]Yeah, but when im trying to do game.ConsoleCommand("serverfunctionsomething") it gives me a nil for ConsoleCommand because im trying to access it from client[/QUOTE] Use RunConsoleCommand. Example for understanding how it works: RunConsoleCommand("say", "hey") Example for sending data: RunConsoleCommand("mycommand", arg1, arg2, arg3) On the server you'd then do something like [lua] concommand.Add("mycommand", function(ply, cmd, args) name = arg[1] text = arg[2] poop = arg[3] end) [/lua] [QUOTE=Weapon317;37662114]Hey guys, I have this entity spawner here, it works good but I wish to add a 1 minute delay before it spawns a next zombie. Thanks :D[/QUOTE] You could wrap it in a timer: [lua] timer.Create( "zombietimer", 60, 0, function() if self.Count < self.MaxSpawnable then local ent = ents.Create(self.SpawnEntity) if ent and ent:IsValid() then ent:SetPos(self:GetPos()) ent:SetModel("models/zed/malezed_0"..table.Random( {4, 6, 8} )..".mdl") ent:Spawn() end if not ent:IsInWorld() then ent:Remove() end self.Count = self.Count + 1 table.insert(self.SpawnedNPCs,ent) end end) [/lua] But remember this timer will never run out, you didnt give any context to how it was to be used so you'll probably have to modify it to suit your needs.
[QUOTE=Weapon317;37662114]Hey guys, I have this entity spawner here, it works good but I wish to add a 1 minute delay before it spawns a next zombie. [code] if self.Count < self.MaxSpawnable then -- Insert 1 minute delay here local ent = ents.Create(self.SpawnEntity) if ent and ent:IsValid() then ent:SetPos(self:GetPos()) ent:SetModel("models/zed/malezed_0"..table.Random( {4, 6, 8} )..".mdl") ent:Spawn() end if not ent:IsInWorld() then ent:Remove() end self.Count = self.Count + 1 table.insert(self.SpawnedNPCs,ent) end [/code] Thanks :D[/QUOTE] Lua tags work better for future reference, same as code tags except you type in lua. [lua] ENT.Type = "anim" ENT.PrintName = "Zombie - Spawner" ENT.Author = "Ninjadude" ENT.Spawnable = false ENT.AdminSpawnable = true ENT.Category = "NPC Spawners" ENT.SpawnEntity = "aura_zombie" ENT.MaxSpawnable = 2 ENT.Interval = 200 ENT.Radius = 400 ENT.Count = 0 ENT.SpawnedNPCs = {} if SERVER then AddCSLuaFile("shared.lua") function ENT:SpawnFunction( ply, tr ) if ( !tr.Hit ) then return end local SpawnPos = tr.HitPos + tr.HitNormal * 16 local ent = ents.Create( "npcspawner_aurazombie" ) ent:SetPos( SpawnPos ) ent:Spawn() ent:Activate() return ent end function ENT:Initialize() self:SetModel("models/dav0r/hoverball.mdl") self:PhysicsInit(SOLID_NONE) self:SetMoveType(MOVETYPE_NOCLIP) self:DrawShadow(false) self:DropToFloor() end function ENT:Think() self:NextThink( CurTime() + self.Interval ) for I,N in pairs( self.SpawnedNPCs ) do if not N:IsValid() then table.remove( self.SpawnedNPCs, I ) self.Count = self.Count - 1 end end local MyDelay = 60 --Set this. if self.Count < self.MaxSpawnable then if !self.Delay then self.Delay = ( os.time() + MyDelay ) end if self.Delay < os.time() then self.Delay = MyDelay local ent = ents.Create(self.SpawnEntity) if ent and ent:IsValid() then ent:SetPos(self:GetPos()) ent:SetModel("models/zed/malezed_0"..table.Random( {4, 6, 8} )..".mdl") ent:Spawn() end if not ent:IsInWorld() then ent:Remove() end self.Count = self.Count + 1 table.insert(self.SpawnedNPCs,ent) else --Please wait one minute before another zombie spawns. end end end end if CLIENT then function ENT:Draw() self.Entity:DrawModel() end end [/lua]
Hm, the zombies still spawn directly after they are killed. This is the full code: [lua] ENT.Type = "anim" ENT.PrintName = "Zombie - Spawner" ENT.Author = "Ninjadude" ENT.Spawnable = false ENT.AdminSpawnable = true ENT.Category = "NPC Spawners" ENT.SpawnEntity = "aura_zombie" ENT.MaxSpawnable = 2 ENT.Interval = 200 ENT.Radius = 400 ENT.Count = 0 ENT.SpawnedNPCs = {} if SERVER then AddCSLuaFile("shared.lua") function ENT:SpawnFunction( ply, tr ) if ( !tr.Hit ) then return end local SpawnPos = tr.HitPos + tr.HitNormal * 16 local ent = ents.Create( "npcspawner_aurazombie" ) ent:SetPos( SpawnPos ) ent:Spawn() ent:Activate() return ent end function ENT:Initialize() self:SetModel("models/dav0r/hoverball.mdl") self:PhysicsInit(SOLID_NONE) self:SetMoveType(MOVETYPE_NOCLIP) self:DrawShadow(false) self:DropToFloor() end function ENT:Think() self:NextThink( CurTime() + self.Interval ) for I,N in pairs( self.SpawnedNPCs ) do if not N:IsValid() then table.remove( self.SpawnedNPCs, I ) self.Count = self.Count - 1 end end if self.Count < self.MaxSpawnable then if !self.Delay then self.Delay = ( os.time() + 5 ) end if self.Delay < os.time() then local ent = ents.Create(self.SpawnEntity) if ent and ent:IsValid() then ent:SetPos(self:GetPos()) ent:SetModel("models/zed/malezed_0"..table.Random( {4, 6, 8} )..".mdl") ent:Spawn() end if not ent:IsInWorld() then ent:Remove() end self.Count = self.Count + 1 table.insert(self.SpawnedNPCs,ent) else --Please wait one minute before another zombie spawns. end end end end if CLIENT then function ENT:Draw() self.Entity:DrawModel() end end [/lua]
[QUOTE=Weapon317;37667761]Hm, the zombies still spawn directly after they are killed. This is the full code: [lua]Code [/lua][/QUOTE] You changed the time I had from 60 seconds to 5 seconds, that might be why...
[QUOTE=find me;37667820]You changed the time I had from 60 seconds to 5 seconds, that might be why...[/QUOTE] Nah, just used that for testing, same effect also on 60 seconds. Edit: How it works at the moment: You spawn the ent, then you wait 5 - 10 or 60 seconds before the first two zombies spawn. When they do and they are killed, they respawn instantly from the ent, I want to put a 1 minute delay for that. Just to clear things up about its current state.
For whatever reason, this function isn't working. I'm not entirely sure why. Anybody have any ideas? [lua] function MoneyForKill(victim, inflictor, killer) local steamID = killer:SteamID() local currentmoney = sql.QueryValue("SELECT money FROM player_info WHERE steam_id = '"..steamID.."'") local killmoney = currentmoney + 500 if inflictor:IsWeapon() == true and killer:IsPlayer() == true then killer:SetNWInt("money", killmoney) print(killer:GetNWInt("money")) --Debugging print(""..killer:GetName().." has killed "..victim:GetName().." and gained "..killmoney.."!\n") end end hook.Add("PlayerDeath", "PlayerDies", MoneyForKill) [/lua]
[QUOTE=Weapon317;37667761]Hm, the zombies still spawn directly after they are killed. This is the full code: [lua] -code- [/lua][/QUOTE] There's no line resetting the self.Delay, so right now, it checks if self.Delay exists, if it doesn't, set the current time + 5, then it checks if self.Delay is less than the current time, it will work perfectly at the first time because the delay is set properly there, as the delay will maintain forever and ever the same, it will always be smaller, as the time didn't stop. Use this code: (Didn't test it, but should work.) [lua] ENT.Type = "anim" ENT.PrintName = "Zombie - Spawner" ENT.Author = "Ninjadude" ENT.Spawnable = false ENT.AdminSpawnable = true ENT.Category = "NPC Spawners" ENT.SpawnEntity = "aura_zombie" ENT.MaxSpawnable = 2 ENT.Interval = 200 ENT.Radius = 400 ENT.Count = 0 ENT.SpawnedNPCs = {} if SERVER then AddCSLuaFile("shared.lua") function ENT:SpawnFunction( ply, tr ) if ( !tr.Hit ) then return end local SpawnPos = tr.HitPos + tr.HitNormal * 16 local ent = ents.Create( "npcspawner_aurazombie" ) ent:SetPos( SpawnPos ) ent:Spawn() ent:Activate() return ent end function ENT:Initialize() self:SetModel("models/dav0r/hoverball.mdl") self:PhysicsInit(SOLID_NONE) self:SetMoveType(MOVETYPE_NOCLIP) self:DrawShadow(false) self:DropToFloor() end function ENT:Think() self:NextThink( CurTime() + self.Interval ) for I,N in pairs( self.SpawnedNPCs ) do if not N:IsValid() then table.remove( self.SpawnedNPCs, I ) self.Count = self.Count - 1 end end if self.Count < self.MaxSpawnable then if !self.Delay then self.Delay = ( os.time() + 5 ) end if self.Delay < os.time() then local ent = ents.Create(self.SpawnEntity) if ent and ent:IsValid() then ent:SetPos(self:GetPos()) ent:SetModel("models/zed/malezed_0"..table.Random( {4, 6, 8} )..".mdl") ent:Spawn() end if not ent:IsInWorld() then ent:Remove() end self.Count = self.Count + 1 table.insert(self.SpawnedNPCs,ent) self.Delay = nil else --Please wait one minute before another zombie spawns. end end end end if CLIENT then function ENT:Draw() self.Entity:DrawModel() end end [/lua]
Sorry, you need to Log In to post a reply to this thread.