Save Player Health
#1

Hello, i have a AFK system in my server, and it's a dm server. So, what i would like to do is, save the player's health when he types /afk, because when player type /back, he will get full health.

So the problem is, if a player has low health, he can just do /afk, and /back, he will get full health.

So, when player types /back, he should have the health he had before he typed /afk.

You got the point? Well, if this is possible, please tell me how to do it. Thank you.
Reply
#2

If the player won't disconnect it's only to save the health into a variable. Nothing harder than that.

This one for example. https://sampwiki.blast.hk/wiki/SetPVarInt
Reply
#3

Is this what you mean

Код:
new Float:SaveHealth[MAX_PLAYERS]; // This must be on the top, this is you global variable

// in the /afk cmd this have to be added
GetPlayerHealth(playerid, SaveHealth[playerid]); // This will store the health of the player

// in the /back cmd
SetPlayerHealth(playerid, SaveHealth[playerid]); // this will restore the health
I hope this helped you with your question

Greetings,
kastranova
Reply
#4

Exactly what he said. ^
Reply
#5

Why dont u put the player into a different VIrtualWorld? and when he types /back he returns to the "real world"?
And remove the SetPlayerHealth from ur code
Reply
#6

That is also Possible ofcourse
Reply
#7

Quote:
Originally Posted by ColdXX
Посмотреть сообщение
Why dont u put the player into a different VIrtualWorld? and when he types /back he returns to the "real world"?
And remove the SetPlayerHealth from ur code
Yea, i could do that, but when player types /afk, it will create a 3D text label, and i want to stick with that. And it also gives the player god mode, and that's good.

@Kastranova, thank you, it worked.

And thank you all.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)