Bloodprime's Question Thread

Hey, I’m in the process of scripting my own simple gamemode, and along the way I’ve run into a few problems. Here is where I will post my problems and ask for help! I’ve decided to make this a thread because I’m going to have more than one question and I don’t want to fill this forum with my questions.

Thanks for your help!

No current questions

question 1 : the function shouldn’t be local , try removing that and then tell us what happens.

question 2 : [lua]
myImage = vgui.Create(“DImage”, myParent) myImage:SetImage( “VGUI/entities/npc_antlion” ) myImage:SizeToContents() // make the control the same size as the image.
[/lua]

example taken from gmod wiki : http://wiki.garrysmod.com/?title=DImage

Question One: You are already hooking the function you can’t add a console command to it after and I don’t see why you would want to

Question Two: You need to convert the textures to VTF’s and then to make it fade change lower the alpha of it

Could i get the altered code for Q1? I tried doing both of your recommendations but neither worked. I assume I’m doing them wrong.

[lua]local ShouldDropWeapon = true

local function PlayerDropWeapon(ply)

if ply:GetActiveWeapon():IsValid()) then
ply:DropWeapon(ply:GetActiveWeapon()) --Drop active weapon
end

end
hook.Add(“DoPlayerDeath”, “Player.DropWeapon”, PlayerDropWeapon)
[/lua]

You don’t need the console command this is called on player death

What key do i press to drop my weapon then?

Also, my revolver and crowbar do not drop on death.

That code only drops your active weapon and if you want to drop it on key-press then you will need another function

It doesn’t even drop my active weapon D=

We would need to see the source of the DropWeapon function

That’s the whole code, but i removed the admin toggle bit and was left with: http://pastebin.com/8ZjEEexf

I was following this tutorial: http://wiki.garrysmod.com/?title=LUA:Gamemode_Features

Well you either need to use a hook on it or a console command like I said not both

I only have a hook here: http://pastebin.com/8ZjEEexf , don’t I?

Are you sure its being run serverside? and AFAIK you wont have an ActiveWeapon when that hook is called since your already dead

“The player is still alive when this hook is ran.” - http://wiki.garrysmod.com/?title=Gamemode.PlayerDeath

Also, that’s probably the problem. I put the script in cl_wepdrop.lua, and included it on clientside. OOPSIES! Classic noob ^.^

I’ll rewrite it tomorrow. Ty!

–Update-- New question!