Results 1 to 7 of 7
  1. #1
    bloodstain97's Avatar
    Join Date
    Oct 2015
    Gender
    male
    Posts
    8
    Reputation
    10
    Thanks
    0

    Question killmarker not hitmarker [LUA]

    i used game listen entity_killed didnt solve the problem im new on this can you guys do this for me please i just wanted to see

  2. #2
    guessjoe1's Avatar
    Join Date
    Aug 2014
    Gender
    male
    Posts
    58
    Reputation
    10
    Thanks
    4
    My Mood
    Bored
    Code:
    local drawkilltime = 0
    gameevent.Listen("entity_killed") --We want to listen to the event if any entities die.
    hook.Add("entity_killed", "killmarker",function(data)
    	local victim = Entity(data.entindex_killed)
    	local attacker = Entity(data.entindex_attacker)
    	if !IsValid(victim) || !IsValid(attacker) then return end --Always check if they entities are there.
    	if attacker == LocalPlayer() && victim:IsPlayer() then 
    		drawkilltime = CurTime()+1 --Draw the marker for 1 second
    	end
    end)
    
    hook.Add("HUDPaint", "DrawKillmarker",function())
    	if drawkilltime >= CurTime() then
    		--Draw killmarker here
    	end
    end
    Last edited by guessjoe1; 08-18-2019 at 06:50 AM. Reason: forgot to add if victim is player

  3. #3
    bloodstain97's Avatar
    Join Date
    Oct 2015
    Gender
    male
    Posts
    8
    Reputation
    10
    Thanks
    0
    thanks that was very usefull for me

  4. #4
    bloodstain97's Avatar
    Join Date
    Oct 2015
    Gender
    male
    Posts
    8
    Reputation
    10
    Thanks
    0
    im trying to add this line but i fail everytime can you help

    Code:
            sound.PlayFile("killmarker.wav", "mono", function()

  5. #5
    guessjoe1's Avatar
    Join Date
    Aug 2014
    Gender
    male
    Posts
    58
    Reputation
    10
    Thanks
    4
    My Mood
    Bored
    Quote Originally Posted by bloodstain97 View Post
    im trying to add this line but i fail everytime can you help

    Code:
            sound.PlayFile("killmarker.wav", "mono", function()
    Code:
    sound.PlayFile( "killmarker.wav", "", function( station )
    	if ( IsValid( station ) ) then station:Play() end --Check if the sound exists and can play if not don't do anything.
    end )

  6. #6
    bloodstain97's Avatar
    Join Date
    Oct 2015
    Gender
    male
    Posts
    8
    Reputation
    10
    Thanks
    0
    thanks but im trying to tell when i kill player killmarker.wav play


    edit: oh ok

    Code:
    surface.PlaySound("killmarker.wav")

    i add this and problem solved
    Last edited by bloodstain97; 08-19-2019 at 10:13 PM.

  7. #7
    Oskarr123's Avatar
    Join Date
    Aug 2019
    Gender
    male
    Posts
    0
    Reputation
    10
    Thanks
    12
    Thanks guessjoe1. I normally code in C, but i am getting into .lua now.

Similar Threads

  1. Couldn't include file 'AXpublic.lua' (File not found) (<nowhere>)
    By pizzadk in forum Garry's Mod Discussions & Help
    Replies: 4
    Last Post: 09-16-2013, 06:18 AM
  2. Lua not working for me?
    By DanVs in forum Garry's Mod Discussions & Help
    Replies: 18
    Last Post: 09-11-2013, 08:52 AM
  3. Lua running not working?
    By colbol99 in forum Garry's Mod Discussions & Help
    Replies: 1
    Last Post: 06-28-2013, 08:31 AM
  4. Lua scripts not opening
    By GokusDog in forum Garry's Mod Discussions & Help
    Replies: 4
    Last Post: 06-07-2013, 12:16 PM
  5. my killmarks not working ;(
    By rdblade in forum CrossFire Mods & Rez Modding
    Replies: 3
    Last Post: 09-12-2010, 03:48 PM