• Problems That Don't Need Their Own Thread v3.0
    5,003 replies, posted
[QUOTE=Sereni;48071046] -snip- [/QUOTE] I am getting this error now. [ERROR] gamemodes/deathrun/gamemode/init.lua:611: attempt to call method 'RoundThink' (a nil value) 1. unknown - gamemodes/deathrun/gamemode/init.lua:611 which points to: [lua] function GM:Think() self.BaseClass:Think() self:RoundThink() self:ConVarThink() end [/lua] What I am trying to accomplish is if there is one person on the server, they can run around as a RUNNER and play deathrun by themself. What it does (if I set it to allow it to start with one player) is spawns them as DEATH and respawns them repeatedly without starting the round.
[QUOTE=MatureGamersNetwork;48071825]I am getting this error now. [ERROR] gamemodes/deathrun/gamemode/init.lua:611: attempt to call method 'RoundThink' (a nil value) 1. unknown - gamemodes/deathrun/gamemode/init.lua:611 which points to: [lua] function GM:Think() self.BaseClass:Think() self:RoundThink() self:ConVarThink() end [/lua] What I am trying to accomplish is if there is one person on the server, they can run around as a RUNNER and play deathrun by themself. What it does (if I set it to allow it to start with one player) is spawns them as DEATH and respawns them repeatedly without starting the round.[/QUOTE] It's saying that RoundThink isn't a valid function. Does it exist?
Yes it is at the very bottom (in the code) of my original post. [lua] function GM:RoundThink() local cur = self:GetRound() if cur != ROUND_WAITING then if #player.GetAll() < 2 then self:SetRound(ROUND_WAITING) return end end if self.ThinkRoundFunctions[cur] then self.ThinkRoundFunctions[cur]( self ) end end [/lua]
Is there a way to get a player on the client? Like, if I have a script running clientside, is there a way to get the clients SteamID64?
[QUOTE=B10H4Z4RD;48073540]Is there a way to get a player on the client? Like, if I have a script running clientside, is there a way to get the clients SteamID64?[/QUOTE] All the player objects still exist clientside. You'd get them the same way as you would on server. I am not sure if SteamID64 will work, but it should work.
Anyone know how to make a nextbot be effected by things like an NPC? For example when you shoot with some weapons it goes right through them.
[CODE]function AddStencils() local entlist = ents.FindByClass("ammo_resupply_station") render.ClearStencil() render.SetStencilEnable( true ) render.SetStencilWriteMask( 255 ) render.SetStencilTestMask( 255 ) render.SetStencilReferenceValue( 10 ) render.SetStencilPassOperation( STENCILOPERATION_REPLACE ) render.SetStencilFailOperation( STENCILOPERATION_KEEP ) render.SetStencilZFailOperation( STENCILOPERATION_KEEP ) render.SetStencilCompareFunction( STENCILCOMPARISONFUNCTION_ALWAYS ) for k,v in pairs(entlist) do v:DrawMask() -- Creates a quad mesh at each corner to create the mask end render.SetStencilCompareFunction( STENCILCOMPARISONFUNCTION_EQUAL ) render.ClearBuffersObeyStencil( 0, 0, 0, 0, true ) for k,v in pairs(entlist) do v:DrawInterior() --Draws the inside of the model end render.SetStencilEnable( false ) for k,v in pairs(entlist) do v:DrawExterior() -- Draws stuff outside the model end end hook.Add("PostDrawOpaqueRenderables","DrawResupplyStencils",AddStencils)[/CODE] I'm working on a simple ammo spawner that uses stencils for its model, but I have an issue whenever someone shoots at the actual model it causes this issue. I have it in a hook rather than the entity because halos cause an issue where it will fill the screen with its color when a player interacts with it. [IMG]http://i.imgur.com/g5nbhAt.jpg[/IMG]
[QUOTE=Avil;48073638]Anyone know how to make a nextbot be effected by things like an NPC? For example when you shoot with some weapons it goes right through them.[/QUOTE] Sounds like a problem with said weapons.
[QUOTE=Robotboy655;48073711]Sounds like a problem with said weapons.[/QUOTE] Well it was until I changed it collision group, but not they're not taking damage. Not sure why. [editline]28th June 2015[/editline] I'm using HL2 Weapons. [editline]28th June 2015[/editline] Nevermind, I've fixed my code. I am using a thunder gun and want to make it throw around my nextbots. Meaning when I shoot them with it they die into a ragdoll and get throw backwards.
How would I go about checking if an entity (a player, in this case) is visible from another player's field of view? (Not just their center of view, mind you)
[QUOTE=zeaga;48076537]How would I go about checking if an entity (a player, in this case) is visible from another player's field of view? (Not just their center of view, mind you)[/QUOTE] [code] can_see = otherguy:GetAimVector( ):Dot( otherguy:EyePos( ) - thisguy:NearestPoint( otherguy:EyePos( ) ) ) <= math.rad( otherguy:GetFOV( ) / 2 ) [/code] Something like that. You'll need to account for a maximum distance as well - it is more or less the logic for FindInCone. Keep in mind this is a pure math test - it doesn't care about things being in the way like solid walls, props, or other players. I use this as part of a check for a hide and seek script to loop the heartbeat sound when the player is being looked at by a seeker if they are a hider.
[QUOTE=Kogitsune;48076630][code] can_see = otherguy:GetAimVector( ):Dot( otherguy:EyePos( ) - thisguy:NearestPoint( otherguy:EyePos( ) ) ) <= math.rad( otherguy:GetFOV( ) / 2 ) [/code] Something like that. You'll need to account for a maximum distance as well - it is more or less the logic for FindInCone. Keep in mind this is a pure math test - it doesn't care about things being in the way like solid walls, props, or other players. I use this as part of a check for a hide and seek script to loop the heartbeat sound when the player is being looked at by a seeker if they are a hider.[/QUOTE] I figured something out like this a little before you posted, but didn't know how to go about doing it. This is exactly what I needed. I think I can handle the missing parts on my own. Thanks so much! [editline]28th June 2015[/editline] Actually, FindInCone should work fine, and I decided I don't want to use their entire FOV. I can't figure out how height and angle work, though? I am not a clever man.
(this isn't Lua) Having trouble making a binary module for running unrestricted concommands serverside. I've got everything else working fine, but when it comes to getting the engine interface, it fails. No error message. I'm using the GM13 headers & the latest Source SDK headers & testing the module on a local dedicated server. GMOD_MODULE_OPEN: [code] GMOD_MODULE_OPEN() { CreateInterfaceFn interfaceFactory = Sys_GetFactory("engine.dll"); server = (IVEngineServer*)interfaceFactory(INTERFACEVERSION_VENGINESERVER, NULL); if (!server) { Msg("Failed to get engine interface (" INTERFACEVERSION_VENGINESERVER ")\n"); } LUA->PushSpecial(SPECIAL_GLOB); LUA->CreateTable(); // Command LUA->PushCFunction(ExecuteCommand); LUA->SetField(-2, "Command"); LUA->SetField(-2, "server"); LUA->Pop(); return 0; } [/code] Includes & stuff: [code] #undef _UNICODE #define WIN32_LEAN_AND_MEAN #define GMMODULE #pragma comment(linker, "/NODEFAULTLIB:libcmt") #pragma comment(lib, "E:/SourceSDK Headers/mp/lib/public/tier0.lib") #pragma comment(lib, "E:/SourceSDK Headers/mp/lib/public/tier1.lib") #include "GarrysMod\Lua\Interface.h" #include "eiface.h" IVEngineServer* server = NULL; using namespace GarrysMod::Lua; [/code]
So it's a long time since I really used Lua so I can't remember how table exactly works as I've gotten used to C# Lists and arrays. Is this how I am supposed to do stuff or is there a better way [lua] hook.Add("PlayerInitialSpawn", "fgtSpawns", function( ply ) ply.achievements = {}; for _,v in pairs ( achievementTable ) do ply.achievement[ v.id ].unlocked = 0; end PrintTable(ply.achievement); ply.achievement["50kills"].unlocked = 1; print(ply.achievement["50kills"].unlocked); end) [/lua] EDIT: top page with a idiotic question. gg man
you would have to do either [lua]ply.achievement[v.id] = {unlocked = 0}[/lua] or [lua]ply.achievement[v.id] = 0[/lua], right now your code is trying to index a nil value [editline]29th June 2015[/editline] also, if you're using 1/0 as booleans, you should use true/false, it'll save you a headache because 0 is true in lua
Do Lua Effects use up a lot of Edicts? Basically, is each individual particle counted or something?
If I'm using ents.Create is there any way I can apply things to the ent created? I want to freeze it and maybe add an effect to it?
[QUOTE=FreddiRox!;48081635]If I'm using ents.Create is there any way I can apply things to the ent created? I want to freeze it and maybe add an effect to it?[/QUOTE] I'm not sure if these things need to be done before spawn or after, but this will help you out: [code]local NewEnt = ents.Create NewEnt:SetKeyValue( "health", "9001" ) NewEnt:AddFlags( number flag ) NewEnt:GetPhysicsObject():EnableMotion( false ) -- This SHOULD disable motion for your entity. Set to true to enable motion.[/code] Just some examples.
So right now I have a panel that plays music when open and should fade the music when the panel is removed. I am creating the sound clientside via [code]music = CreateSound( LocalPlayer(), "soundpath" )[/code] Yes, I want it to stay global. Problem is, FadeOut is not working on the sound. I can't even stop the sound. Using lua_run_cl and executing the same code will work, but for whatever reason, this code will not work on a panel. [code] function PANEL:FadeMusic() if (!music) then return end music:FadeOut(5) end function PANEL:OnRemove() self:FadeMusic() music = nil --to remove the sound because why not. I have tried removing this, it changes nothing. end [/code] It successfully sets music to nil, but it doesn't fade my music. If I don't set it to nil and use lua_run_cl to stop the soundpatch, it still doesn't respond.
Anyone know how I can make a serverside command to give ammo? I don't know how to get the specific person who used the command.
[QUOTE=Avil;48082092]Anyone know how I can make a serverside command to give ammo? I don't know how to get the specific person who used the command.[/QUOTE] There is already a command serverside to give ammo- Oh wait, do you mean a console command? Can you explain a bit more clearly?
[QUOTE=A Fghtr Pilot;48082484]There is already a command serverside to give ammo- Oh wait, do you mean a console command? Can you explain a bit more clearly?[/QUOTE] Not for you.
[QUOTE=Avil;48082505]Not for you.[/QUOTE] What? I'm trying to help, dude
[QUOTE=A Fghtr Pilot;48082548]What? I'm trying to help, dude[/QUOTE] Oh, I thought you tried to be cheeky. Sorry. Anyways I meant I want to make a console command that gives the person who used it ammo.
Have you looked at [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/concommand/Add]concommand.Add[/url]? Because that's what you need to use.
Yes, heres what I have now. Clientside: [CODE] LocalPlayer():ConCommand("_buyammo") [/CODE] Serverside [CODE] concommand.Add("_buyammo",function(ply,cmd,args) ply:GiveAmmo("bowie_knife") ply:SetPoints(ply:GetPoints() - 500) end) [/CODE]
[QUOTE=Avil;48082702]Yes, heres what I have now. Clientside: [CODE] LocalPlayer():ConCommand("_buyammo") [/CODE] Serverside [CODE] concommand.Add("_buyammo",function(ply,cmd,args) ply:GiveAmmo("bowie_knife") ply:SetPoints(ply:GetPoints() - 500) end) [/CODE][/QUOTE] You are using GiveAmmo incorrectly. The syntax is [code]Player:GiveAmmo( number amount, string type, boolean hidePopup )[/code] So you should be doing [code]ply:GiveAmmo( 1, "bowie_knife", false ) -- or set the last one to true if you don't want them to know they got ammo[/code]
Sorry, I was editing it thats not ammo but rather a weapon but what you said is what I was doing.
So then you are doing [code]ply:Give( "bowie_knife" )[/code] and nothing happens? Does the part where you are subtracting points work? If so, try creating this in a shared document where both server and client can see it and change the format of your command to [code] concommand.Add("_buyammo",function(ply,cmd,args) if SERVER then ply:Give( "bowie_knife" ) ply:SetPoints(ply:GetPoints() - 500) end end)[/code] Maybe that would work, as the client might not be registering it's a command?
Here is what I am doing, ignore what I said before. [CODE] concommand.Add("_buyammo",function(ply) ply:GiveAmmo(120, ply:GetPrimaryAmmoType(),true) ply:SetPoints(ply:GetPoints() - 500) end) [/CODE] [editline]29th June 2015[/editline] What you said works great thank you~!
Sorry, you need to Log In to post a reply to this thread.