[QUOTE=JustShine;38810919]Is there any default lua command that applies like the ent_fire !picker does (ex: where you looking at prop/entity/player etc.)?[/QUOTE]
player:GetEyeTrace().Entity
[QUOTE=sniperdude0;38808127][url]http://pastebin.com/4kyv2LJv[/url]
and here is the error message again
[lua]
[ERROR] addons/wanted/lua/autorun/client/cl_wanted.lua:207: attempt to call method 'EnableHorizontal' (a nil value)
1. Function - addons/wanted/lua/autorun/client/cl_wanted.lua:207
2. unknown - lua/includes/modules/usermessage.lua:87
[/lua][/QUOTE]
I'm thinking about making a new version of my wanted addon (I suppose you use my former one).
-snip- Turns out as a whole the Inflictor variable in the bullet table doesn't work as a whole, off I go to post a bug report.
I'm working on a gamemode similar to Killing Floor and games like it: randomly spawning waves of NPCs. I've been trying to get the prop_vehicle_apc and npc_apcdriver entities to work for use with it (i.e. an APC spawning around a corner and driving in your way).
So far, I've been able to get it to shoot at players and NPCs without any problems. It spawns successfully and without any errors. However...
[img]http://cloud-2.steampowered.com/ugc/884094379080791371/4E7F9DA1194D08FBAEB4454E2FB0C10045ACE78E/[/img]
[i]The assault begins, but with no causalities.[/i]
Neither the pulse gun mounted on the side or the rockets do any damage to any Rebel-aligned NPCs.
[img]http://cloud.steampowered.com/ugc/884094379080789775/D80858A2989BA1B6C874BB913B30D1814DC74476/[/img]
[img]http://cloud.steampowered.com/ugc/884094379080787628/A1F0590526DCECF8B0602A40E8282A52829B2D6E/[/img]
[i]Poor Kleiners.[/i]
It's not a problem with any of my code, because other NPCs can damage them just fine:
[img]http://cloud-2.steampowered.com/ugc/884094379080788195/6104C383E556FEB68553C5F3FAE29069E518E971/[/img]
[i]Even with the low HP of the Kleiner NPC, a Combine's shotgun does more damage.[/i]
Also, players can still take damage, along with any NPC (that I've tested), just not the Rebels:
[img]http://cloud-2.steampowered.com/ugc/884094379080790556/6249D3E39018EB1800C39466E09E48A5763D3D95/[/img]
[i]I placed Gman there so the APC would have a target that wouldn't die so the APC could accidentally shoot the Combine soldiers.[/i]
[img]http://cloud-2.steampowered.com/ugc/884094379080792003/2AA12BB0FA4DA1468B993456481778A8A357F5F0/[/img]
I'm at a complete loss here.
Not only that, but I attempted to make the vehicle move using point_corners. It doesn't move at all, even if I fire StartForward on the APC NPC.
Here's the code I'm using to spawn it:
[code]
function ENT:Initialize()
self.APC = ents.Create("prop_vehicle_apc")
self.APC:SetModel("models/combine_apc.mdl")
self.APC:SetPos(self:GetPos())
self.APC:SetAngles(self:GetAngles())
self.APC:SetName("CombineAPC" .. self:EntIndex())
self.APC:SetKeyValue("vehiclescript", "scripts/vehicles/apc_npc.txt")
self.APC:Spawn()
self.APC:Activate()
self.APCDriver = ents.Create("npc_apcdriver")
self.APCDriver:SetPos(self:GetPos())
self.APCDriver:SetName("CombineAPC" .. self:EntIndex() .. "Driver")
self.APCDriver:SetKeyValue("vehicle", "CombineAPC" .. self:EntIndex())
self.APCDriver:Spawn()
self.APCDriver:Activate()
end
[/code]
...And here's the follow code (which works fine, all the prints fire, but it still doesn't move):
[code]
function ENT:Think()
if not IsValid(self.APC) or not IsValid(self.APCDriver) then
self:Remove()
return
end
local Pos = self.APC:OBBCenter()
Pos:Rotate(self.APC:GetAngles())
Pos = Pos + self.APC:GetPos()
self:SetPos(Pos)
self.APCDriver:SetPos(Pos)
local ClosestDistance = math.huge
for _, Ent in pairs(ents.GetAll()) do
if Ent ~= self and Ent ~= self.APC and Ent ~= self.APCDriver and ((Ent:IsNPC() or Ent:IsPlayer()) and Ent:GetModel()) and Ent:Health() > 0 and self.APCDriver:Disposition(Ent) == D_HT then
if util.TraceLine(
{
start = Pos,
endpos = Ent:GetPos(),
filter = {self, self.APC, self.APCDriver}
}
).Entity == Ent then
local Distance = Ent:GetPos():Distance(Pos)
if Distance < ClosestDistance then
ClosestDistance = Distance
self.Target = Ent
end
end
end
end
if IsValid(self.Target) and self.Target ~= self.OldTarget and Pos:Distance(self.Target:GetPos()) > 500 and math.random(1, 2000) then
print("Found an enemy.", self.Target, self.OldTarget)
if not IsValid(self.Path) then
print("Need to make a path.")
self.Path = ents.Create("path_corner")
self.Path:SetName("CombineAPC" .. self:EntIndex() .. "Target")
self.Path:Spawn()
self.Path:Activate()
print("Firing GotoPathCorner.")
self.APCDriver:Fire("GotoPathCorner", "CombineAPC" .. self:EntIndex() .. "Target")
end
print("Set pos.\n\n\n")
self.Path:SetPos(self.Target:GetPos())
self.Path:SetParent(self.Target)
self.OldTarget = self.Target
end
end
[/code]
My only guess as to why the follow code isn't working is that I'm incorrectly using GotoPathCorner and/or path_corners. But all my research tells me I'm doing it correctly.
A huge thanks to any possible help on this quite trivial matter.
[editline]13th December 2012[/editline]
Also, my apologies if this has been addressed before and I just didn't look hard enough.
[editline]13th December 2012[/editline]
Oh, and, yes, I have tried setting the position of the path_corner before I spawn it, no effect.
[QUOTE=NinjaS;38815209][URL="http://wiki.garrysmod.com/page/Libraries/resource/AddFile"]resource/AddFile[/URL]
On the Additional Notes
If called for vmt or mdl files, all related files will be automatically added.
I'm guessing if you add a bleh.mdl file only the models bleh.vtx bleh.skn ect would get downloaded, but not the materials.[/QUOTE]
My experience with this is that it will NOT add all related files. I made a recursive scanner that adds all game-mode content to resource.AddFile for mdl, or the other which adds all related; it didn't work. If I did resource.AddFile for ALL files, it would make the table overflow. I'm using resource.AddSingleFile to go through all files, and it works flawlessly.
-snip-
I set player to spectate on initialSpawn and show the team menu right away so they can choose a team. The problem is that if there are multiple players in spectate at one time, then they'll 'spawn' on top of eachother and die.
Any ideas?
I tried enabling god-mode and setting the teammates to nocollide but it still didn't stop them from dying due to spawning on top of each other.
Could I get some help with the tmysql module? I'm not sure how to use it, it's been a while since I've touched the module so I can't remember anything...
[lua] if CLIENT then
concommand.add("Donate",function(pl, cmd, args)
local Frame = vgui.Create("DFrame")
Frame:SetSize(ScrW() - 20, ScrH() - 20)
Frame:Center()
Frame:SetTitle("Donate")
Frame:MakePopup()
Frame:SetMouseInputEnabled(true)
local html = vgui.Create("DHTML", Frame)
html:SetPos(5,25)
html:SetSize(ScrW() - 30, ScrH() - 30)
html:OpenURL("http://forum.ammgaming.com/index.php?page=Donate")
end)
end
if SERVER then
hook.Add("PlayerSay", "ChatHook", function(Player, Text, Public)
if Text[1] == "!" then
Text = Text:lower()
if Text == "!donate" then
Player:ConCommand("Donate")
return ""
end
end
end)
end
[/lua]
Getting the error
[ERROR] lua/autorun/donate.lua:20: '=' expected near 'Text'
1. unknown - lua/autorun/donate.lua:0
can some1 please tell me what im doing wrong?
[QUOTE=DarkShadow6;38820827]Neither the pulse gun mounted on the side or the rockets do any damage to any Rebel-aligned NPCs.[/QUOTE]
If I remember correctly, you need to set the damage explictly via Entity.SetSaveValue. You should take a look at what Entity.GetSaveTable returns if there's anything related to damage in there.
[QUOTE=DarKSunrise;38825482]If I remember correctly, you need to set the damage explictly via Entity.SetSaveValue. You should take a look at what Entity.GetSaveTable returns if there's anything related to damage in there.[/QUOTE]
I... I had no idea you could set C-side value with GLua...
...
This would have been so helpful so many times...
After Gmod is done VALERDATIN' I'll try it.
[editline]14th December 2012[/editline]
Any ideas on the movement?
[editline]14th December 2012[/editline]
DAT FEEL
WHEN YOU REALISE
SETKEYVALUES, ENT:FIRE AND SETSAVETABLE CAN ALL PRETTY MUCH DO THE SAME THING
FFS.
Also, no values like that in the npc. I'll try the vehicle.
[editline]14th December 2012[/editline]
I have tried:
[code]
self.APC:SetSaveValue("speed", "100")
self.APC:SetSaveValue("m_hNPCDriver", self.APCDriver)
self.APCDriver:SetSaveValue("speed", "100")
self.APCDriver:SetSaveValue("driverminspeed", "0.2")
self.APCDriver:SetSaveValue("drivermaxspeed", "1")
self.APCDriver:Fire("StartForward")
[/code]
...And nothing. Not even using an npc_vehicledriver helps.
[editline]14th December 2012[/editline]
[code]
self.APC:SetSaveValue("m_nSpeed ", "1000")
self.APC:SetSaveValue("m_flHandbrakeTime", "0")
self.APCDriver:SetSaveValue("m_flMaxSpeed", "1000")
self.APCDriver:SetSaveValue("m_flGroundSpeed", "1000")
[/code]
[editline]14th December 2012[/editline]
I'm going to bed fdsdf head pain
I'm having problems with the notify function
[code] [ERROR] gamemodes/darkrp/gamemode/init.lua:280: attempt to call global 'Notify' (a nil value)
1. callback - gamemodes/darkrp/gamemode/init.lua:280
2. RP_PlayerChat - gamemodes/darkrp/gamemode/server/chat.lua:20
3. unknown - gamemodes/darkrp/gamemode/server/chat.lua:63
[/code]
This is how the lua code looks.
[lua] Notify(attk, 5, 5, "You have completed the hit on " .. victim:Name() .. " and received $" .. LDRP_SH_Hitman.HitPrice) [/lua]
[QUOTE=quentuz;38828110]I'm having problems with the notify function
[code] [ERROR] gamemodes/darkrp/gamemode/init.lua:280: attempt to call global 'Notify' (a nil value)
1. callback - gamemodes/darkrp/gamemode/init.lua:280
2. RP_PlayerChat - gamemodes/darkrp/gamemode/server/chat.lua:20
3. unknown - gamemodes/darkrp/gamemode/server/chat.lua:63
[/code]
This is how the lua code looks.
[lua] Notify(attk, 5, 5, "You have completed the hit on " .. victim:Name() .. " and received $" .. LDRP_SH_Hitman.HitPrice) [/lua][/QUOTE]
My fault, try use GAMEMODE:Notify.
Thanks for the help :)
[QUOTE=quentuz;38828332]Thanks for the help :)[/QUOTE]
Np.
I'm trying to make players take damage when the vehicle they are in is shot however as far as I can tell the hook I am using in the code isn't being called when the vehicle is shot. Anyone have any ideas how I can fix this?
[lua]
function GM:EntityTakeDamage( ent, dmginfo )
if (ent:IsVehicle()) then
if ent:GetDriver():IsPlayer() then
ent:GetDriver():SetHealth( ent:GetDriver():Health() - dmginfo:GetDamage() )
if ( ent:GetDriver():Health() <= 0 ) then ent:GetDriver():Kill() end
end
end
self.BaseClass:EntityTakeDamage( ent, dmginfo )
end
[/lua]
[QUOTE=jellybaby34;38828532]I'm trying to make players take damage when the vehicle they are in is shot however as far as I can tell the hook I am using in the code isn't being called when the vehicle is shot. Anyone have any ideas how I can fix this?
[/QUOTE]
If you're trying this with a pod or a seat, I've tried this. And asked about it. AFAIK, it is impossible to do what you're trying to do with seats without a module. Someone told me the pod/seat are hardcoded to never allow the driver to take damage. If you figure out a way to do it please let me know.
[QUOTE=luavirusfree;38830155][ERROR] lua/weapons/mario_fireballs/shared.lua:82: bad argument #1 to '__add' (Vector expected, got number)
1. __add - [C]:-1
2. unknown - lua/weapons/mario_fireballs/shared.lua:82
Now.
[code] mPhys:SetVelocity((self.Owner:GetAngles():Forward().y + self.Owner:GetAngles():Forward().r + Vector(45, 0, 0)) * 256 * CurTime() * 1)[/code][/QUOTE]
That means it's returning a number not a vector.
How would I go about making a panel that gives you a quiz/test?
[QUOTE=J.R.;38830636]How would I go about making a panel that gives you a quiz/test?[/QUOTE]
DFrame Buttons RunConsoleCommand to send the answer and question
concommand.Add serverside to receive question and client awnsers
Can I get some help here? I'm working with SQL again to get myself back into it but I can't seem to edit tables, here's what I have.
[lua]
hook.Add("PlayerInitialSpawn","callSQL",function(player)
tmysql.query("SELECT * FROM players",function(r,s,e)
if r then
if r[1] then
local id = player:SteamID()
if table.HasValue(r[1],id) then
player:PrintMessage(HUD_PRINTTALK,"Welcome back, "..player:Name().."!")
else
tmysql.query("INSERT INTO players '"..id.."'",callback)
end
end
end
end)
end)
[/lua]
In the end I rejoin and it says that I've never joined before, and that the tables say I'm not in there either, but when I manually add my steamid it's fine.
After a large amount of fucking around and after reading the source code for the APC (npc_apcdriver.cpp and apc_vehicledriver.cpp) I've finally gotten it to work. Pootis.
[QUOTE=jrj996;38831530]Can I get some help here? I'm working with SQL again to get myself back into it but I can't seem to edit tables, here's what I have.
[lua]
hook.Add("PlayerInitialSpawn","callSQL",function(player)
tmysql.query("SELECT * FROM players",function(r,s,e)
if r then
if r[1] then
local id = player:SteamID()
if table.HasValue(r[1],id) then
player:PrintMessage(HUD_PRINTTALK,"Welcome back, "..player:Name().."!")
else
tmysql.query("INSERT INTO players '"..id.."'",callback)
end
end
end
end)
end)
[/lua]
In the end I rejoin and it says that I've never joined before, and that the tables say I'm not in there either, but when I manually add my steamid it's fine.[/QUOTE]
Post your table structure
[QUOTE=Trumple;38832934]Post your table structure[/QUOTE]
nevermind it was my problem, I guess my SQL tables or DB wasn't on.
But on a different note, how do I get a directory to go to my gamemode itself? I'm trying to create a /items/ folder and I don't know how to navigate to it.
[ERROR] lua/entities/mariofire/init.lua:115: attempt to call method 'Length' (a nil value)
1. unknown - lua/entities/mariofire/init.lua:115
[code]function ENT:PhysicsCollide( data, physobj )
-- Shoot some blood
-- local effectdata = EffectData()
-- effectdata:SetOrigin( self.Entity:GetPos() )
-- util.Effect( "BloodImpact", effectdata )
-- function ENT:PhysicsCollide( data, physobj )
if data.Speed <= 12 then
local LastSpeed = math.max( data.OurOldVelocity:Length(), data.Speed )
local NewVelocity = physobj:GetVelocity()
if self.bounces == 0 then
local NewVelocity = self.AngTr2
self.bounces = 1
LastSpeed = math.max( NewVelocity:Length(), LastSpeed )
else
local NewVelocity = self.AngTr
self.bounces = 0
LastSpeed = math.max( NewVelocity:Length(), LastSpeed )
end
if NewVelocity:IsValid() && LastSpeed:IsValid() then
LastSpeed = math.max( NewVelocity:Length(), LastSpeed )
end
local TargetVelocity = NewVelocity * 64
physobj:SetVelocity( Vector(0,0,0) )
physobj:SetVelocity( TargetVelocity )
-- local Pos1 = data.HitPos + data.HitNormal
-- local Pos2 = data.HitPos - data.HitNormal
-- util.Decal( "Blood", Pos1, Pos2 ) -- Scorch
-- Play sound on death
--[[ if (data.Speed > 80 && data.DeltaTime > 0.2 ) then
self.Entity:EmitSound( "Weapon_Crossbow.BoltHitBody" )
end]]
-- if data.Entity():IsPlayer() or data.Entity():IsNPC() then
-- SafeRemoveEntity( self.Entity )
end
end[/code]
It only gives that error if I shoot it a ton of times. Right now, however, it's not moving at all...
And for that matter, why doesn't it move anymore?? I don't want to paste that much code [URL="http://facepunch.com/showthread.php?t=1232897&p=38835268#post38835268"]here[/URL]...
Sorry, you need to Log In to post a reply to this thread.