Hello. My goal is to create a working HEV suit for use in a SENT pack I'm making.
I have a SENT (it's a physical object) such that when you press E on it, it removes itself and sets a networked boolean value on you called "hassuit" to TRUE.
Problem is, where does the scripting go to make the networkedbool have any consequence?? I can't put it in the suit sent's code because that gets removed once the player picks it up.
I want any player wearing an HEV suit (his "hassuit" variable is 1) to have a special set of attributes and whatnot. Where does the code go for this? Does anyone have an idea of how this should be structured?
[url]http://www.facepunch.com/threads/1038820-Me-and-Seth[/url]
that should help
[highlight](User was banned for this post ("Not helpful" - PLing))[/highlight]
[QUOTE=Godlike2;26748622][url]http://www.facepunch.com/threads/1038820-Me-and-Seth[/url]
that should help[/QUOTE]
Any admins in here?
[b][url=wiki.garrysmod.com/?title=Gamemode.Think]Gamemode.Think [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
[lua]
function CheckForHIV()
for k, v in pairs( players.GetAll() ) do
if( v:getbool ) then
v:dressup();
end
end
end
hook.Add("Think", "HIVCheck", CheckForHIV)
[/lua]
None optimized, random functions and all but it's a start.
Cool..thanks!
So, this can go anywhere because it's hooked to the game's "think" event, so it will always execute?
It should be placed in a serverside file.
[QUOTE=Skuch;26748786][b][url=wiki.garrysmod.com/?title=Gamemode.Think]Gamemode.Think [img_thumb]http://wiki.garrysmod.com/favicon.ico[/img_thumb][/url][/b]
[lua]
function CheckForHIV()
for k, v in pairs( players.GetAll() ) do
if( v:getbool ) then
v:dressup();
end
end
end
hook.Add("Think", "HIVCheck", CheckForHIV)
[/lua]
None optimized, random functions and all but it's a start.[/QUOTE]
:what:
Actually, wouldn't it be better to hook stuff like the damage hooks etc, and do the modifications there?
You will have troubles with the hev sounds in the future,MANY troubles.
Since i just found my old garrysmod.org account,you can rip my old addon apart to get sounds to work clientside.
This is not the complete hev suit pack,this is just an old addon that lets you hear the hev suit messages.
[url=http://www.garrysmod.org/downloads/?a=view&id=91357][img]http://www.garrysmod.org/img/?t=dll&id=91357[/img][/url]
I use the scaleplayerdamagewhatever hook serverside and then send an usermessage to the client telling him which hev suit message to play.
Serverside sounds are laggy,clientside is better.
Awesome. It worked, all except for the damage scaling. I put this in my suit's init file, but it doesn't seem to work...
By the way, thanks for the HEV sounds! I'll be sure to implement them :D
[lua]
function ScaleDamage(ply,hitgroup,dmginfo)
if(ply:GetNetworkedBool("hassuit"))then
if(hitgroup==HITGROUP_HEAD)then dmginfo:ScaleDamage(0.1) end
if(hitgroup==HITGROUP_CHEST)then dmginfo:ScaleDamage(0.1) end
if(hitgroup==HITGROUP_STOMACH)then dmginfo:ScaleDamage(0.1) end
if(hitgroup==HITGROUP_LEFTARM)then dmginfo:ScaleDamage(0.1) end
if(hitgroup==HITGROUP_RIGHTARM)then dmginfo:ScaleDamage(0.1) end
if(hitgroup==HITGROUP_LEFTLEG)then dmginfo:ScaleDamage(0.1) end
if(hitgroup==HITGROUP_RIGHTLEG)then dmginfo:ScaleDamage(0.1) end
if(hitgroup==HITGROUP_GEAR)then dmginfo:ScaleDamage(0.1) end
if(hitgroup==HITGROUP_GENERIC)then dmginfo:ScaleDamage(0.1) end
end
end
hook.Add("ScalePlayerDamage","ScaleDamage",ScaleDamage)
[/lua]
Anyone know what's wrong?
One more thing, anyone know a simple way to tint a player's view?
I want everything to get a little darker when you put the suit on (as if you're looking through a visor).
And another thing (lol sorry), would it be simple to make this compatible with life support? I don't want it to be complicated, all I want it to do is for it to interfere with the "drowning" that LS introduces back into gmod. I looked at LS's code and I can't figure out how to prevent players wearing the suit from drowning (without modifying LS's code).
[QUOTE=Jackarunda;26759951]Awesome. It worked, all except for the damage scaling. I put this in my suit's init file, but it doesn't seem to work...
By the way, thanks for the HEV sounds! I'll be sure to implement them :D
[lua]
function ScaleDamage(ply,hitgroup,dmginfo)
if(ply:GetNetworkedBool("hassuit"))then
if(hitgroup==HITGROUP_HEAD)then dmginfo:ScaleDamage(0.1) end
if(hitgroup==HITGROUP_CHEST)then dmginfo:ScaleDamage(0.1) end
if(hitgroup==HITGROUP_STOMACH)then dmginfo:ScaleDamage(0.1) end
if(hitgroup==HITGROUP_LEFTARM)then dmginfo:ScaleDamage(0.1) end
if(hitgroup==HITGROUP_RIGHTARM)then dmginfo:ScaleDamage(0.1) end
if(hitgroup==HITGROUP_LEFTLEG)then dmginfo:ScaleDamage(0.1) end
if(hitgroup==HITGROUP_RIGHTLEG)then dmginfo:ScaleDamage(0.1) end
if(hitgroup==HITGROUP_GEAR)then dmginfo:ScaleDamage(0.1) end
if(hitgroup==HITGROUP_GENERIC)then dmginfo:ScaleDamage(0.1) end
end
end
hook.Add("ScalePlayerDamage","ScaleDamage",ScaleDamage)
[/lua]
Anyone know what's wrong?
One more thing, anyone know a simple way to tint a player's view?
I want everything to get a little darker when you put the suit on (as if you're looking through a visor).
And another thing (lol sorry), would it be simple to make this compatible with life support? I don't want it to be complicated, all I want it to do is for it to interfere with the "drowning" that LS introduces back into gmod. I looked at LS's code and I can't figure out how to prevent players wearing the suit from drowning (without modifying LS's code).[/QUOTE]
I'm not that good at Lua coding, but are you forgetting alot of spaces? ( if(hitgroup, blah)then )
The only way to stop drowning is by modifying Ls's code or by overwriting the player's ls variables stored somewhere in the player's table ex. ply.ls.suit or something like that
Sorry, you need to Log In to post a reply to this thread.