• What do you need help with? V3
    6,419 replies, posted
Trying to fix some errors: [CODE][ERROR] gamemodes/game/gamemode/cl_command.lua:133: attempt to perform arithmetic on a nil value 1. v - gamemodes/game/gamemode/cl_command.lua:133 2. unknown - lua/includes/modules/hook.lua:82[/CODE] Does this mean it's basically f**ked? Line [lua]if(client:GetActiveWeapon().Primary)then ammobar=mag_left/client:GetActiveWeapon().Primary.ClipSize*180 else ammobar=mag_left/MaxAmmo[client:GetActiveWeapon():GetClass()]*180 end[/lua]
GetActiveWeapon can be nil
How would one make so so when someone buys admin on my website it makes them admin on the server :)
[QUOTE=Banana Lord.;38909525]GetActiveWeapon can be nil[/QUOTE] @brandonj4 call StripWeapons on a player, GetActiveWeapon is nil also when they are dead
Am I doing this right? I've read that the GetKeyValues() func has been broken in the past, but that was a couple years ago. I'm currently assuming that it is not broken, and I'm just doing something silly wrong, so I'm asking you guys. I have on my map four spawns which will act as respawn points. I have a key value set to them as so; [IMG]http://i247.photobucket.com/albums/gg122/shinji144/ktownzoneinfoplayerstart_zpscd1c379f.jpg[/IMG] But when I access this in lua at all, it returns nil. ent 95 IS in fact a spawn with this keyvalue set in hammer. [CODE]local Zone_Keldrin = ents.GetByIndex(95) print(tostring(Zone_Keldrin:GetKeyValues().zonespawn))[/CODE]
Is there a special way you're supposed to reset the view model animation on a SWEP? I'm just using [lua]self:SendWeaponAnim( ACT_VM_HITCENTER )[/lua] In PrimaryAttack, the animation plays fine for the first attack, but doesn't do anything in any subsequent attack. If I change to another weapon and back again, it works again for one attack. Edit: to anyone who comes across this in the future, you have to call self:SetNextPrimaryFire/self:SetNextSecondaryFire, that fixes it
[QUOTE=Banana Lord.;38911544]@brandonj4 call StripWeapons on a player, GetActiveWeapon is nil also when they are dead[/QUOTE] I was assuming that it was the GetActiveWeapon().Primary.ClipSize(HL2 Weapons) or the MaxAmmo Table MaxAmmo[client:GetActiveWeapon():GetClass()] doesn't have the weapon class. This is from a really old and shitty hud script anyway.
Also, is there a way to make a trace ignore all entities? I just want it to run from one position to another and only stop if it hits the world. I'm guessing setting trace.filter to ents.GetAll() isn't a good way to go about it? [editline]20th December 2012[/editline] Aha, trace.mask is what I was looking for
Does anyone know how to get rid of the ammo notifications that you get from picking up ammo or ply:GiveAmmo(n, "type") ? edit: GM:HUDAmmoPickedUp hurr
[QUOTE=Minteh Fresh;38904483]I'm attempting to make an effect or partical whatever you guys call it follow my character around for a sort of "aura" .. Well pretty much an aura, but I'm totally clueless in the Emitting area.. Anybody willing to help a poor old silly Australian? Haha![/QUOTE] Nobody willing to help? -- EDIT -- Helped by my pal' ol' buddy Impulse! Thanks!
[QUOTE=Hyper Iguana;38912704]Does anyone know how to get rid of the ammo notifications that you get from picking up ammo or ply:GiveAmmo(n, "type") ? edit: GM:HUDAmmoPickedUp hurr[/QUOTE] Instead of overwriting that, ply:GiveAmmo(n, "type", true) [url=http://wiki.garrysmod.com/page/Classes/Player/GiveAmmo]GiveAmmo[/url] has an optional third arg to disable it.
Does anyone know how to draw .png's onto your screen? I remember I used to be able to draw .png's on the screen, but I can't find the method I used
[QUOTE=Hyper Iguana;38914802]Does anyone know how to draw .png's onto your screen? I remember I used to be able to draw .png's on the screen, but I can't find the method I used[/QUOTE] [lua] local mat = Material( "whatever.png" ) -- outside paint/draw function ... -- inside paint/draw function surface.SetMaterial( mat ) surface.DrawTexturedRect( x, y, w, h ) [/lua]
Do particle effects still require you to reload your game?
How do I write a file inside my gamemodes folder? Ex: MyGamemodeName/gamemode/data/file.txt Only ways I can find are inside the data folder or in the base gmod folder.
[QUOTE=brandonj4;38918905]How do I write a file inside my gamemodes folder? Ex: MyGamemodeName/gamemode/data/file.txt Only ways I can find are inside the data folder or in the base gmod folder.[/QUOTE] You're only allowed to write files into the data folder.
[QUOTE=Trumple;38891791][lua] (signed) integers use the first bit to signify +ve or -ve unsigned integers can therefore use the extra bit to signify a larger number, since they are always positive So on a 32 bit system, we have integers ranging from –2,147,483,648 to 2,147,483,647 (normal) and unsigned integers from 0 to 4,294,967,295 As you can see, both have the same size (32 bits) but can represent different ranges. As for getting the size of the integer... if you know you're dealing with small integers, such as 1 through 4 for example, you could get away with putting a size of 3 bits. This is purely for the sake of efficiency. If you have no idea what size, you can use 32, which would give you the range of the usigned integer above. It would be inefficient though, and I'd suggest looking into some sensible value ranges. If you're super keen, you could try detecting the size in bits of a number in Lua. To do that you could convert to binary using a fairly simple method, then convert that to a string and count how many elements in that string (representing the number of bits you need to send i.e the size argument)[/QUOTE] I know it will sound as a dumb excuse but that's exactly what I ment. And by range I ment that the unsigned numbers provide the same amount of different numbers, if you get what I'm trying to say.
My main helper has been banned, for [URL="http://facepunch.com/showthread.php?t=1232367&p=38921445#post38921445"]Yaweih(YHWH)[/URL] knows how long, but I still need help on this Swep. I can't get the projectiles to remove themselves without getting errors.
So do you have the code for it?
Yes, I do... Go to [URL="http://facepunch.com/showthread.php?t=1232367"]page one[/URL], and it should be there. I would also like model help, however. I want the creatures/enemies for SMB to be animated, and I would like the castles. I have threads for both, though, [URL="http://facepunch.com/showthread.php?t=1234376&p=38923343#post38923343"]such as this one[/URL].
[QUOTE=_Undefined;38918923]You're only allowed to write files into the data folder.[/QUOTE] Wasn't there a module in gmod 12 that allowed you to write files in other directories?
[QUOTE=Stiveno;38836086]I cant seem to get my code to spawn entities automatically working correctly. For some reason, it spawns all the entities twice in the same spot. Any ideas? [URL="http://pastebin.com/n3SWuakr"]sv_entstartup.lua[/URL] [URL="http://pastebin.com/yk61SX8s"]Map file[/URL][/QUOTE] Reposting this because I still have not had any luck, if anybody knows, or knows of a better way to spawn them id appreciate it.
[QUOTE=Drakehawke;38914834][lua] local mat = Material( "whatever.png" ) -- outside paint/draw function ... -- inside paint/draw function surface.SetMaterial( mat ) surface.DrawTexturedRect( x, y, w, h ) [/lua][/QUOTE] How to bind that to a derma scoreboard?
-snip-
I published an SWEP I made to the workshop, but for some people it's not showing up in the weapons place so they can't spawn it. I used the SWEP maker to create the script, so should I make a new one?
[QUOTE=Donkie;38904740]How is Entity:WorldToLocal( pos ) and Entity:LocalToWorld( pos ) calculated?[/QUOTE] This is how LocalToWorld is calculated: [lua] function ENT:LocalToWorld(Vec) local Pos = self:GetPos() local EntityForward = self:GetForward() local EntityRight = self:GetRight() local EntityUp = self:GetUp() return Pos+(EntityForward*Vec.x)+(EntityRight*Vec.y)+(EntityUp*Vec.z) end [/lua] And This is how WorldToLocal is calculated: [lua] function ENT:WorldToLocal(Vec1) local Pos = self:GetPos() local EntityForward = self:GetForward() local EntityRight = self:GetRight() local EntityUp = self:GetUp() local Vec2 = Vec1-Pos -- F.x*R.y*U.z+F.y*U.x+F.z*R.x*U.y-F.z*R.y*U.x-F.y*R.x*U.z-F.x*R.z*U.y = Rule of Sarrus. local Forward = -(Vec2.x*EntityRight.y*EntityUp.z+Vec2.y*EntityRight.z*EntityUp.x+Vec2.z*EntityRight.x*EntityUp.y-Vec2.z*EntityRight.y*EntityUp.x-Vec2.y*EntityRight.x*EntityUp.z-Vec2.x*EntityRight.z*EntityUp.y) local Right = (EntityForward.x*Vec2.y*EntityUp.z+EntityForward.y*Vec2.z*EntityUp.x+EntityForward.z*Vec2.x*EntityUp.y-EntityForward.z*Vec2.y*EntityUp.x-EntityForward.y*Vec2.x*EntityUp.z-EntityForward.x*Vec2.z*EntityUp.y) local Up = -(EntityForward.x*EntityRight.y*Vec2.z+EntityForward.y*EntityRight.z*Vec2.x+EntityForward.z*EntityRight.x*Vec2.y-EntityForward.z*EntityRight.y*Vec2.x-EntityForward.y*EntityRight.x*Vec2.z-EntityForward.x*EntityRight.z*Vec2.y) return Vector(Forward,Right,Up) end [/lua]
I can't find the swep I uploaded to the workshop in game. I installed it but it's not in the "weapons" section. Please help!
Fuck, none of you are going to help me... are you?? >_< I have two threads, this is the most recent. [URL="http://facepunch.com/showthread.php?t=1232897"]I want help!!![/URL] [editline]Dec 12 2012[/editline] Yeah, I expected the dumb rating. But seriously, I've posted this many times, and the only helper I got has been banned!
Does anyone know any good SWEP tutorials? Thanks
I can get you one, but I'd need help from an experienced LUA programmer first, on the link above.
Sorry, you need to Log In to post a reply to this thread.