• Problems That Don't Need Their Own Thread v3.0
    5,003 replies, posted
[QUOTE=Mka0207;49078008]I am having this problem for when trying to set the world model texture not the SWEP's view model.[/QUOTE] Hmm. I misread that post, then. What you might want to try is messing around with model functions and what not, the world model is a drawn model so you might be able to find it by messing around with functions. Try ents.GetAll() and see if the world model is in there, maybe?
[QUOTE=MaximLaHaxim;49078075]Hmm. I misread that post, then. What you might want to try is messing around with model functions and what not, the world model is a drawn model so you might be able to find it by messing around with functions. Try ents.GetAll() and see if the world model is in there, maybe?[/QUOTE] I found a tedious/hacky work around, I guess it will do for now. Thanks for the help anyway!
[QUOTE=MaximLaHaxim;49076268][code]function GM:PreDrawHalos() local singletab = { LocalPlayer():GetNWEntity( "SelectedCombine" ) } if singletab[1] == NULL || !IsValid(singletab[1]) then print("screwit") return end halo.Add( singletab, Color( 255, 0, 0 ), 5, 5, 2, true, true ) end[/code] Still get the same problem. [/quote] Well my point was to just [I]not[/I] use NULL as a comparison. If you absolutely need it, then make it an "and" statement, because I'm somewhat certain that that comparison must be failing. That, or GetNWEntity is sometimes returning a null entity.
[QUOTE=Z0mb1n3;49078181]Well my point was to just [I]not[/I] use NULL as a comparison. If you absolutely need it, then make it an "and" statement, because I'm somewhat certain that that comparison must be failing. That, or GetNWEntity is sometimes returning a null entity.[/QUOTE] Already solved. Thanks for helping me, though :) [editline]8th November 2015[/editline] Anyone know how I could create a little map and place a dot depending on the vector a DTextEntry provides? Example of what I mean(made in ms paint :vs:): [img]http://i.imgur.com/s24Ubn9.png[/img] (with the little dot representing the given vector)
[QUOTE=MaximLaHaxim;49078496]Anyone know how I could create a little map and place a dot depending on the vector a DTextEntry provides? [/QUOTE] Well, to make the DTextEntry text into a vector you could use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/util/StringToType]util.StringToType[/url] but I have no idea how to make an entire minimap (sounds pretty hard to me).
[QUOTE=MaximLaHaxim;49078496]-snip=[/QUOTE] make a coordinate system check the x and y values of the vector with vector.x and vector.y and use that to place a dot along the panel by using ratios of panel sizes
[QUOTE=Shenesis;49076808]Then call the necessary hooks on the dmginfo, then substract the player's health at the end: [lua] bullet.Callback = function(attacker, tr, dmginfo) local ent = tr.Entity if (!IsValid(ent) or !ent:IsPlayer()) then return end if (!hook.Call("PlayerShouldTakeDamage", GAMEMODE, ent, attacker)) then return end hook.Call("ScalePlayerDamage", GAMEMODE, ent, tr.HitGroup, dmginfo) hook.Call("EntityTakeDamage", GAMEMODE, ent, dmginfo) local damage = dmginfo:GetDamage() local newhealth = ent:Health() - damage ent:SetHealth(newhealth) hook.Call("PlayerHurt", GAMEMODE, ent, attacker, newhealth, damage) end [/lua] Untested, but that's what I'd do[/QUOTE] The hook calls with setting health did the trick, thanks!
Is there an easy way to check if an entity is dead/destroyed? I've tried using [code] if ent:Health() == 0 then ent:remove() end [/code] but it just deletes the entity as soon as it spawns fixed it, used [code] if !IsValid( ent ) or ent:Health() <= 0 then ent:Remove() SeSound:Stop() end [/code]
How best way to transfer the table with the values: as string or as separate arguments?. If I try send the string, net.BytesWritten print ~ 240 bytes if I send separately, then print ~ 150 bytes. (String are compressed, because I use util.Compress and transmit data via net.WriteData) net.Receive get message lenght 1244, but why net.BytesWritten print only 157? Best way to send 128x128 or 256x256 image?
Is there any way to detect a player touching a trigger_teleport? Some maps have missing teleport destinations and could redo this myself rather than recompiling maps.
[QUOTE=Revenge282;49077924]To add to this, I can the particle effects immediately after joining the server, but after I have completely spawned (after that splash noise), the particles are removed.[/QUOTE] Solved my issue by using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/CreateParticleSystem]Global.CreateParticleSystem[/url] with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/CNewParticleEffect/IsValid]CNewParticleEffect:IsValid[/url] ( IsValid(ParticleSys) ) in a Think hook.
Is there an easy way to make derma frames not lock your controls, a bit like ULX XGUI does? I'm trying to make a menu that you can walk around while using, but your mouse is free to click on the menu buttons. Thank you =)
[QUOTE=Deathbypwnage;49092192]Is there an easy way to make derma frames not lock your controls, a bit like ULX XGUI does? I'm trying to make a menu that you can walk around while using, but your mouse is free to click on the menu buttons. Thank you =)[/QUOTE] Use Frame:SetAlpha(255) or Frame:SetVisible(true) [b]instead[/b] of using Frame:MakePopup(). Now use gui.EnableScreenClicker(true) to enable the mouse. Remember to set gui.EnableScreenClicker(false) when the Frame is being closed.
Having an issue spawning vehicles (dev branch) [lua]local c = ents.Create('prop_vehicle_jeep') print(m,s,c,veh,pos,ang) c:SetModel(m) c:SetKeyValue('vehiclescript','scripts/vehicles/'..s..'.txt') c:PhysicsInit(SOLID_VPHYSICS) c:SetUseType(SIMPLE_USE) c:SetPos(pos) c:SetAngles(ang) c:Spawn()[/lua] The print on the second line prints this: [code]models/lonewolfie/bently_pmcontinental.mdl continental Vehicle [NULL] continental 7262.000000 -7435.000000 57.000000 0.000 -22.000 0.000[/code] Error (line 192 is c:Spawn() in the above code): [code]gamemodes/x/gamemode/modules/vehicles/sv_vehicles.lua:192: Tried to use a NULL vehicle! 1. SetPos - [C]:-1 2. SetupVehicle - gamemodes/x/gamemode/modules/vehicles/sv_vehicles.lua:192 3. oldFunc - gamemodes/x/gamemode/modules/vehicles/sv_vehicles.lua:291 4. func - addons/dbugr/lua/dbugr/util/modules/sh_func.lua:77 5. unknown - lua/includes/extensions/net.lua:32[/code] [editline]10th November 2015[/editline] SetupVehicle is the function/code provided.
[QUOTE=Revenge282;49094076]Having an issue spawning vehicles (dev branch) [lua]local c = ents.Create('prop_vehicle_jeep') print(m,s,c,veh,pos,ang) c:SetModel(m) c:SetKeyValue('vehiclescript','scripts/vehicles/'..s..'.txt') c:PhysicsInit(SOLID_VPHYSICS) c:SetUseType(SIMPLE_USE) c:SetPos(pos) c:SetAngles(ang) c:Spawn()[/lua] The print on the second line prints this: [code]models/lonewolfie/bently_pmcontinental.mdl continental Vehicle [NULL] continental 7262.000000 -7435.000000 57.000000 0.000 -22.000 0.000[/code] Error (line 192 is c:Spawn() in the above code): [code]gamemodes/x/gamemode/modules/vehicles/sv_vehicles.lua:192: Tried to use a NULL vehicle! 1. SetPos - [C]:-1 2. SetupVehicle - gamemodes/x/gamemode/modules/vehicles/sv_vehicles.lua:192 3. oldFunc - gamemodes/x/gamemode/modules/vehicles/sv_vehicles.lua:291 4. func - addons/dbugr/lua/dbugr/util/modules/sh_func.lua:77 5. unknown - lua/includes/extensions/net.lua:32[/code] [editline]10th November 2015[/editline] SetupVehicle is the function/code provided.[/QUOTE] Is there actually a vehicle script named 'continental.txt' in your vehicle scripts folder? And does this vehicle have a spawnmenu icon?
[QUOTE=Z0mb1n3;49094120]Is there actually a vehicle script named 'continental.txt' in your vehicle scripts folder? And does this vehicle have a spawnmenu icon?[/QUOTE] Yeah, it has a script, file.Exists on that filepath returns true. The gamemode is not sandbox, so no spawn icons.
[QUOTE=Revenge282;49094208]Yeah, it has a script, file.Exists on that filepath returns true. The gamemode is not sandbox, so no spawn icons.[/QUOTE] Well I mean if you were to go into sandbox, could you spawn it from the Q menu? I'm thinking it might be a different vehicle class other than prop_vehicle_jeep. For now, try making the class a prop_vehicle_jeep_old.
[QUOTE=Deathbypwnage;49092192]Is there an easy way to make derma frames not lock your controls, a bit like ULX XGUI does? I'm trying to make a menu that you can walk around while using, but your mouse is free to click on the menu buttons. Thank you =)[/QUOTE] [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Panel/SetMouseInputEnabled]Panel:SetMouseInputEnabled[/url] Use that instead of panel:MakePopup
[QUOTE=Revenge282;49094076]Having an issue spawning vehicles (dev branch) [lua]local c = ents.Create('prop_vehicle_jeep') print(m,s,c,veh,pos,ang) c:SetModel(m) c:SetKeyValue('vehiclescript','scripts/vehicles/'..s..'.txt') c:PhysicsInit(SOLID_VPHYSICS) c:SetUseType(SIMPLE_USE) c:SetPos(pos) c:SetAngles(ang) c:Spawn()[/lua] The print on the second line prints this: [code]models/lonewolfie/bently_pmcontinental.mdl continental Vehicle [NULL] continental 7262.000000 -7435.000000 57.000000 0.000 -22.000 0.000[/code] Error (line 192 is c:Spawn() in the above code): [code]gamemodes/x/gamemode/modules/vehicles/sv_vehicles.lua:192: Tried to use a NULL vehicle! 1. SetPos - [C]:-1 2. SetupVehicle - gamemodes/x/gamemode/modules/vehicles/sv_vehicles.lua:192 3. oldFunc - gamemodes/x/gamemode/modules/vehicles/sv_vehicles.lua:291 4. func - addons/dbugr/lua/dbugr/util/modules/sh_func.lua:77 5. unknown - lua/includes/extensions/net.lua:32[/code] [editline]10th November 2015[/editline] SetupVehicle is the function/code provided.[/QUOTE] Make sure you are up to date, that was already fixed.
Robotboy, An entity index needs only 13 bits to represent the full range of -4096 to 4095 (well, 4096 is the value stated on the Valve wiki). Question 1: Firstly, ignoring whether it would make much difference at all to bandwidth, would there be an actual physical decrease at all in the number of bits transmitted over the network by doing: [code] net.WriteInt(ent:EntIndex(), 14) [/code] - when compared with doing [code] net.WriteEntity(ent) [/code] - which in a thread from 2013, Willox claims is implemented as [code]net.WriteInt(ent:EntIndex(), 32)[/code] ... does it just send 32 bits (or 16 bits) for alignment purposes and then only use 14 (13?) of those bits - or does it [i]actually[/i] literally send 14 bits for that value? Secondly, if it is true that the net library sends the exact number of bits specified, would the bandwidth saving of the 2 bits (assuming that it aligns on a byte boundary) - or 18 bits (if it always sends 32 bits underneath) be worth it when compared with the performance impact of the lack of byte alignment?
[QUOTE=Mrkrabz;49090492]Is there any way to detect a player touching a trigger_teleport? Some maps have missing teleport destinations and could redo this myself rather than recompiling maps.[/QUOTE] Try looping through [url=http://wiki.garrysmod.com/page/ents/FindByClass]ents.FindByClass[/url] with "trigger_teleport" as the argument, and then add a callback for PhysicsCollide with [url=http://wiki.garrysmod.com/page/Entity/AddCallback]ENTITY:AddCallback[/url]. I think that might work. You might want to use some sort of global bool as to when you should loop through the ents, as doing this every frame would be expensive(and you don't want to keep overriding callbacks)
[CODE]sound.Add( { name = "enzo_engine_idle", channel = CHAN_STATIC, volume = 1.0, level = 80, pitch = { 95, 110 }, sound = "vehicles/enzo/idle.wav" } )[/CODE] Would usign something like this but with a link for the file path work?
[QUOTE=man with hat;49074943]Not possible. Closest thing you can use is [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/string/dump]string.dump[/url], but that will return the bytecode of the function, which, unless, you're going to parse yourself, won't tell you an awful lot.[/QUOTE] Not always true. If the function is defined in a file somewhere, you get the function body using linedefined and lastlinedefined (provided with debug.getinfo or one of the jit ones), some maths and simple parsing. All the information you need is available if the function is defined in a file on the disk.
-snip-
My clientside files in autorun doesn't run automaticly unless i reload them (save them), what can i do?
You need to make sure the file's name is unique, and no other file in existence inside any clientside autorun folder has the same name. To test, name it something like "cl_myuniqueluafile.lua"
[lua] if attacker:Team() == 1 then alphascore = (alphascore + 10) else bravoscore = (bravoscore + 10) end[/lua] I know the answer will be extremely simple, but I'll ask it anyway. What did I do wrong here? The score doesn't get added by 10. (the function around it works fine, its just that this part doesn't add 10 to the score) And no, those variables are not nil, I added this before it. [lua] if alphascore == nil then alphascore = 0 end if bravoscore == nil then bravoscore = 0 end [/lua]
[QUOTE=Skere_;49115487][lua] if attacker:Team() == 1 then alphascore = (alphascore + 10) else bravoscore = (bravoscore + 10) end[/lua] I know the answer will be extremely simple, but I'll ask it anyway. What did I do wrong here? The score doesn't get added by 10. (the function around it works fine, its just that this part doesn't add 10 to the score) And no, those variables are not nil, I added this before it. [lua] if alphascore == nil then alphascore = 0 end if bravoscore == nil then bravoscore = 0 end [/lua][/QUOTE] you shouldn't use score variables you should use team.SetScore
[QUOTE=MaximLaHaxim;49115548]you shouldn't use score variables you should use team.SetScore[/QUOTE] Oh right forgot about them, will use that. EDIT: It worked fine, thanks. Just for educational purposes, mind explaining why my old code didn't work?
Hey, I want a function to be executed, every server start/map change and from there every 10800 seconds. Here is what I got so far (the function is working, but not executed every server start/map change): [CODE] local function ConnectAPI() http.Fetch( "https://bitcoinapi.de/v1/NOPE/rate.json", function( body, len, headers, code ) if body == "api call limit reached" then MsgC( Color( 255, 0, 0 ), "[BM DEBUG] ERROR: api call limit reached\n" ) else local value = util.JSONToTable( body ) bitconfig.bitvalue = math.Round( tonumber( value["rate_weighted_3h"] ), 0 ) MsgC( Color( 33, 150, 243 ), "[BM DEBUG]", Color( 255, 255, 255), "Der aktuelle Wert beträgt ", Color( 33, 150, 243 ), bitconfig.bitvalue, Color( 255, 255, 255 ), "€ pro BitCoin\n" ) end end, function( error ) MsgC( Color( 255, 0, 0 ), "[BM DEBUG] ERROR: Verbindung mit API konnte nicht hergestellt werden\n" ) end ) end timer.Create( "BitMinerConnectAPI", 10800, 0, ConnectAPI ) hook.Add("Initialize", function() ConnectAPI() end) [/CODE] [editline]15th November 2015[/editline] Also this code seems not to work: [CODE] local function SetOwner(ply, ent) ent:SetNWEntity("owner", ply) end hook.Add("PlayerSpawnedSENT", "SetCPPIOwnerSENT", SetOwner) local function RemoveOwnEntities( ply, tr, tool ) if tool == "remover" and IsValid( tr.Entity ) and tr.Entity:GetNWEntity("owner") == ply then return true end end hook.Add( "CanTool", "AllowRemovingOwnEntities", RemoveOwnEntities ) [/CODE] Any idea? I'm trying to allow everyone to remove their own entities spawned in DarkRP via F4.
Sorry, you need to Log In to post a reply to this thread.