Forum

> > CS2D > Scripts > Sethealth doesn't seem to work after spawnplayer!
Forums overviewCS2D overview Scripts overviewLog in to reply

English Sethealth doesn't seem to work after spawnplayer!

2 replies
To the start Previous 1 Next To the start

old Sethealth doesn't seem to work after spawnplayer!

aleksix
User Off Offline

Quote
Well, I'm trying to make a fake death script.
So you will become invincible and can kill your killer(1 hit knife).
1
2
3
4
5
6
7
8
9
10
11
if (canfake[id]==true) then
	if (killer>=1) then
		parse("customkill "..killer.." \""..weaponname[w].."\" "..victim)
	end
	timer(1,"parse","spawnplayer "..victim.." "..player(victim,"x").." "..player(victim,"y")	
	parse("sethealth "..victim.." 10")
	parse("setweapon "..victim.." 50")
	parse("setarmor "..victim.." 206")
	isfake[id]=true
	canfake[id]=false
end

Everything works fine,but "sethealth" doesn't work!

old Re: Sethealth doesn't seem to work after spawnplayer!

TimeQuesT
User Off Offline

Quote
the command timer, executes the given function as thread. Depending on your cpu speed the next few commands can be skipped (Actually it gets executed, but it's not going to apply on a dead player) . In your case, 'sethealth'

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function xyz(...)
    if (canfake[id]==true) then
     if (killer>=1) then
          parse("customkill "..killer.." \""..weaponname[w].."\" "..victim)
     end
    timer(1,"vGhostRevive", victim, 1);
      end
end



function vGhostRevive(id)
     victim = tonumber(id);
     parse("sethealth "..victim.." 10")
     parse("setweapon "..victim.." 50")
     parse("setarmor "..victim.." 206")
     isfake[id]=true
     canfake[id]=false
end

old Re: Sethealth doesn't seem to work after spawnplayer!

DC
Admin Off Offline

Quote
Yeah the timer function will execute your stuff with a delay. Even with a delay of just 1. It will - under no circumstances - be executed before the other stuff which is in the same code passage (like sethealth, setweapon and setarmor in your case) because all this stuff doesn't use timers and is therefore executed instantly!

So you are actually using sethealth BEFORE respawning the player. This is pointless. Obviously.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview