Forum

> > CS2D > Scripts > the weapons disappear when you die
Forums overviewCS2D overview Scripts overviewLog in to reply

English the weapons disappear when you die

3 replies
To the start Previous 1 Next To the start

old the weapons disappear when you die

jerezinho
User Off Offline

Quote
Hi everyone. can someone help me with this please?

I have a problem with this lua, when they kill me and I use the spawnplayer function, the things the player has disappears...

the weapons that the player who was murdered have disappeared and they do not drop.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
UTSFX=true

addhook("kill","_killer")
function _killer(killer,victim,x,y)
if UTSFX==true then
local clr
		if player(killer,"team") == 0 then -- t
			clr = "©255220000" -- t
		elseif player(killer,"team") == 1 then -- t
			clr = "©255025000" -- t
		elseif player(killer,"team") == 2 then -- ct
			clr = "©050150255" -- ct
end	
			parse("killplayer "..killer)
			msg(clr..player(killer,"name").."©255220000 YOU CAN'T KILL ANYONE NOW! TRY IN NIGHT!")
local x,y = player(victim,'x'),player(victim,'y')
parse('spawnplayer '..victim..' '..x..' '..y)
end
end
edited 1×, last 23.10.18 10:03:10 am

old Re: the weapons disappear when you die

GeoB99
Moderator Off Offline

Quote
Instead of cs2d lua hook kill, use the cs2d lua hook die hook to allow the killed player having the items dropped. Just make sure that the source of the death was actually caused by a player and not by a different entity. Such as in this code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
UTSFX = true

function DropOnDeath(victim, killer, weapon, x, y, kobj)
  if (UTSFX == true) then
    local clr
    
    if (killer > 0) then -- Sanity check!
      -- Code here
    end
  end
  
  return 0 -- Drop the items, normally
end

addhook('die', 'DropOnDeath')
So that you can easily implement the rest of your code in a proper way without breaking things.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview