• Problems That Don't Need Their Own Thread v2.0
    5,020 replies, posted
[QUOTE=Jvs;45804094]Remove the ent:SetOwner( ply ) part[/QUOTE] Bingo, why does that end up breaking it?
[QUOTE=Adzter;45804129]Bingo, why does that end up breaking it?[/QUOTE] Because the name is misleading, it makes the object not collide with that player at all, it's mainly used for stuff that the player throws ( such as rockets, grenades and etc ). It shouldn't be used for ownership that involves collisions , I guess I'll have to add a note to the wiki page.
[QUOTE=Leystryku;45801476]If it's a dedicated server, join the server and it should run.[/QUOTE] You could also add a bot OR If this is singleplayer, set the maxplayers to 2 or something higher than one before connecting so that you don't have to unpause the game for it to run
[QUOTE=sm69baller;45803074]Well that is a rather hacky way to do that , If i were you i would use the recommended sizes or powers by 2[/QUOTE] I've tried both to no avail. I am going off what the Wiki says is good now [editline]26th August 2014[/editline] [QUOTE=Loures;45802976]You can do what I did in my death badge, make the avatar 184x184 and then cut out the checkered part by parenting a 128x128 dummy panel to the AvatarImage.[/QUOTE] Alright I might try that, whats the panel called in your death badge?
[QUOTE=xaviergmail;45804232]You could also add a bot OR If this is singleplayer, set the maxplayers to 2 or something higher than one before connecting so that you don't have to unpause the game for it to run[/QUOTE] You can't do that iirc, because then it wont be single player but a listen server instead
Hi, example code from [url]http://wiki.garrysmod.com/page/VGUI/Elements/Button[/url] returns [ERROR] lua/button.lua:1: attempt to index global 'vgui' (a nil value) 1. unknown - lua/button.lua:1 I'm trying to learn to code, so probably i'm missing something obivious. But it gets harder when examples itself return an error.. EDIT: I'm stupid, that's clientside code...
[QUOTE=Stronglime;45804691]Hi, example code from [url]http://wiki.garrysmod.com/page/VGUI/Elements/Button[/url] returns [ERROR] lua/button.lua:1: attempt to index global 'vgui' (a nil value) 1. unknown - lua/button.lua:1 I'm trying to learn to code, so probably i'm missing something obivious. But it gets harder when examples itself return an error..[/QUOTE] Are you running the code on server or client?
[QUOTE=Stronglime;45804691]Hi, example code from [url]http://wiki.garrysmod.com/page/VGUI/Elements/Button[/url] returns [ERROR] lua/button.lua:1: attempt to index global 'vgui' (a nil value) 1. unknown - lua/button.lua:1 I'm trying to learn to code, so probably i'm missing something obivious. But it gets harder when examples itself return an error..[/QUOTE] Because you're running it on the server, which does not load the vgui library. Encase your code in "if CLIENT then" or ensure it is not shared automatically (all files in /autorun/ are shared unless in the /server/ or /client/ subdirectories) or include()ed by the server
Yeeah.. I've just realized that twenty seconds later. I feel ashamed.
surface.DrawPoly seems not to be working, no errors, nothing, just doesn't draw, my code: [lua] local hp = hHUD.CalculateHealthTables( 25, ScrH() - 100, 100, 20, 20, true, 1 ) // args: x, y, w, h, slope length, use borders, border length hook.Add( "HUDPaint", "HUD-Test", function() surface.SetDrawColor( 255, 0, 0, 255 ) draw.NoTexture() surface.DrawPoly( hp ) end ) [/lua] this is what printing hp gives me: [lua] 1: y = 980 x = 25 2: y = 980 x = 125 3: y = 960 x = 145 4: y = 960 x = 25 [/lua] [editline]hi there[/editline] The wiki's example seems to work fine though
Maybe you need examples: [lua] //Vertical draw poly local hX = 16 local hY = ScrH()-142 local a = math.Clamp((math.Clamp(LocalPlayer():Health(),0,100)/100)*1,0,1) surface.DrawPoly( { { x = hX+164, y = hY-44+(1-a)*104, u = 0, v = 1-a }, { x = hX+164+106, y = hY-44+(1-a)*104, u = 1, v = 1-a }, { x = hX+164+106, y = hY-44+104, u = 1, v = 1}, { x = hX+164, y = hY-44+104, u = 0, v = 1} }) //Horizontal drawpoly local a = math.Clamp(math.abs(math.Clamp(LocalPlayer():Health()/100,0,1))*1,0,1) surface.DrawPoly( { { x = hX+(1-a)*512, y = hY, u = (1-a), v = 0 }, { x = hX+512, y = hY, u = 1, v = 0 }, { x = hX+512, y = hY+128, u = 1, v = 1}, { x = hX+(1-a)*512, y = hY+128, u = (1-a), v = 1} }) [/lua]
Can you detect whether a player got killed by water / drowned?
[QUOTE=The Beta;45807251]Can you detect whether a player got killed by water / drowned?[/QUOTE] You can hook EntityTakeDamage and get damage type, if this was caused by the water, then our player "Can" die, if player dies near at that damage event, then he was killed by water
[QUOTE=gonzalolog;45807221]Maybe you need examples: [lua] //Vertical draw poly local hX = 16 local hY = ScrH()-142 local a = math.Clamp((math.Clamp(LocalPlayer():Health(),0,100)/100)*1,0,1) surface.DrawPoly( { { x = hX+164, y = hY-44+(1-a)*104, u = 0, v = 1-a }, { x = hX+164+106, y = hY-44+(1-a)*104, u = 1, v = 1-a }, { x = hX+164+106, y = hY-44+104, u = 1, v = 1}, { x = hX+164, y = hY-44+104, u = 0, v = 1} }) //Horizontal drawpoly local a = math.Clamp(math.abs(math.Clamp(LocalPlayer():Health()/100,0,1))*1,0,1) surface.DrawPoly( { { x = hX+(1-a)*512, y = hY, u = (1-a), v = 0 }, { x = hX+512, y = hY, u = 1, v = 0 }, { x = hX+512, y = hY+128, u = 1, v = 1}, { x = hX+(1-a)*512, y = hY+128, u = (1-a), v = 1} }) [/lua][/QUOTE] I don't really understand what you mean, that's pretty much what I'm doing: [lua] function hHUD.CalculateHealthTables( x, y, w, h, s, bd, b ) bd = bd || true b = b || 1 local dTable = { { x = x, y = y }, { x = x + w, y = y }, { x = x + w + s, y = y - h }, { x = x, y = y - h } } if !bd then return dTable end // return the table of coords if we're not drawing the border local dBorder = { { x = x, y = y }, { x = x + w + b, y = y }, { x = x + w + s + b, y = y - h }, { x = x, y = y - h } } return dTable, dBorder end [/lua] [QUOTE=The Beta;45807251]Can you detect whether a player got killed by water / drowned?[/QUOTE] EntityTakeDamage with DMG_DROWN as the damage type
I don't know how to make scripted NPC's, even with nextbot... I tried, but I want to learn how and this is just a fore-question; is it possible to use a hard coded NPC as a base, or mimic its behavior with just a few lines of code? I want to take the combine soldier's AI and apply it to my own, but script in a few exceptions, such as maybe making it use suit chargers, simulating suit armor, making it react to flash bangs, etc, etc, etc... So the general question would be, is there a way to make a SNPC pull behaviors from the hard-coded AI system?
I guess you should really go deeper in the nextbot thing instead of making SNPC even tho it isn't that easy you will find your way out ant it will be a better way then a hard coded AI system
[QUOTE=frietje2008;45817484]I guess you should really go deeper in the nextbot thing instead of making SNPC even tho it isn't that easy you will find your way out ant it will be a better way then a hard coded AI system[/QUOTE] That's an interesting idea, but I really want to imitate the behavior of the npc_combine_s entity as much as possible :downs: and I won't even be able to get close given my current mental capacity, which has dropped a LOT ever since I stopped smoking [IMG]http://facepunch.com/fp/forums/385.png?1[/IMG] (I'm being 100% serious there, I had a much sharper mind when I was high!) I speak so poorly of myself though, the fact being that I've tried to go the nextbot route before and when I finally got something that would spawn, I had no idea how to program the actual Artificial Intelligence.
Is there a hook/function I can use serverside to determine if a player has jumped? I was looking into PlayerBindPress, but: 1. Clientside (or seems to be) 2. Can hide whats being 'pressed' so to speak (eg: 'alias swag +jump' returns swag as the bind) I'll go browse the wiki for a bit, but if anyone could give me a solution to what seems to be trivial question, would be great. Cheers.
[QUOTE=PaellaPablo;45823825]Is there a hook/function I can use serverside to determine if a player has jumped? I was looking into PlayerBindPress, but: 1. Clientside (or seems to be) 2. Can hide whats being 'pressed' so to speak (eg: 'alias swag +jump' returns swag as the bind) I'll go browse the wiki for a bit, but if anyone could give me a solution to what seems to be trivial question, would be great. Cheers.[/QUOTE] [url=http://wiki.garrysmod.com/page/GM/FinishMove]FinishMove[/url], [url=http://wiki.garrysmod.com/page/CMoveData/KeyDown]CMoveData::KeyDown[/url], and [url=http://wiki.garrysmod.com/page/CMoveData/GetButtons]CMoveData::GetButtons[/url] are probably what you're looking for. [lua] local function IsPlayerABunny( pl, move ) --[[ Check if the player is holding down the jump key It will trigger regardless of binds/aliases ]] if move:KeyDown( IN_JUMP ) then -- do whatever end -- Alternatively, you can do this if bit.bor( move:GetButtons(), IN_JUMP ) ~= 0 then -- do whatever end end hook.Add( 'FinishMove', 'DetectBunnies', IsPlayerABunny ) [/lua]
[QUOTE=npypntz;45824239][url=http://wiki.garrysmod.com/page/GM/FinishMove]FinishMove[/url], [url=http://wiki.garrysmod.com/page/CMoveData/KeyDown]CMoveData::KeyDown[/url], and [url=http://wiki.garrysmod.com/page/CMoveData/GetButtons]CMoveData::GetButtons[/url] are probably what you're looking for. [lua] local function IsPlayerABunny( pl, move ) --[[ Check if the player is holding down the jump key It will trigger regardless of binds/aliases ]] if move:KeyDown( IN_JUMP ) then -- do whatever end -- Alternatively, you can do this if bit.bor( move:GetButtons(), IN_JUMP ) ~= 0 then -- do whatever end end hook.Add( 'FinishMove', 'DetectBunnies', IsPlayerABunny ) [/lua][/QUOTE]Doing it like that is not necessary, it would be much easier to do something like this: [CODE] local PLAYER = FindMetaTable( "Player" ) --[[--------------------------------------------------------- Determines if a player is jumping -----------------------------------------------------------]] function PLAYER:IsJumping( ) return self:GetTable().m_bJumping end [/CODE]
I have a strange problem, when I try to use the rope tool on this SEnt (actually I was using the lua function, but the rope tool does the same thing) the rope doesn't follow the entity visually after it moves, but the constraint is definately working... This is the entity code: [lua]AddCSLuaFile() ENT.Base = "base_entity" ENT.Type = "anim" ENT.RenderGroup = RENDERGROUP_OPAQUE function ENT:Initialize() self:SetModel("models/player/items/humans/top_hat.mdl") self:PhysicsInit(SOLID_VPHYSICS) self:SetSolid(SOLID_VPHYSICS) self:SetMoveType(MOVETYPE_VPHYSICS) end[/lua] I feel like I've forgotten something :S EDIT: No idea what the difference is, setting the physics on the server, but apparently this works: [lua]AddCSLuaFile() ENT.Base = "base_gmodentity" ENT.RenderGroup = RENDERGROUP_OPAQUE function ENT:Initialize() self:SetModel("models/player/items/humans/top_hat.mdl") if SERVER then self:PhysicsInit( SOLID_VPHYSICS ) self:SetMoveType( MOVETYPE_VPHYSICS ) self:SetSolid( SOLID_VPHYSICS ) end end[/lua]
I have a strange problem with my server-side script that uses the ScalePlayerDamage hook . It's located in autorun/server and basically it only works if the host re-saves the script while the server is running. [editline]28th August 2014[/editline] Is it because it is being overwritten by another hook of the same type?
Probably a dumb question, but does SetNWString and GetNWString work on bots?
I'm not sure but SetNWString and GetNWString work on all entities so since a bot is an entity it should need to work normally not tested but you shouldn't have any problems with it
Can't really test atm, but with what I had before, GetNWString seemed to work on my player entity but didn't return on bot's entity. Does player.GetAll return bots as well?
[QUOTE=HumbleTH;45829061]Can't really test atm, but with what I had before, GetNWString seemed to work on my player entity but didn't return on bot's entity. Does player.GetAll return bots as well?[/QUOTE] You need GetBots for that. [url]http://wiki.garrysmod.com/page/player/GetBots[/url]
[QUOTE=HumbleTH;45829061]Does player.GetAll return bots as well?[/QUOTE] Yes, it does. [CODE]> PrintTable( player.GetAll() )... 1 = Player [1][Bot01] [/CODE] I've used Set/GetNW* on bots before without any problem either.
[IMG]http://puu.sh/bbrVZ/fd35daf858.jpg[/IMG] Is this a good buy? I've recently purchased this to accompany the PIL
How do i get player animations to work? Whenever I use these functions: [code] Entity:ResetSequence( number seq ) Entity:SetSequence( number sequenceId ) [/code] They do not do anything and I checked to make sure they were valid animations here: [url]http://wiki.garrysmod.com/page/Enums/ACT[/url]
[QUOTE=bran92don;45831892]How do i get player animations to work? Whenever I use these functions: [code] Entity:ResetSequence( number seq ) Entity:SetSequence( number sequenceId ) [/code] They do not do anything and I checked to make sure they were valid animations here: [url]http://wiki.garrysmod.com/page/Enums/ACT[/url][/QUOTE]What animations are you trying to use?
Sorry, you need to Log In to post a reply to this thread.