• What do you need help with? V3
    6,419 replies, posted
You're passing a nil value to usermessage.Hook instead of a function.
I'll take a look into that. [editline]19th February 2012[/editline] So, I fixed the OnPlayerDeath one, but now I figured out that the second (PlayerTakeDamage) doesn't send the usermessage. And I've been trying to figure out whats wrong [lua] function TTT.LogPlayerHurt( ent, infl, att, amount, dmginfo ) local v = ent local k = att local dm = dmginfo local d = string.FormattedTime(math.max(0, GetGlobalFloat("ttt_round_end", 0) - CurTime()), "%02i:%02i") local Message = Format("%s;;%s [%s] was attacked by %s [%s] for %s HP", d, k:Nick(), k:GetRoleString(), v:Nick(), v:GetRoleString(), math.Round(dm:GetDamage())) umsg.Start( "umsgRecieveDmg", pl ) umsg.String( Message ) umsg.End( ) end hook.Add("PlayerTakeDamage", "LogPlayerHurt", TTT.LogPlayerHurt) [/lua]
I got the error [lua] [gamemodes\dorkrp\gamemode\init.lua:216] attempt to index local 'player' <a number value> [/lua] when running this block of code [lua] net.Receive( "CreateCharInfo", function( player ) InFirstName = net.ReadString( fname ) InLastName = net.ReadString( fname ) InNationality = net.ReadString( nationality ) InOrientation = net.ReadString( orientation ) InPersonality = net.ReadString( personality ) local CharInsert = databaseObject:query("UPDATE users SET Firstname = '" .. InFirstName .. "' , SET Lastname = '" .. InLastName .. "', SET Nationality = '" .. InNationality .. "', SET Orientation = '" .. InOrientation .. "', SET Personality = '" .. InPersonality .. "' WHERE sid = '" .. player:SteamID() .. "'") CharInsert.onSuccess = function(q) print("Added character to the database") end woop! CharInsert.onError = function(Q,E) print("Q1") print(E) end CharInsert:start() net.Start( "Complete" ) net.WriteString( "True" ) net.Send(Entity(1)) end) [/lua]
The player is the second parameter. The first one is the length of the message. [editline]19th February 2012[/editline] Also net.ReadString doesn't take any parameters (none of the read functions do)
[QUOTE=ralle105;34774132]The player is the second parameter. The first one is the length of the message. [editline]19th February 2012[/editline] Also net.ReadString doesn't take any parameters (none of the read functions do)[/QUOTE] fname and the others are varibles being sent to it. and I dont know why that block of code isnt working, Im using ply:SteamID() further up in the code.
I just told you, your function needs 2 parameters, the second being the player. [editline]19th February 2012[/editline] Like so [lua]function(len, player)[/lua]
[QUOTE=ralle105;34774294]I just told you, your function needs 2 parameters, the second being the player. [editline]19th February 2012[/editline] Like so [lua]function(len, player)[/lua][/QUOTE] oh, sorry. I didnt get what you meant.
[QUOTE=Dorkslayz;34757402]This problem has only occurred in the GM13 beta, but I dont know how to fix it. This happens on all the map's I have tried with my gamemode. [img]http://cloud.steampowered.com/ugc/504639052636532739/BFDA3C426EDC806A49C2DA6D1D0BEA4F350D4CA7/[/img][/QUOTE] You can use the Command " gl_clear 1 " , but it dosent remove the leak.
Hi! I want to make a pointer on HUD, but I dont know how to rotate the texture. I have already drawn the face of speedometer: [CODE] local speedTex = surface.GetTextureID("gui/velocity_icons/speedo_face") surface.SetTexture(speedTex) surface.SetDrawColor(255, 255, 255, 255) surface.DrawTexturedRect(w-266, h-266, 256, 256) [/CODE] and now could anyone please help me with drawing a pointer? (how to draw texture at custom angle) Thanks!
[QUOTE=Jinx786;34774440]Hi! I want to make a pointer on HUD, but I dont know how to rotate the texture. I have already drawn the face of speedometer: [CODE] local speedTex = surface.GetTextureID("gui/velocity_icons/speedo_face") surface.SetTexture(speedTex) surface.SetDrawColor(255, 255, 255, 255) surface.DrawTexturedRect(w-266, h-266, 256, 256) [/CODE] and now could anyone please help me with drawing a pointer? (how to draw texture at custom angle) Thanks![/QUOTE] [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexcaac.html? title=Surface.DrawTexturedRectRotated"]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexcaac.html?title=Surface.DrawTexturedRectRotated[/URL] BAM :D
[QUOTE=Asaratha;34777045][lua] ply:SetPos(Vector(55.737461, 980.968750, -661.712341))[/lua] This is crashing my game when I start it up in Multiplayer, but when somebody else hosts it they don't crash. Is it just my game fucking up?[/QUOTE] You sure you're putting it in the spawn hooks and the file is server side?
[QUOTE=brandonj4;34776238][URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexcaac.html? title=Surface.DrawTexturedRectRotated"]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexcaac.html?title=Surface.DrawTexturedRectRotated[/URL] BAM :D[/QUOTE] Wow, thanks, I didnt realise that there was a separate function for this :D Works like a charm!
[QUOTE=Jinx786;34777626]Wow, thanks, I didnt realise that there was a separate function for this :D Works like a charm![/QUOTE] Glad to help :D
Is there a way to make an additional DFrame created from a DButton.OnClick not be hidden if you click the main form? It's kinda hard to explain. [thumb]http://www.bananatree.im/i/EFqDa7k2VDl.png[/thumb] Basically, when the red DFrame pops up, I don't want it to be hidden/put behind the black DFrame if I were to click out of it.
[b][url=http://wiki.garrysmod.com/?title=Panel.RequestFocus]Panel.RequestFocus [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
[QUOTE=marvincmarvin;34778345][b][url=http://wiki.garrysmod.com/?title=Panel.RequestFocus]Panel.RequestFocus [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b][/QUOTE] Thanks ;)
Is there an easy way to toggle SWEP.CSMuzzleFlashes in the shared file? I have a swep with a silencer toggle and want to disable it when the silencer is on and reenable it when the silencer is off, but I'm a bit new to lua and don't want to mess with the cl_init file :~(
Is it just me or does trying to loop through entity.dt silently fail? Why? Is there any way to get around this? I'm trying to save information from it for different entities with different DTVars. And I don't want to have to do something like this: [lua] local info = {} if ent:GetClass() == "entity1" then info.test1 = ent.dt.test1 elseif ent:GetClass() == "entity2" then info.test2 = ent.dt.test2 elseif -- etc [/lua] Edit: Managed to get it, thanks to Lexic, for anyone else trying this, here's how I did it: [lua] local ent = LocalPlayer():GetEyeTrace().Entity local _, table = debug.getupvalue( ent.DTVar, 1 ) PrintTable( table ) [/lua]
[QUOTE=CapsAdmin;34767547]view.angles = (ply:EyePos() - view.origin):Angle()[/QUOTE] This did not work its just thirdperson from behind. I need it facing my face :P function MyCalcView(ply, pos, angles, fov) local view = {} view.origin = pos+(angles:Forward()*100) view.angles = (ply:EyePos() - view.origin):Angle() view.fov = fov return view end hook.Add("CalcView", "MyCalcView", MyCalcView) hook.Add("ShouldDrawLocalPlayer", "MyHax ShouldDrawLocalPlayer", function(ply) return true end) TRIPLE EDIT GOT IT :D
[QUOTE=Asaratha;34779799]I let more people test it, they're crashing too. Would anybody know WHY this is happening at all? It's starting to irritate me.[/QUOTE] What hook are you calling this in?
[QUOTE=Drakehawke;34779371]Is it just me or does trying to loop through entity.dt silently fail? Why? Is there any way to get around this? I'm trying to save information from it for different entities with different DTVars. And I don't want to have to do something like this: [lua] local info = {} if ent:GetClass() == "entity1" then info.test1 = ent.dt.test1 elseif ent:GetClass() == "entity2" then info.test2 = ent.dt.test2 elseif -- etc [/lua][/QUOTE] It isn't just you. The issue is that ent.dt is a metatable and thus can't be iterated over. I don't think there's anything you can do about this either.
i have started working on a VIP rank system that i could use some help on [code] require( "tmysql" ) tmysql.initialize("localhost", "root", "12345", "gmod", 3306) local Player = FindMetaTable( "Player" ) function Player.IsVIP() tmysql.query( "SELECT `steamid`, `rank` FROM `gm_rank` WHERE `steamid`='" .. Player:SteamID() .. "'",function( rank ) if ( tonumber(rank[1][2]) >= 10 ) then return true end end) end [/code] When trying to do something simple like this: [code] for k, v in pairs(player.GetAll()) do if v:IsVIP() then v.SetHealth(300) end end [/code] I get calling 'SteamID' on bad self (Entity expected, got table) I haven't been doing lua vary long so i don't know much abut meta tables or if there is a better way to do this.
well there's a few problems here first off, in your IsVIP function, it should be a : not . also, you can't do it like that. You are returning true in the callback, not the function itself, you need to get the value when they join and then cache it [editline]19th February 2012[/editline] and it's v:SetHealth not v.SetHealth
How the hell can I prevent this crash from happening: [code]models/props_junk/meathook001a.mdl (2) at 39.2 -2.9 101.5 in contact with models /sickness/towtruckdr.mdl (2) at 41.1 -1.6 98.4, crash. dist = -1, minq = 9999999 99999999980000000000000000000000000000000000000000000000000000000000000000000000 00000000000000.000000[/code]
Im trying to send a netmessage from server to client, but I keep getting the error [lua] attempt to call field 'Recieve' (a nil value) [/lua] the block of code which is sending is [lua] local CharInsert = databaseObject:query("UPDATE users SET Firstname = '" .. InFirstName .. "', Lastname = '" .. InLastName .. "', Nationality = '" .. InNationality .. "', Orientation = '" .. InOrientation .. "', Personality = '" .. InPersonality .. "' WHERE sid = '" .. ply:SteamID() .. "'") CharInsert.onSuccess = function(q) print("Added character to the database") end CharInsert.onError = function(Q,E) print("Q1") print(E) end CharInsert:start() net.Start( "Complete" ) net.WriteString( truephrase ) net.Send(ply) [/lua] and the recieving block is [lua] net.Recieve( "Complete" , function( len ) local iscomplete = net.ReadString( truephrase ) if iscomplete == "true" then characterPanel:Close() print("Char Added") else print("Char not added; some shit went wrong") end [/lua]
its [code] net.Receive [/code] not [code] net.Recieve [/code]
[QUOTE=ArmageddonScr;34787730]its [code] net.Receive [/code] not [code] net.Recieve [/code][/QUOTE] oh, ok. Im just a fucking idiot.
I'm running Flood and I've made a VIP system etc, however when I set someone's team with pl:SetTeam(1) or so, they spawn and everything else works apart from the toolgun, It says it's a scripted entity. None of the tools work like weld etc. [lua] if table.HasValue(VIPS, pl:SteamID()) then pl:SetTeam(3) elseif table.HasValue(ADMINS, pl:SteamID()) then pl:SetTeam(4) else pl:SetTeam(2) end [/lua] That's what I'm doing on initial spawn, if I don't set there team everything works fine. I don't know what else to show really.
[QUOTE=Banana Lord.;34781235]well there's a few problems here first off, in your IsVIP function, it should be a : not . also, you can't do it like that. You are returning true in the callback, not the function itself, you need to get the value when they join and then cache it [editline]19th February 2012[/editline] and it's v:SetHealth not v.SetHealth[/QUOTE] As I said I haven't been doing lua vary long, so I don't know how I would cache it :(
[QUOTE=ory25;34788669]As I said I haven't been doing lua vary long, so I don't know how I would cache it :([/QUOTE] when they join, run the query, store it in a table
Sorry, you need to Log In to post a reply to this thread.