[QUOTE=Banhfunbags;39435006]Does anyone know what the math function is to find if a number is between two other numbers?
For Example, I want to check if 99939 is between 40 and 10,000[/QUOTE]
[lua]
function Between(num, low, high)
return low < num && num < high
end
[/lua]
[img]http://gyazo.com/86f8321cbd5e44d9f87ca7da8e22a436.png?1359711265[/img]
[QUOTE=James0roll;39431900]Thank you! I got it to work, now I can load a player's inventory via MySQL.[/QUOTE]
Why don't you save and load it as JSON?
hello i made a custom printer called wood_printer but where do i set how much its print ?
[ERROR] ...des/perp/entities/entities/ent_light_manager/cl_init.lua:54: attempt to compare number with nil
1. DrawTranslucent - ...des/perp/entities/entities/ent_light_manager/cl_init.lua:54
2. unknown - ...des/perp/entities/entities/ent_light_manager/cl_init.lua:15
EDIT: Fixed.
post the damned code.
[QUOTE=Matt-;39440436]post the damned code.[/QUOTE]
Yeh... I Kinda fixed it a second ago
[QUOTE=EthanTheGreat;39433176]Then, replace line 5 with:
[code]if !Killer or !Killer:IsValid( ) then Killer = Pl end[/code][/QUOTE]
I need help, now I've solved out what causes that glitch, when the player is killed by the world, it generates error and the living players can hear that player that was killed by the world
[ERROR] lua/autorun/server/ttt_death_notify.lua:9: attempt to call method 'IsTraitor' (a nil value)
1. v - lua/autorun/server/ttt_death_notify.lua:9
But if the player suicide trough command "kill" on console, it works. How do I fix it?
Here's my script:
[CODE]if ( SERVER ) thenresource.AddFile("lua/autorun/client/ttt_death_notify.lua")
resource.AddFile("lua/autorun/server/ttt_death_notify.lua")
AddCSLuaFile("autorun/client/ttt_death_notify.lua")
hook.Add( "PlayerDeath", "CHIIPPPSS" , function( Pl, Ent, Killer )
if !Killer or !Killer:IsValid( ) then Killer = Pl end
umsg.Start( "PlayerDeathCustom", Pl )
umsg.Entity( Killer )
umsg.Bool( Killer:IsTraitor() )
umsg.Bool( Killer:IsDetective() )
umsg.End()
end)
else
usermessage.Hook( "PlayerDeathCustom" , function( um )
local Killer = um:ReadEntity()
local IsT = um:ReadBool()
local IsD = um:ReadBool()
chat.AddText( Color( 255,255,255 ) , "You've been killed by ", Color( 175,175,175 ), Killer:Nick(),
Color( 255,255,255 ), ( ( IsT or IsD ) and ", a " or ", an " ), ( (IsT and Color( 255,99,99)) or (IsD and Color( 52,128, 209)) or Color(161,232,116) ),
( (IsT and "Traitor!") or (IsD and "Detective!") or "Innocent!" ) )
chat.PlaySound()
end)
[/CODE]
please... stop posting errors without the relevant code, we can't help you otherwise.
[editline]1st February 2013[/editline]
Replace
[lua]
if !Killer or !Killer:IsValid( ) then Killer = Pl end
umsg.Start( "PlayerDeathCustom", Pl )
umsg.Entity( Killer )
umsg.Bool( Killer:IsTraitor() )
umsg.Bool( Killer:IsDetective() )
umsg.End()
[/lua]
With
[lua]
if Pl and Pl:IsValid() and Killer and Killer:IsValid( ) then
umsg.Start( "PlayerDeathCustom", Pl )
umsg.Entity( Killer )
umsg.Bool( Killer:IsTraitor() )
umsg.Bool( Killer:IsDetective() )
umsg.End()
end
[/lua]
[QUOTE=Matt-;39440515]please... stop posting errors without the relevant code, we can't help you otherwise.
[editline]1st February 2013[/editline]
Replace
if !Killer or !Killer:IsValid( ) then Killer = Pl end umsg.Start( "PlayerDeathCustom", Pl ) umsg.Entity( Killer ) umsg.Bool( Killer:IsTraitor() ) umsg.Bool( Killer:IsDetective() ) umsg.End()
With
if Pl and Pl:IsValid() and Killer and Killer:IsValid( ) then umsg.Start( "PlayerDeathCustom", Pl ) umsg.Entity( Killer ) umsg.Bool( Killer:IsTraitor() ) umsg.Bool( Killer:IsDetective() ) umsg.End()end[/QUOTE]
Same errors
[ERROR] lua/autorun/server/ttt_death_notify.lua:9: attempt to call method 'IsTraitor' (a nil value)
1. v - lua/autorun/server/ttt_death_notify.lua:9
2. unknown - lua/includes/modules/hook.lua:82
ps: that only happens when the player get killed by world hurt.
oh right, try this out, forgot to check if it's a player:
[lua]
if Pl and Pl:IsValid() and pl:IsPlayer() and Killer and Killer:IsValid( ) and Killer:IsPlayer() then
[/lua]
[QUOTE=Matt-;39440773]oh right, try this out, forgot to check if it's a player:
[lua]
if Pl and Pl:IsValid() and pl:IsPlayer() and Killer and Killer:IsValid( ) and Killer:IsPlayer() then
[/lua][/QUOTE]
[ERROR] lua/autorun/server/ttt_death_notify.lua:6: attempt to index global 'pl' (a nil value)
Oh jeez, just change it to Pl.
[QUOTE=Matt-;39440870]Oh jeez, just change it to Pl.[/QUOTE]
lol.. yay, it worked! thanks
[QUOTE=thejjokerr;39435133]Use the larger and less than operators: > and <
There aint no function for it afaik because it's too damn easy.[/QUOTE]
I for some reason did not think about that. I thought there was a function that would make it much easier. Thanks!
[lua]
1.6 - math.floor( 1.6 )
[/lua]
Will return 0.6, just a sexy fun tip for you sexy noob coders out there to return the decimal of a number.
Sorry to ask in here but does anyone know of a working basic server "TimeSpent" scripts kicking around? I've been looking for one for a gaming event. It somewhat needs to work with TTT and Fretta but preferably TTT.
How do I make a player take damage from being underwater too long?(Having no oxygen)
[QUOTE=Banhfunbags;39445395]How do I make a player take damage from being underwater too long?(Having no oxygen)[/QUOTE]
[url]http://wiki.garrysmod.com/page/Classes/Entity/WaterLevel[/url]
To see if the player is under water
[url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexba9a.html[/url]
To force the player to take damage, I'd use 'DMG_DROWN' for Entity:SetDamageType( )
[QUOTE=EthanTheGreat;39445430][url]http://wiki.garrysmod.com/page/Classes/Entity/WaterLevel[/url]
To see if the player is under water
[url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexba9a.html[/url]
To force the player to take damage, I'd use 'DMG_DROWN' for Entity:SetDamageType( )[/QUOTE]
Alright thanks!
Is there a way to draw a player's avatar in a 3D2D environment?
(or at least get the avatar image)
[QUOTE=xaviergmail;39446303]Is there a way to draw a player's avatar in a 3D2D environment?[/QUOTE]
Create an "AvatarImage" VGUI element and use the function PANEL:PaintManual() in a 3D2D environment.
[QUOTE=Matt-;39446324]Create an "AvatarImage" VGUI element and use the function PANEL:PaintManual() in a 3D2D environment.[/QUOTE]
Thanks, but is there any other way of doing this? This isn't very convenient...
Garry, please add something that lets us get players' avatars ? :rolleye:
[QUOTE=xaviergmail;39446405]Thanks, but is there any other way of doing this?[/QUOTE]
No, do it the way I just said; what's wrong with it?
[QUOTE=Matt-;39446412]No, do it the way I just said; what's wrong with it?[/QUOTE]
I don't want the avatar as a VGUI element because then it gets rendered twice and I have to deal with a stupid VGUI element. Is there a that I can make it paint only when I do it manually?
[QUOTE=xaviergmail;39446436]I don't want the avatar as a VGUI element because then it gets rendered twice and I have to deal with a stupid VGUI element. Is there a that I can make it paint only when I do it manually?[/QUOTE]
PANEL:SetPaintedManually(true)
[QUOTE=Matt-;39446445]PANEL:SetPaintedManually(true)[/QUOTE]
Oh fiddlesticks, I should have checked the wiki before asking that. Thanks for the help!
[QUOTE=The-Spy;39445077]Sorry to ask in here but does anyone know of a working basic server "TimeSpent" scripts kicking around? I've been looking for one for a gaming event. It somewhat needs to work with TTT and Fretta but preferably TTT.[/QUOTE]
If you're referring to something that it's commonly known as an "Anti-AFK Kick Script" here:
[lua]
local KickLength = 600
local PlayerPositions = { }
timer.Create( "anti_afk_script", KickLength, 0, function( )
for _, ply in pairs( player.GetAll( )) do
if PlayerPositions[ply:UserID( )] and PlayerPositions[ply:UserID( )]:Distance( ply:GetPos( )) < 100 then
PlayerPositions[ply:UserID( )] = nil
ply:Kick( "You have been kicked for being afk for "..( KickLength / 60 ).." minute(s)." )
else
PlayerPositions[ply:UserID( )] = ply:GetPos( )
end
end
end )
[/lua]
Hoo boy, none of my old stuff works. Just how much have things changed since I left?
EDIT: Alright, I give, nothing I'm doing is making this ruddy bullet-hose work again. Does anyone have a template SWEP I can have a peek at, so that I can maybe get back on my feet in this strange new Garry's Mod 13?
[QUOTE=randomscript;39447396]Hoo boy, none of my old stuff works. Just how much have things changed since I left?
EDIT: Alright, I give, nothing I'm doing is making this ruddy bullet-hose work again. Does anyone have a template SWEP I can have a peek at, so that I can maybe get back on my feet in this strange new Garry's Mod 13?[/QUOTE]
Try this [url]https://docs.google.com/document/d/1khSuIYrAMkqXu7wlH5YRJNwz6hOH6Xqi5lqBhE3x6gA/edit?pli=1[/url]
[QUOTE=Crap-Head;39447730]Try this [URL]https://docs.google.com/document/d/1khSuIYrAMkqXu7wlH5YRJNwz6hOH6Xqi5lqBhE3x6gA/edit?pli=1[/URL][/QUOTE]
I appreciate it, but unless it's something I'm overlooking (a renamed library that I'm somehow not seeing), there's nothing in that document that I'm doing wrong (as far as I know, at least). I suspect it's an issue with deriving from the base SWEP, but at this point I'm so lost I wouldn't be surprised if it wasn't. It doesn't even give errors in the console on starting up a game, it just... isn't there. 'give weapon_x' errors, which makes the conclusion obvious. If anyone would like to take a look at my code, I'll pastebin it, but I'm stumped.
[URL]http://pastebin.com/FgEPJ3Ue[/URL]
EDIT: The lua file itself is in lua/weapons/weapon_domdoublebarrel/, and is named shared.lua. If either of these conventions have changed (I seriously doubt this, but what the hell), my bad.
Sorry, you need to Log In to post a reply to this thread.