• What do you need help with? V3
    6,419 replies, posted
[QUOTE=Science;39414245]I simply want to return the index value of a table?[/QUOTE] [lua] for index, value in pairs(table) do MsgN(index) -- Lol MsgN(value) -- true end [/lua]
[QUOTE=Science;39414245]I simply want to return the index value of a table?[/QUOTE] which index?
[QUOTE=Drakehawke;39414803]which index?[/QUOTE]Dont worry. I simply used my dodgy hacky method. [lua]function table.GetI(tab, ref) for k,v in pairs(tab) do if k == ref then return k or nil end end end[/lua]
[QUOTE=Science;39414882]Dont worry. I simply used my dodgy hacky method. [lua]function table.GetI(tab, ref) for k,v in pairs(tab) do if k == ref then return k or nil end end end[/lua][/QUOTE] what on earth are you doing why do you need to get k, if k is equal to ref and you're passing ref to that function? you may aswell do [lua]function table.GetI(tab, ref) return tab[ref] ~= nil and ref end[/lua] which is so small it's not even worth having a function for it
I realised that about 10 minutes ago. Im offically an idiot. [img]http://transitionculture.org/wp-content/uploads/potato.jpg[/img] ^ Me ^
[QUOTE=Science;39404448]One more question. Lets say i had this table. Table = {} Table["Lol"] = true Table["Test"] = false How would i get the indexing value? Eg. Lol or Test[/QUOTE] IIRC wouldn't you use: [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index411a-2.html"]table.KeyFromValue[/URL] or [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexf932.html"]table.KeysFromValue[/URL]
FIXED!
Clockwork bypass. One does not simply say "Open-source". Thus, this is a bypass to their DRM, to make Clockwork truly open-source. I protest against the misuse of these words. Either don't call it open-source, or don't include a DRM with Clockwork itself. Spread the word. Clockwork: [url]http://filesmelt.com/dl/clockwork1.7z[/url] Bypass: [url]http://filesmelt.com/dl/clockwork_drm_bypass.7z[/url] I will not post HL2RP, it would violate my principles. But according to Conna and Co, Clockwork should be open-source. What we currently see is a Clockwork with a DRM, that is required to run it, thus, not open-source.
I got this code, it tells you who killed you and if he was innocent or traitor. [CODE]if ( SERVER ) then hook.Add( "PlayerDeath", "CHIIPPPSS" , function( Pl, Ent, Killer ) 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) end[/CODE] But it is giving me a error " [ERROR] lua/autorun/client/ttt_death_notify.lua:23: unexpected symbol near 'and' 1. unknown - lua/autorun/client/ttt_death_notify.lua:0 " help?
for some reason my auto promote for my server stop promoting every one and i dont know how to fix it im using ulx admin, this auto promote [url]http://forums.ulyssesmod.net/index.p...ic,3826.0.html[/url] and ulx time. what would cause this issue?
[QUOTE=Alex_grist;39413912]Stop trying to crack Clockwork.[/QUOTE] Done.
When I'm loading up my Dev Gamemode I'm Receiving this error: Engine Error Error loading Gamemode !IsValidGamemode [DEV]
Getting error bad argument #2 to 'Find' (string expected, got nil) [CODE]for k, v in pairs(file.Find("PERP3/gamemode/sh_modules/*", LUA_PATH)) do include("sh_modules/" .. v); end Msg("Loading Items...\n"); for k, v in pairs(file.Find("PERP3/gamemode/items/*", LUA_PATH)) do include("items/" .. v); end Msg("Loading Shops...\n"); for k, v in pairs(file.Find("PERP3/gamemode/shops/*", LUA_PATH)) do include("shops/" .. v); end Msg("Loading Mixtures...\n"); for k, v in pairs(file.Find("PERP3/gamemode/mixtures/*", LUA_PATH)) do include("mixtures/" .. v); end Msg("Loading Vehicles...\n"); for k, v in pairs(file.Find("PERP3/gamemode/vehicles/*", LUA_PATH)) do include("vehicles/" .. v); end local function loadPostInt ( ) Msg("Loading Properties...\n"); for k, v in pairs(file.Find("PERP3/gamemode/properties/*", LUA_PATH)) do include("PERP3/gamemode/properties/" .. v); end Msg("Loading NPCs...\n"); for k, v in pairs(file.Find("PERP3/gamemode/npcs/*", LUA_PATH)) do include("PERP3/gamemode/npcs/" .. v); end[/CODE] Any help guys? :/
[QUOTE=havejack;39415918] How would i make it where it always adds the icons to the owned cars part when they open it, it doesnt show the owned cars till you buy one....[/QUOTE] ANyone able to help me with my code ?
[QUOTE=trav0405;39417630]Getting error bad argument #2 to 'Find' (string expected, got nil) [CODE]for k, v in pairs(file.Find("PERP3/gamemode/sh_modules/*", LUA_PATH)) do include("sh_modules/" .. v); end Msg("Loading Items...\n"); for k, v in pairs(file.Find("PERP3/gamemode/items/*", LUA_PATH)) do include("items/" .. v); end Msg("Loading Shops...\n"); for k, v in pairs(file.Find("PERP3/gamemode/shops/*", LUA_PATH)) do include("shops/" .. v); end Msg("Loading Mixtures...\n"); for k, v in pairs(file.Find("PERP3/gamemode/mixtures/*", LUA_PATH)) do include("mixtures/" .. v); end Msg("Loading Vehicles...\n"); for k, v in pairs(file.Find("PERP3/gamemode/vehicles/*", LUA_PATH)) do include("vehicles/" .. v); end local function loadPostInt ( ) Msg("Loading Properties...\n"); for k, v in pairs(file.Find("PERP3/gamemode/properties/*", LUA_PATH)) do include("PERP3/gamemode/properties/" .. v); end Msg("Loading NPCs...\n"); for k, v in pairs(file.Find("PERP3/gamemode/npcs/*", LUA_PATH)) do include("PERP3/gamemode/npcs/" .. v); end[/CODE] Any help guys? :/[/QUOTE] replace LUA_PATH with "LUA"
[QUOTE=Splambob;39410791]Hey guys, I've got a problem with tools and singleplayer. Here's my tool's left click function; [lua]function TOOL:LeftClick( trace ) Msg(CLIENT, SERVER, "\n") if (CLIENT) then Msg("hello") self:TransmitSelection() return true end self.LastClick = trace end[/lua] The tool doesn't work. In the console, I only see "falsetrue" printed in server text. Why doesn't this function run on the client when I'm running singleplayer? Also an unanswered question from earlier just in case it was missed, how do I find the holder of a weapon? self.Owner proves unreliable if another person spawned the weapon. Thanks! [/QUOTE] Try it in local-multiplayer instead. Clientside is really unreliable in singleplayer (because it doesn't really exist in source). self.Owner should always return the player who is carrying the weapon, wether it be spawned by him or not.
[QUOTE=Cookie Monster!;39417519]When I'm loading up my Dev Gamemode I'm Receiving this error: Engine Error Error loading Gamemode !IsValidGamemode [DEV][/QUOTE]No symbols. Remove them from the game mode name.
My server is auto-disconnecting people upon joining this error is printed on my server console gamemodes/perp3/gamemode/sv_misc.lua:71: attempt to index global 'gatekeeper' (a nil value) I have gate keepter modules installed, but this error is is required to be fixed for anyone to play sv_misc.lua:71 [CODE] local numPlayers = gatekeeper.GetNumClients().total;[/CODE] Also i have another error with a simple timer Timer Failed! [Simple] sv_hooks.lua:149 [CODE]timer.Simple(1, GAMEMODE.PushNumPlayers);[/CODE]
Any help with my proplem at all ?
[QUOTE=thejjokerr;39418973]99)) or IsD (and Color( 52,128, 209) that and shouln't have that bracketin front.[/QUOTE] Thanks, so if it's wrong, how do I fix it? EDIT: Nvm got it to work! o///
[lua] cam.Start3D( EyePos(), EyeAngles() ) for k, v in pairs(ents.GetAll()) do if IsValid(v) then v:SetNoDraw(true) end end local cd = {} cd.origin,cd.angles = EyePos(),EyeAngles() cd.x,cd.y = 0,0 cd.w,cd.h = ScrW()/10,ScrH()/10 render.RenderView(cd) for k, v in pairs(ents.GetAll()) do if IsValid(v) then v:SetNoDraw(false) end end cam.End3D() [/lua] Inside a screen rendering hook, this displays what I see to the top left of my screen, minus all valid entities. How can I also make the world geometry not draw in the renderview?
So.. this code reveals who is traitor, and who is inno. umsg.Bool( Killer:IsTraitor() ) umsg.Bool( Killer:IsDetective() ) Anyway to make a script that tells who is who when you look at them? I plan to insert that into a D weapon, (something like glasses, that will cost 3 credits and will endure only 10 seconds) But I won't need help with making the swep.
player:GetEyeTrace().Entity:Nick()
[QUOTE=Bletotum;39420325]player:GetEyeTrace().Entity:Nick()[/QUOTE] How do I merge that with my code into a lua script?(ps: I don't know how to make them from scratch, sorry)
[url]https://github.com/garrynewman/garrysmod/blob/master/garrysmod/gamemodes/base/gamemode/cl_targetid.lua[/url]
I'm making a small custom SWEP for a fairly useless mini-project of mine, and this is what I have. [lua]function SWEP:PrimaryAttack() local tr = self.Owner:GetEyeTrace().Entity if not tr:IsValid() then return end if tr:IsPlayer() then else return end if tr:GetPos():Distance( self.Owner:GetPos() ) > self.Primary.Distance then return end if SERVER then self.Owner:EmitSound( self.Primary.Sound, 75, 160 ) tr:SetHealth( tr:Health - 5 ) --Damages Player for 5 HP end end[/lua] I'm trying to make it so that when a player is within distance in eyetrace, it removes 5HP and plays a sound. [b]Problem 1:[/b]The sound works but it refuses to make the victim's HP minus 5. [b]Problem 2:[/b]How can I go about making a small 'nudge' effect you see on other SWEPs, where the victim takes pain and it nudges him a little in the opposite direction? Thanks in advance for any help/info guys, I appreciate it.
How come this always gives me errors: [LUA] local add1 = (toNumber(ply:GetPData( "JeepOwned" ))) local add = (toNumber(ply:GetPData( "GolfOwned" ))) ply:SetNWInt( "JeepOwned", add1) ply:SetNWInt( "GolfOwned", add) [/LUA] this is the error in the console "attempt to call global 'toNumber' (a nil value)"
Does anyone know what the math function is to find if a number is between 2 other numbers. Like to check if 7 is between 1 and 20
Ironsights. Is it like broken in Gmod 13 or something? Anyone got a good tutorial?
[QUOTE=Bletotum;39420388][url]https://github.com/garrynewman/garrysmod/blob/master/garrysmod/gamemodes/base/gamemode/cl_targetid.lua[/url][/QUOTE] I see you're really trying to help, but how can I make it show if he's a traitor or inno over their nicknames when you look at them?
Sorry, you need to Log In to post a reply to this thread.