• Problems That Don't Need Their Own Thread v5
    4,111 replies, posted
Thank you so much it works now :D just one more question if i wanted to spawn the user at the location of his ragdoll, How would i got about doing this?
[QUOTE=DJ Bat;52817099]Thank you so much it works now :D just one more question if i wanted to spawn the user at the location of his ragdoll, How would i got about doing this?[/QUOTE] store a local variable on the player when he dies with his location, when he spawns set his location to that.
How can I get sv.db custom saved Pdata to the client? Trying to make it check if the data has a specific value, if its the value I assigned it should print something on the client. How can I do that?
[QUOTE=MGFear;52820083]How can I get sv.db custom saved Pdata to the client? Trying to make it check if the data has a specific value, if its the value I assigned it should print something on the client. How can I do that?[/QUOTE] Network the value using net messages or the SetNW*Type* functions.
Is [url=https://wiki.garrysmod.com/page/File_Based_Storage]this guide[/url] outdated or am I just disabled? I'm getting this error, despite literally not changing anything in the page's code: [code] [ERROR] addons/monster mash/lua/autorun/medals_data.lua:12: attempt to index a nil value 1. LoadPlayerData - addons/monster mash/lua/autorun/medals_data.lua:12 2. unknown - addons/monster mash/lua/autorun/medals_data.lua:17 [/code]
idk if anyone has asked this before but, does table.remove( ) work for non numerically indexed tables?
Does anyone know if the core playermodel code has support for ACT_TURN? CS:GO uses it for playermodels and I wanted to see if I could an animation to get it myself. I know the hl2 npcs use it.
[QUOTE=Stiffy360;52820574]Does anyone know if the core playermodel code has support for ACT_TURN? CS:GO uses it for playermodels and I wanted to see if I could an animation to get it myself. I know the hl2 npcs use it.[/QUOTE] Not by default, but it's possible to add.
This should be an easy problem but apparently nobody has the answer... My understanding is that valve moved the npc sounds in the vo/ directory to a special GCF file so that they could release different voice packs depending on the game language. One caveat is that the user must have a * symbol before the sound name in order for it to play, i think. Because the NPCs use this format when they play a sound from that GCF. It seems that if i do something like [code]someEntity:EmitSound("*vo/npc/male01/ok02.wav")[/code] it works.... but only for some of the sounds i try. others will give me an error that it can't be found on disk even though it's obviously there. i thought this was a precache problem but it doesn't seem to help if i precache the sounds.
Can you provide a few that don't work so we can test?
[CODE] local pl = LocalPlayer() local ammo = pl:GetActiveWeapon():Clip1() local ammo2 = pl:GetAmmoCount(pl:GetActiveWeapon():GetPrimaryAmmoType()) local smoothHealth = Lerp(10 * FrameTime() , smoothHealth , pl:Health()) surface.SetDrawColor(40,40,40,120) surface.DrawRect(posx + 3.5, posy - 3, 255, 25) surface.SetDrawColor(255, 255, 255, 255) surface.DrawRect(posx + 4, posy, smoothHealth * 2.5, 20) surface.SetTextColor(255,255,255,255) surface.SetFont("HUDFont") surface.SetTextPos(posx - 60, posy - 10) surface.DrawText(pl:Health()) surface.SetTextColor(255,255,255,255) surface.SetFont("HUDFont") surface.SetTextPos(posx * 8, posy - 10) surface.DrawText(ammo.."/"..ammo2) [/CODE] get an error along the lines of "attempted to call method 'Clip1' (a nil value)", get the same error for GetPrimaryAmmoType just getting into lua and from what I've seen on the forums and looking around through tutorials I thought I did everything right.
[QUOTE=*Braindawg*;52821626] -- get an error along the lines of "attempted to call method 'Clip1' (a nil value)", get the same error for GetPrimaryAmmoType just getting into lua and from what I've seen on the forums and looking around through tutorials I thought I did everything right.[/QUOTE] GetActiveWeapon() returns NULL if you aren't holding a weapon which causes that error, so you write something like this: [CODE] local pl = LocalPlayer() if IsValid(LocalPlayer():GetActiveWeapon()) then // code end [/CODE]
- delete -
[QUOTE=arow1234;52820557]idk if anyone has asked this before but, does table.remove( ) work for non numerically indexed tables?[/QUOTE] No. It's impossible to 'shift down' non numeric keys because they have no numerical position in the first place. This is why you need to use a [URL="https://wiki.garrysmod.com/page/Global/pairs"]pairs[/URL] loop to go through these sorts of tables. You can't use [URL="https://wiki.garrysmod.com/page/Global/ipairs"]ipairs[/URL] on a non numeric table. Just do [CODE] tbl[ key ] = nil [/CODE] That works with numeric tables as well, but some indexes will be missing
[QUOTE=MPan1;52822293]No. It's impossible to 'shift down' non numeric keys because they have no numerical position in the first place. This is why you need to use a [URL="https://wiki.garrysmod.com/page/Global/pairs"]pairs[/URL] loop to go through these sorts of tables. You can't use [URL="https://wiki.garrysmod.com/page/Global/ipairs"]ipairs[/URL] on a non numeric table. Just do [CODE] tbl[ key ] = nil [/CODE] That works with numeric tables as well, but some indexes will be missing[/QUOTE] hmmk, that's what I've been doing with tables with non numeric keys, setting their values to nil. I was just looking to see if there was a way to just remove the entry from the table completely.
[QUOTE=arow1234;52822374]hmmk, that's what I've been doing with tables with non numeric keys, setting their values to nil. I was just looking to see if there was a way to just remove the entry from the table completely.[/QUOTE] That's what setting it to nil does. A valid key cannot have nil as a value, and even if it did, checking if the key existed would always prove it didn't. Lua treats nil as false, and by default, all keys of a table are nil anyway. You're just setting it to what it was originally.
Are weapons attached or bonemerged onto the playermodel? if attached is there a way to bonemerge them?
[QUOTE=Stiffy360;52823550]Are weapons attached or bonemerged onto the playermodel? if attached is there a way to bonemerge them?[/QUOTE] Bonemerged
[QUOTE=code_gs;52821584]Can you provide a few that don't work so we can test?[/QUOTE] Try running this on your console and see what sound plays: [code] Entity(1):EmitSound("*vo/npc/male01/hacks01.wav") Entity(1):EmitSound("*vo/npc/male01/hi01.wav") [/code] In a perfect world you will hear both. For me, i only hear the second voice clip.
[QUOTE=Moat;52825626]Try this: [lua] Entity(1):EmitSound("*vo/npc/male01/hacks01.wav", 75, 100, 1, CHAN_STATIC) Entity(1):EmitSound("*vo/npc/male01/hi01.wav", 75, 100, 1, CHAN_STATIC) [/lua][/QUOTE] You would probably want CHAN_VOICE in this case, but I'm not sure of his use intention.
Assuming you're not playing both at the same time, DarkRP uses both those sounds and both of them don't have the aterisks. Look at line 62 and line 285 [URL="https://github.com/FPtje/DarkRP/blob/353dc3286092cdb2efade2cc0f2145db5a6c2e69/gamemode/modules/chatsounds.lua#L62"]here[/URL]
[QUOTE=MelonShooter;52825658]Assuming you're not playing both at the same time, DarkRP uses both those sounds and both of them don't have the aterisks. Look at line 62 and line 285 [URL="https://github.com/FPtje/DarkRP/blob/353dc3286092cdb2efade2cc0f2145db5a6c2e69/gamemode/modules/chatsounds.lua#L62"]here[/URL][/QUOTE] It makes sense there since people can say the same voice clip repetitively, while in HL2, the voice clips are usually played rarely or only once in a sequential campaign. Would be nice to get some context on what he's trying to do with the sound clips.
[QUOTE=code_gs;52825703]It makes sense there since people can say the same voice clip repetitively, while in HL2, the voice clips are usually played rarely or only once in a sequential campaign. Would be nice to get some context on what he's trying to do with the sound clips.[/QUOTE] The context is that players can emit these sounds at any time on demand. If i remove the asterisk i get errors saying it's not on the disk. I'll mess around with it more tomorrow and see if i can get consistent results.
So I made an npc entity and I'm trying to change its model, but it doesn't work. I also tried making the npc entity invisible and parenting it to another entity, but that doesn't place on the parent so well. Any thoughts on how to change an npc entity? [CODE] local entity = ents.Create("npc_cscanner") entity:SetPos(client:GetPos()) --This isn't a problem entity:SetAngles(client:GetAngles()) --This isn't a problem entity:SetColor(client:GetColor()) --This isn't a problem entity:SetModel("models/shield_scanner.mdl") entity:Spawn() entity:Activate() [/CODE]
What's your entity's Initialize method?
[QUOTE=code_gs;52825971]What's your entity's Initialize method?[/QUOTE] Isn't npc_cscanner the HL2 city scanner? There wouldn't be an Initialize method, only a Spawn method If you can set the entity's [URL="https://github.com/ValveSoftware/source-sdk-2013/blob/master/mp/src/game/server/hl2/npc_scanner.cpp#L151"]m_bIsClawScanner[/URL] to true before you spawn it, it should set it up as a proper Claw Scanner. Also, even if you could set the model correctly, the sounds and that wouldn't be correct. There's also [URL="https://developer.valvesoftware.com/wiki/Npc_clawscanner"]npc_clawscanner[/URL] but apparently that is only existent in HL2 EP1 EDIT: Just found out that npc_clawscanner does exist in GMod, and is what is used in Sandbox
[QUOTE=Sm63;52826128]Isn't npc_cscanner the HL2 city scanner? There wouldn't be an Initialize method, only a Spawn method If you can set the entity's [URL="https://github.com/ValveSoftware/source-sdk-2013/blob/master/mp/src/game/server/hl2/npc_scanner.cpp#L151"]m_bIsClawScanner[/URL] to true before you spawn it, it should set it up as a proper Claw Scanner. Also, even if you could set the model correctly, the sounds and that wouldn't be correct. There's also [URL="https://developer.valvesoftware.com/wiki/Npc_clawscanner"]npc_clawscanner[/URL] but apparently that is only existent in HL2 EP1 EDIT: Just found out that npc_clawscanner does exist in GMod, and is what is used in Sandbox[/QUOTE] (Sorry I didn’t mean to rate your post late I’m on my phone) Anyways I think the only working method then is to just set the scanner as invisible and then parent a new entity over it. Only issue is that it spawns like 5ft above the scanner and I have no way of lowering it. Also, it makes me wonder how things like Model Manipulator work when it comes to changing NPC’s
[QUOTE=pilot;52826329](Sorry I didn’t mean to rate your post late I’m on my phone) Anyways I think the only working method then is to just set the scanner as invisible and then parent a new entity over it. Only issue is that it spawns like 5ft above the scanner and I have no way of lowering it. Also, it makes me wonder how things like Model Manipulator work when it comes to changing NPC’s[/QUOTE] Have you tried changing the order? I mean, setting the model AFTER you do entity:Spawn() The city scanner NPC sets the model when the Spawn method is called, so it might be overriding your call
[QUOTE=Sm63;52826408]Have you tried changing the order? I mean, setting the model AFTER you do entity:Spawn() The city scanner NPC sets the model when the Spawn method is called, so it might be overriding your call[/QUOTE] That's what I was thinking. I guessed it would have been Lua code since he said "my entity," but the engine probably sets it in the spawn method and not the constructor.
[QUOTE=code_gs;52826419]That's what I was thinking. I guessed it would have been code since he said "my entity," but the engine probably sets it in the spawn method and not the constructor.[/QUOTE] [URL="https://github.com/ValveSoftware/source-sdk-2013/blob/master/mp/src/game/server/hl2/npc_scanner.cpp#L248-L255"]It most certainly does[/URL]
Sorry, you need to Log In to post a reply to this thread.