[QUOTE=Persious;35970880]I made a function which should allow me to set model of a player depending on his team:
[lua]
function AddTeam(ID, Name, Model, Loadout, Salary, Color)
table.insert(Teams, {ID = ID, Name = Name, Model = Model, Loadout = Loadout, Salary = Salary, Color = Color})
end
[/lua]
And to return the model I've tried a lot, but never got it working:
[lua]
function GM:PlayerSetModel(pl)
pl:SetModel(Teams[(pl:Team().Model)])
end
[/lua]
This thing gives me
[gamemodes\Testing\gamemode\server\player.lua:3] attempt to index a number value(Hook: PlayerSetModel)[/QUOTE]
Could I use this for my project by any chance?
Exactly what I'm looking for :\
Just begging to use E2 and I have ran into an issue.
I am making a teleport chip that goes with the Asgard teleporter. It works fine however I want to be able to cycle through multiple targets so I can teleport to multiple locations. I have set up a value which increments when numpad 1 or 2 are pressed but it increments very fast which leads to the number becoming way too high. I was wondering if someone could help me make an increment system that only goes up by a single digit when the numpad key is pressed and waits until it is pressed again before it moves up or down.
Here is the code I have on this chip so far
[Lua]@name
@inputs Up Down
@outputs X Y Z C
@persist Target:entity A
@trigger all
if (Up){A++}
if (Down) {A--}
C = A
interval(10)
findByModel("models/props_lab/powerbox02d.mdl")
Target = findResult(A)
Location = Target:pos()
X = Location:x()
Y = Location:y()
Z = Location:z()[/Lua]
The C variable is just so I could check how much it was incrementing by. As I said I am very new to this.
[QUOTE=Rombishead;36013730]Just begging to use E2 and I have ran into an issue.
I am making a teleport chip that goes with the Asgard teleporter. It works fine however I want to be able to cycle through multiple targets so I can teleport to multiple locations. I have set up a value which increments when numpad 1 or 2 are pressed but it increments very fast which leads to the number becoming way too high. I was wondering if someone could help me make an increment system that only goes up by a single digit when the numpad key is pressed and waits until it is pressed again before it moves up or down.
Here is the code I have on this chip so far
[Lua]@name
@inputs Up Down
@outputs X Y Z C
@persist Target:entity A
@trigger all
if (Up){A++}
if (Down) {A--}
C = A
interval(10)
findByModel("models/props_lab/powerbox02d.mdl")
Target = findResult(A)
Location = Target:pos()
X = Location:x()
Y = Location:y()
Z = Location:z()[/Lua]
The C variable is just so I could check how much it was incrementing by. As I said I am very new to this.[/QUOTE]
Totally the wrong place to ask for help, but change your ifs to [I]if (~Input & Input) {[/I].
~ checks if the input triggered this current run.
Do you need an interval?
I'm sorry for posting in the wrong place, is there a part of this forum I should have posted it at?
The "~" worked very well, except it incremented when the key went down and when I let go of the key again. So each press added 2 digits.
I have a question about a little bit of a weapon script I was working on.
[CODE]function SWEP:Think()
if self.Owner:KeyDown(IN_USE) then
if self.Owner:KeyPressed(IN_ATTACK2) then
self.data = "burstmode"
self.data.burstmode = true
end
end
if self.Owner:KeyDown(IN_USE) then
if self.Owner:KeyPressed(IN_ATTACK2) then
self.data = "burstmode"
self.data.burstmode = false
end
end
end[/CODE]
I'd like to change between two different firing modes, they are defined under the primary fire function as two sets of variables for CSShootBullet.
[CODE]function SWEP:PrimaryAttack()
if ( !self:CanPrimaryAttack() ) then return -- no ammo? play a locking sound or something like that.
self.Weapon:EmitSound( "buttons/button2.wav" )
end
if self.mode = "off" then
-- don't even need a condition; starting mode
self.Weapon:EmitSound("Weapon_m249.Single", 100, 100)
self:CSShootBullet( 10, 0.24, 1, 0.068 )
self:TakePrimaryAmmo( 1 )
self.Owner:ViewPunch( Angle(math.random(-0.3, -0.03)))
self.Weapon:SetNextPrimaryFire( CurTime() + 0.12 )
end
if self.mode = "on" then -- augmented burst fire, lower damage, but more shots.
self.Weapon:EmitSound("Weapon_tmp.Single", 100, 100) -- stand-in sounds, make better ones later.
self:CSShootBullet( 2, 0.1, 4, 0.09 )
self:TakePrimaryAmmo( 1 ) -- like adjusting the energy setting, blah blah future whoosh. wowy zowy.
self.Owner:ViewPunch( Angle(math.random(-0.1, 0.001)))
self.Weapons:SetNextPrimaryFire( CurTime() + 0.08 ) -- faster fire rate.
end
local muzzle = EffectData( muzzleattachment ) -- I don't think it's possible to have different muzzleflashes.
muzzle:SetEntity(self.Weapon)
muzzle:SetOrigin(self.Owner:GetShootPos())
muzzle:SetNormal(self.Owner:GetAimVector())
muzzle:SetAttachment(1)
util.Effect("ChopperMuzzleflash",muzzle)
if ((SinglePlayer() and SERVER) or CLIENT) then
self.Weapon:SetNetworkedFloat("LastShootTime", CurTime())
end
end[/CODE]
Not really sure what's wrong, I've never used data type coding before, if anyone could help it would be just amazing.
Thanks
(I've used HTTrack to download [nearly] the entire gmod wiki for study offline... it sucks.)
[QUOTE=Rombishead;36013801]I'm sorry for posting in the wrong place, is there a part of this forum I should have posted it at?
The "~" worked very well, except it incremented when the key went down and when I let go of the key again. So each press added 2 digits.[/QUOTE]
Try the wiremod.com forums, or possibly Garry's Mod Discussion.
I did say ~A & A, since you have to check if it is both the triggerer and 1, since it triggers when it goes back to 0 as well.
[QUOTE=Chessnut;35325881]All of the indexes aren't part of a table. It should be:
local myTable = {};
myTable[1] = "Hello";
myTable[2] = "World";
myTable[3] = "stuff.";
And so on.[/QUOTE]
that helped, it's still giving me some problems, but probably cause I'm tired.
Can anyone give me a link or suggestion to disable key inputs(I want to disable the players ability to move left, right, up, down (wasd while in the air using IsOnGround())
I'm not looking for Freeze() or Lock().
You could try returning true in the Move hook. This overrides any movement.
[lua]
function GM:Move( ply, mv )
if( not ply:IsOnGround() and ply:KeyDown( IN_MOVELEFT | IN_MOVERIGHT | IN_FORWARD | IN_BACK ) ) then
return true
end
end[/lua]
If that doesn't work just change the ply:KeyDown( IN_MOVELEFT | IN_MO... ) to if( ply:KeyDown( IN_MOVELEFT ) or ply:KeyDown( IN_MOVERIGHT ) .. and so on.
[QUOTE=whitespace;36018137]You could try returning true in the Move hook. This overrides any movement.
[lua]
function GM:Move( ply, mv )
if( not ply:IsOnGround() and ply:KeyDown( IN_MOVELEFT | IN_MOVERIGHT | IN_FORWARD | IN_BACK ) ) then
return true
end
end[/lua]
If that doesn't work just change the ply:KeyDown( IN_MOVELEFT | IN_MO... ) to if( ply:KeyDown( IN_MOVELEFT ) or ply:KeyDown( IN_MOVERIGHT ) .. and so on.[/QUOTE]
Thank you, I forgot about that hook
Hi, I need code that shows weapon which was used to kill player X. Something like this: "[B]Player X was killed with AK-47 by Player Y[/B]". Any ideas?
[lua]
hook.Add("PlayerDeath", "LogKills", function(victim, inflictor, attacker, ply)
if attacker:IsPlayer() then
inflictor = inflictor:GetActiveWeapon()
end
if attacker:IsPlayer() then
T = Format("%s killed %s using %s", victim:Name(), attacker:Name(), inflictor:GetClass() )
end
for _, v in pairs(player.GetAll()) do
v:ChatPrint(T)
end
end)
[/lua]
Old ass code which I just found on my computer.
Is it possible if I do have like 4 DCollapsiveCategory and whenever I open one of them, the other ones close?
[QUOTE=Persious;36022222]Is it possible if I do have like 4 DCollapsiveCategory and whenever I open one of them, the other ones close?[/QUOTE]
[url]http://www.luabin.com/browse/?path=/lua/vgui/DCategoryCollapse.lua[/url]
It looks like SetExpanded and Toggle might be what you want
I tried SetExpanded, and it only opens the category when the menu opens.
You're right, SetExpanded didn't work in my test but Toggle did
Hm, how do you use Toggle? I tried doing Collapsive:Toggle() and it returned some kind of error.
Here's my code that worked, hope it's correct
[url]http://pastebin.com/MmW68Upg[/url]
Hm, I see what you mean. But I don't have any buttons directing to ex. a category, but as soon as I press the Category itself, it will only toggle, and all the other categories will close.
I simply don't know where to use the "Toggle"
This is my menu:
[IMG]http://desmond.imageshack.us/Himg20/scaled.php?server=20&filename=asdqj.png&res=landing[/IMG]
When you create the categories, put them into a table. And when you click on one, loop through the table of categories (and if the current category isn't the one you just clicked on) Check if its open, if it is then use Toggle()
I think
[QUOTE=ArmageddonScr;36023351]When you create the categories, put them into a table. And when you click on one, loop through the table of categories (and if the current category isn't the one you just clicked on) Check if its open, if it is then use Toggle()
I think[/QUOTE]
Ah, I can try that.
I was just wondering if there was any code (to go in a SWEP's shared.lua file) that would enable a check for an npc's model and maybe the current animation that said npc/model was playing? Like (hypothetically): If self.Owner:IsNPC() and self.npcmodel (this is what i'm asking about) = combineelite.mdl and self.npcanimation = act_run (also wondering what this check would actually be) then().
Sorry for the drawn-out explanation, but any help would be appreciated.
[lua]
if self.Owner:IsNPC() and self.Owner:GetModel() == "combineelitewhatever.mdl" and self.Owner:GetActivity() == ACT_RUN then
dostuff
end
[/lua]
Not sure if this is correct or not, just came off the top of my head.
-snip- (12 hours late)
I believe this is possible and people have been saying it's impossible but I want to make a spot light using only the clientside.
I'm aware of env_projectedtexture, but I want to have a similar effect with a spotlight using only the clientside...
How can I save Persistent data in the form of a table? Can't seem to get it to work.
You cant use PData with tables, but you can use glon.decode and glon.encode, TableToKeyValues or KeyValuesToTable along with file.Read/Write
I'm drawing a mesh with [b][url=http://wiki.garrysmod.com/?title=IMesh.Draw]IMesh.Draw [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] and trying to set it's color with render.SetColorModulation(), but the color doesn't change at all. I'm using it in the exact same way as I color another model, so I know I'm using it right. Is there another (proper) way to color an IMesh?
I need help with "Entity:Set" how would i make it set HEV suit power i have tryed Entity:Setarmor / suit but cannot figure it out
Sorry, you need to Log In to post a reply to this thread.