[QUOTE=WalkingZombie;46294936]Is there an easy way to tell if a user has been poisoned (like by poison headcrabs, the antlion queen, antlion workers, or a swep) ?
[editline]21st October 2014[/editline]
without checking if they player was attacked by them during a function called when they get hurt.[/QUOTE]
Funnily enough, in the engine there is a function CBasePlayer::IsPoisoned:
[code] bool IsPoisoned( void ) { return m_Local.m_bPoisoned; }[/code]
So in theory you can probably do this on the server:
[code]person:GetSaveTable( ).m_bPoisoned[/code]
But you'd have to network it to the client yourself if this is true.
[QUOTE=Exho;46296480]Okay well how would I go abouy using a PHP function I made in Lua?[/QUOTE]
Install PHP on your gameserver and get it to execute your file :v:
[QUOTE=Kogitsune;46297014]Funnily enough, in the engine there is a function CBasePlayer::IsPoisoned:
[code] bool IsPoisoned( void ) { return m_Local.m_bPoisoned; }[/code]
So in theory you can probably do this on the server:
[code]person:GetSaveTable( ).m_bPoisoned[/code]
But you'd have to network it to the client yourself if this is true.[/QUOTE]
I couldn't see m_bPoisoned in the table but [I]m_nPoisonDmg[/I] is > 0 while you are poisoned. And yep, serverside only.
I was looking at this [url]https://github.com/ValveSoftware/source-sdk-2013/blob/master/mp/src/game/server/player.cpp[/url] to work it out.
[QUOTE=wh1t3rabbit;46298348][QUOTE=Kogitsune;46297014][QUOTE=WalkingZombie;46295151]That is an option I guess. I meant something more like the player:Alive() thing, player:Poisoned(). I could try out what you just said, but is there a shorthand function like that? Like plr:Poisoned() ??
[editline]21st October 2014[/editline]
or perhaps in the manner of IsPoisoned( plr )[/QUOTE]
Funnily enough, in the engine there is a function CBasePlayer::IsPoisoned:
[code] bool IsPoisoned( void ) { return m_Local.m_bPoisoned; }[/code]
So in theory you can probably do this on the server:
[code]person:GetSaveTable( ).m_bPoisoned[/code]
But you'd have to network it to the client yourself if this is true.[/QUOTE]
I couldn't see m_bPoisoned in the table but [I]m_nPoisonDmg[/I] is > 0 while you are poisoned. And yep, serverside only.
I was looking at this [url]https://github.com/ValveSoftware/source-sdk-2013/blob/master/mp/src/game/server/player.cpp[/url] to work it out.[/QUOTE]
I suppose I can do this if I add in a server side script, and a way to, of course, transmit it from server to client, for the sake of why I need to know this.
[QUOTE=WalkingZombie;46298973]I suppose I can do this if I add in a server side script, and a way to, of course, transmit it from server to client, for the sake of why I need to know this.[/QUOTE]
The client knows SOMEHOW because the little "Administering Antidote" thing shows up on the client...
[QUOTE=OzymandiasJ;46299069]The client knows SOMEHOW because the little "Administering Antidote" thing shows up on the client...[/QUOTE]
Thats because it's done in C, and they have access to the IsPoisoned function
What you could try doing is checking if the element CHudPoisonDamageIndicator shows up during the HUDShouldDraw hook (since it should only be passed to lua if it passes the C hud element call?)
So something like
[LUA]
local last_poison = CurTime() - 1
local function IsPoisoned()
return CurTime() - last_poison > .01 -- Maybe use FrameTime() or something
end
hook.Add( "HUDShouldDraw", "monitor_poison", function( elem )
if elem == "CHudPoisonDamageIndicator" then last_poisoned = CurTime() end
end )
[/LUA]
play around with something like that maybe?
(Of course an actual binding would be better. Im sure Vinh'll fix it)
Are networked variables (such as NWInt, NWString, etc) saved between map changes/server restarts or should I use them in conjunction with PData?
[QUOTE=Sereni;46301047]Are networked variables (such as NWInt, NWString, etc) saved between map changes/server restarts or should I use them in conjunction with PData?[/QUOTE]No, they are not saved between map changes/server restarts. If you want them to, you'll need to use them with some form of saving method such as what you suggested.
- solved
Take a look at [url=http://wiki.garrysmod.com/page/Global/Matrix]Matrix[/url], [url=http://wiki.garrysmod.com/page/VMatrix/ScaleTranslation]Matrix:ScaleTranslation[/url] and the examples on [url=http://wiki.garrysmod.com/page/cam/PushModelMatrix]cam.PushModelMatrix[/url].
If I understand ScaleTranslation correctly, you can multiply the size using a scalar, this example *should* double the size of what you draw. Remember to use a decently large font size so the text looks nice
[lua]hook.Add( "HUDPaint", "MyHUD", function()
local mat = Matrix()
mat:Translate( Vector( pos_x, pos_y ) )
mat:ScaleTranslation( 2 )
render.PushFilterMag( TEXFILTER.ANISOTROPIC ) -- AA stuff
render.PushFilterMin( TEXFILTER.ANISOTROPIC )
cam.PushModelMatrix( mat )
-- Draw your stuff
cam.PopModelMatrix()
render.PopFilterMag() -- Stop AA stuff
render.PopFilterMin()
end )[/lua]
Thanks ;)
[QUOTE=rejax;46300273]Thats because it's done in C, and they have access to the IsPoisoned function
What you could try doing is checking if the element CHudPoisonDamageIndicator shows up during the HUDShouldDraw hook (since it should only be passed to lua if it passes the C hud element call?)
So something like
[LUA]
local last_poison = CurTime() - 1
local function IsPoisoned()
return CurTime() - last_poison > .01 -- Maybe use FrameTime() or something
end
hook.Add( "HUDShouldDraw", "monitor_poison", function( elem )
if elem == "CHudPoisonDamageIndicator" then last_poisoned = CurTime() end
end )
[/LUA]
play around with something like that maybe?
(Of course an actual binding would be better. Im sure Vinh'll fix it)[/QUOTE]
Hmm? But consider the indicator as disabled?
just started coding, i made a helloworld program and saved it my lua folder in gmod and when i try to run it with lua_openscript helloworld.lua it says "Couldn't include file "helloworld.lua"(File not found) (<nowhere>)" I'm probably doing something silly but help would be nice
[QUOTE=GmanMan;46306807]just started coding, i made a helloworld program and saved it my lua folder in gmod and when i try to run it with lua_openscript helloworld.lua it says "Couldn't include file "helloworld.lua"(File not found) (<nowhere>)" I'm probably doing something silly but help would be nice[/QUOTE]
Make sure it's the exact file name and include and sub folders
[QUOTE=GmanMan;46306807]just started coding, i made a helloworld program and saved it my lua folder in gmod and when i try to run it with lua_openscript helloworld.lua it says "Couldn't include file "helloworld.lua"(File not found) (<nowhere>)" I'm probably doing something silly but help would be nice[/QUOTE]
What is the folder path of your helloworld.lua file?
[QUOTE=Exho;46307358]What is the folder path of your helloworld.lua file?[/QUOTE]
gmod/gmod/lua as per this tutorial [url]http://wiki.garrysmod.com/page/Beginner_Tutorial_Intro[/url]
also im running linux if that means anything
[QUOTE=GmanMan;46307375]gmod/gmod/lua as per this tutorial [url]http://wiki.garrysmod.com/page/Beginner_Tutorial_Intro[/url]
also im running linux if that means anything[/QUOTE]
Linux likes lowercase file names in my experience (I used Ubuntu for a while) also if it is a client side script and not serverside run it with lua_openscript_cl helloworld.lua
[editline]23rd October 2014[/editline]
Is their a (isNumeric) hook for gmod? I need to check if text entered into a text entry box contains any numbers.
[QUOTE=BlackMadd;46309232]Linux likes lowercase file names in my experience (I used Ubuntu for a while) also if it is a client side script and not serverside run it with lua_openscript_cl helloworld.lua
[editline]23rd October 2014[/editline]
Is their a (isNumeric) hook for gmod? I need to check if text entered into a text entry box contains any numbers.[/QUOTE]
Yes, there is an "IsNumeric" function in Lua and you can test for the number-datatype via type( ) function or isnumber function: type( x ) == "number" or isnumber( x )
How do I render spawnicon with different way?
Can I save PNG into the data folder like spawnicon does?
[QUOTE=Acecool;46309263]Yes, there is an "IsNumeric" function in Lua and you can test for the number-datatype via type( ) function or isnumber function: type( x ) == "number" or isnumber( x )[/QUOTE]
Solved, I used [code]if n:match("%d") then[/code]
EDIT:
Even better I changed to [code]if !n:match("%a") then[/code]
So now i got totally confused tbh.
I try to work with Keyvalue for the first time. To look into the Keyvalues to get a bit of an overview i tried following:
[lua]AddCSLuaFile()
DEFINE_BASECLASS( "base_anim" )
ENT.PrintName = "Bouncy Ball"
ENT.Author = "Garry Newman"
ENT.Information = "An edible bouncy ball"
ENT.Category = "Fun + Games"
ENT.Editable = true
ENT.Spawnable = true
ENT.AdminOnly = false
ENT.RenderGroup = RENDERGROUP_TRANSLUCENT
ENT.tf = {}
function ENT:KeyValue(key, value)
table.insert(self.tf, key .. " " .. value)
end
[/lua] (yes i used the ball as a base, since it is just an dummy ent)
So. Now i got the problem. i spawned 2 Entities with different Keyvalues and try to print the tf table with [lua]for k,v in pairs(ents.FindByClass("item_teamflag")) do PrintTable(v.tf) end[/lua]
[URL="http://pastebin.com/yRxC0LdJ"]Output[/URL]
But idk why for sure, but the table contains the keyvalues of both entities, not just one.
How could i disable this?
Try doing this
[code]
--ENT.tf = {} -- Get rid of this.
function ENT:KeyValue(key, value)
if(!self.tf) then self.tf = {} end
table.insert(self.tf, key .. " " .. value)
end[/code]
[QUOTE=rebel1324;46309408]How do I render spawnicon with different way?
Can I save PNG into the data folder like spawnicon does?[/QUOTE]
Hacky way to load PNG files with the txt extension from data
[code]
function MaterialData(mat, param)
local ret = Material("../data/" .. mat .. "\n.png", param)
LocalPlayer():ConCommand("mat_reloadmaterial ../data/" .. mat .. "*") -- This is optional for if you want materials to reload on each MaterialData call
return ret
end
-- write to my_file.txt lalala
local mat = MaterialData("my_file.txt")
-- draw mat
[/code]
Okay so I found out what I was doing wrong. LUA does NOT like spaces in its file names. After i removed the space after "helloworld " it worked. I was doing something silly >.<
not sure if it's right for this thread but Im sure people have to deal with this all the time
how do you change the icon of your steam workshop file when you have already submitted it?
[QUOTE=ROFLBURGER;46312746]not sure if it's right for this thread but Im sure people have to deal with this all the time
how do you change the icon of your steam workshop file when you have already submitted it?[/QUOTE]
Some people claim to have done this with the old workshopper tool, but I never could so I've just been hooking up quick applications that use the Steam API whenever I need to do this. Add me if you can't find a way and I can do the same for you.
No gifs though, I'm not allowed :v:
[QUOTE=ROFLBURGER;46312746]not sure if it's right for this thread but Im sure people have to deal with this all the time
how do you change the icon of your steam workshop file when you have already submitted it?[/QUOTE]
You can do it with the Dev branch version of gmpublish.exe
[QUOTE=Robotboy655;46312860]You can do it with the Dev branch version of gmpublish.exe[/QUOTE]
Where can I find this dev branch of gmpublish if it is accessible to me?
[editline]23rd October 2014[/editline]
And is it command line prompt? I'm going to have to borrow the format for that if there is documentation I can find.
I'm trying to find a way to get the exact / relative position of bones.. Basically, instead of using pose-parameters and animation / sequences to make my client-side legs system work, I'd like to copy the bone positions straight over. The issue is, because it is a clientsidemodel, I can't use physics bones which allow for EASY copying / transferring from source to target.
I'm using
[code]function META_PLAYER:CopyBonesTo( _target )
// Player Pos and angles
local _ppos = self:GetPos( );
local _pang = self:GetAngles( );
// Target RenderPos and RenderAngles ( using ClientsideModel which gets rendered many times )
local _rpos = _target:GetRenderOrigin( );
local _rang = _target:GetRenderAngles( );
// ClientsideModel safe functions
for i = 0, self:GetBoneCount( ) - 1 do
// Bone name, straight forward.. LookupBone returns i, but will return nil if invalid which is why it is being used
local _name = self:GetBoneName( i );
local _bone = self:LookupBone( _name );
if ( !_bone ) then continue; end
// These functions give world pos. Even if I use self:WorldToLocal, it doesn't give me the relative bone position; I need the exact bone position relative to ITS origin AND the exact bone angles relative to ITS origin in order to copy it properly
local _pos, _ang = self:GetBonePosition( _bone );
local _tpos, _tang = _target:GetBonePosition( _bone );
// Reset the bones - This should be where I modify...
_target:ManipulateBonePosition( _bone, vector_origin );
_target:ManipulateBoneAngles( _bone, angle_zero );
end
end[/code]
It is probably something stupid-simple that I'm overlooking but I'd appreciate some guidance; it has been a long night unfortunately ( unable to do much )...
I know how to create my own functions and have started using them more frequently, but how would I basically 'use' the player in them?
Example:
[code]
function GM:CustomFunction(ply)
ply:ChatPrint("test")
end
[/code]
Sorry, you need to Log In to post a reply to this thread.