Author Topic: Lua  (Read 3778 times)

Offline FuriousJack95

  • VIP
  • *
  • Posts: 131
    • View Profile
    • Awards
Lua
« on: June 02, 2011, 07:51:27 PM »
Trying to code something so that if a player headshots someone it plays a sound on the player and the victim and anyone near them from a list

Offline Hopsin

  • *
  • Posts: 101
    • View Profile
    • Awards
Re: Lua
« Reply #1 on: June 03, 2011, 05:32:32 PM »
what are you making this sound file for ?

Offline FuriousJack95

  • VIP
  • *
  • Posts: 131
    • View Profile
    • Awards
Re: Lua
« Reply #2 on: June 04, 2011, 03:48:40 PM »
what are you making this sound file for ?
Trolling
So when someone gets a headshot it goes R U ON TEH BALL?
or FUCKIN LAG U PISASHIT

Offline knoxed

  • #YOLO
  • Gold Member
  • *
  • Posts: 164
  • Awards [OCRP Award] Secret Phrase [OCRP Award] Social Player [OCRP Award] Junkie [OCRP Award] Owner Party
    • View Profile
    • Awards
Re: Lua
« Reply #3 on: June 04, 2011, 04:00:30 PM »
Google

Offline JoshB

  • *
  • Posts: 359
    • View Profile
    • Awards
Re: Lua
« Reply #4 on: June 12, 2011, 12:04:45 PM »
Code: [Select]
function Headshot(ply, hitgroup, dmginfo)

if ply:Health() > dmginfo:GetDamage() then

if hitgroup == HITGROUP_HEAD then
ply:EmitSound(table.Random({pathtosound.wav, pathtosound.wav, pathtosound.wav}), 100, 100)

end

end

end

hook.Add("ScalePlayerDamage", "HeadshotStuff", Headshot)
pathtosound is the sound relative to the 'sound' directory.
Might not work. I don't know if checking the player's health on scaleplayerdamage will return their health before or after the damage is added.
[CG-SA]Toy4x4funrun: When guns are involved RP = basicly void
lolwut?

Offline Its Max Blad

  • I'M SO CREATIVE THAT THIS IS THE BEST TITLE I COULD COME UP WITH Thx Carb!ne bff
  • Gold Member
  • *
  • Posts: 281
  • Awards [OCRP Award] Secret Phrase [OCRP Award] Social Player [OCRP Award] Owner Party [GMR2 Award] City Circuit Record
    • View Profile
    • Awards
Re: Lua
« Reply #5 on: June 12, 2011, 01:28:42 PM »
Code: [Select]
function BOOMHeadShot( victim, attacker, dmginfo )
if victim:LastHitGroup() == 1 then
victim:EmitSound(table.Random({pathtosound.wav, pathtosound.wav, pathtosound.wav}), 100, 100)
end
end
hook.Add( "DoPlayerDeath", "HeadShot", BOOMHeadShot )


I couldnt be bothered to rewrite the sound playing aswell, so I stole it from JoshB as it looked fine, so "ply:EmitSound(table.Random({pathtosound.wav, pathtosound.wav, pathtosound.wav}), 100, 100)" should be credited to him, me the rest :)
Code: [Select]
[center][b]~ Locked (HH:MM GMT - DD/MM/2012) - Its Max Blad ~[/b][/center]
[center][b]~ Moved, [i]Board[/i] to [i]Board[/i] (HH:MM GMT - DD/MM/2012) - Its Max Blad ~[/b][/center]
[center][b]~ Locked & Moved (HH:MM GMT - DD/MM/2012) - Its Max Blad ~[/b][/center]
Code: [Select]
[left][color=red][b]Player Warning: #%
(HH:MM GMT - DD/MM/2012)

<Reason>

~ Its Max Blad[/b][/color][/left]

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal