sync player hp and armour
#1

So..I want to sync player health and armour. When they aren't synchronized by the SA-MP or whatever.

So I made 2 variables where I stored the player last health and armour.

and when I finish checking I use SetPlayerHealth/Armour...

So basically, when a player change his VW to anoter VW where a Player is AFK (they aren't sync) so I want to do when the player that isn't AFK shoot in player that is AFK to take damage (default the player doesn't take DMG).

So I made this script, in OnPlayerGiveDamage: https://pastebin.com/jgXh60cn
And OnPlayerUpdate: https://pastebin.com/bVwWTBHC

I tested on my server and nothing happend, like before, when they aren't sync , the player AFK still doesn't take dmg.
Reply
#2

Do you partner when he go afk , anything is happening ? for example Any textdraw apear , Tags or color changed ? , if no try to put anything Showing that player is afk or not because the variable OnPlayerPause Doesn't work as well as other methods to detect if player is afk or not.
Reply
#3

Quote:
Originally Posted by RedGun2015
Посмотреть сообщение
So..I want to sync player health and armour. When they aren't synchronized by the SA-MP or whatever.

So I made 2 variables where I stored the player last health and armour.

and when I finish checking I use SetPlayerHealth/Armour...

So basically, when a player change his VW to anoter VW where a Player is AFK (they aren't sync) so I want to do when the player that isn't AFK shoot in player that is AFK to take damage (default the player doesn't take DMG).

So I made this script, in OnPlayerGiveDamage: https://pastebin.com/jgXh60cn
And OnPlayerUpdate: https://pastebin.com/bVwWTBHC

I tested on my server and nothing happend, like before, when they aren't sync , the player AFK still doesn't take dmg.
If you use variables they will update even if the player is AFK, BUT the health bar will not update nor will the player die until he will be back, because it's controlled by the client.

If you want the player to die, you must make a fake-death system which applies an animation to that player.
Reply
#4

Quote:
Originally Posted by NaS
Посмотреть сообщение
If you use variables they will update even if the player is AFK, BUT the health bar will not update nor will the player die until he will be back, because it's controlled by the client.

If you want the player to die, you must make a fake-death system which applies an animation to that player.
So, how can I do that?
Reply
#5

Quote:
Originally Posted by RedGun2015
Посмотреть сообщение
So, how can I do that?
You could save yourself a lot of work by looking into weapon-config.inc by Slice, which also offers a lot of other nice features and bug fixes, including damaging and killing AFK Players with death animations (with correct health bars).

It's also configurable, so if you don't want to use certain features you can disable them.

https://sampforum.blast.hk/showthread.php?tid=563387

It's also super efficient against any kind of health or weapon hacks.

If you want to do it on your own, you need to check the server-sided health everywhere in your script instead of GetPlayerHealth (best would be to hook it, but that's not really neccessary).
You also need to process every type of damage a player takes correctly, like fall damage or explosions that aren't caused by other players (exploding vehicles, CreateExplosion, etc) via OnPlayerTakeDamage.

If you decide to not use weapon-config I still suggest you to look at it. It's really well done and it's exactly how a custom damage/health system should look like, in my opinion.
Reply
#6

Quote:
Originally Posted by NaS
Посмотреть сообщение
You could save yourself a lot of work by looking into weapon-config.inc by Slice, which also offers a lot of other nice features and bug fixes, including damaging and killing AFK Players with death animations (with correct health bars).

It's also configurable, so if you don't want to use certain features you can disable them.

https://sampforum.blast.hk/showthread.php?tid=563387

It's also super efficient against any kind of health or weapon hacks.

If you want to do it on your own, you need to check the server-sided health everywhere in your script instead of GetPlayerHealth (best would be to hook it, but that's not really neccessary).
You also need to process every type of damage a player takes correctly, like fall damage or explosions that aren't caused by other players (exploding vehicles, CreateExplosion, etc) via OnPlayerTakeDamage.

If you decide to not use weapon-config I still suggest you to look at it. It's really well done and it's exactly how a custom damage/health system should look like, in my opinion.
I look in the include, and I tried something else:

I set every player (onplayerconnect + Onplayerspawn) to the same team ( SetPlayerTeam(playerid, 0) ) to know that no one take damage without the pHealth or pArmour to be changed, and When OnPlayerTakeDamage is called I do this:

https://pastebin.com/JwK28ZCp

But, sometimes OnPlayerTakeDamage isn't called / player don't take the damage when someone shoot in him.

I now I can use OnPlayerGiveDamage, but like I said, the script same as onplayertakedamage to onplayergivedamage when the damagedid is AFK(not streamed with playerid).

So , how can I fix this?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)