Saving Player Health/Spawning With Health
#1

Well, I'm still new to this but I've tried many things for Saving a Player's Health and Armour.as in each time people log off and log back in or saved within the script during the game. I don't really know what code I should post for you guys to help me with it. But, If you could help me, I would really appreciate it.
Reply
#2

plz define what you mean by "saving" as in each time peaple log off and log back in or saved within the script during the game?
Reply
#3

Quote:
Originally Posted by [LCG
TANKER ]
plz define what you mean by "saving" as in each time peaple log off and log back in or saved within the script during the game?
Yes.
Reply
#4

Bump, Need help please.
Reply
#5

what gamemode u use?
Reply
#6

pawn Код:
//For saving:
new Float:health,Float:x,Float:y,Float:z,Float:a
GetPlayerPos(playerid,x,y,z);
GetPlayerFacingAngle(playerid,a);
GetPlayerHealth(playerid,health);
//For loading:
SetPlayerPos(playerid,x,y,z);
SetPlayerFacingAngle(playerid,a);
SetPlayerHealth(playerid,health);
i didn't compile it so you have to test if it works

i dont know your variables or if you want to save it permanently, then you have to use dini or dudb
Reply
#7

Quote:
Originally Posted by thiaZ_
pawn Код:
//For saving:
new Float:health,Float:x,Float:y,Float:z,Float:a
GetPlayerPos(playerid,x,y,z);
GetPlayerFacingAngle(playerid,a);
GetPlayerHealth(playerid,health);
//For loading:
SetPlayerPos(playerid,x,y,z);
SetPlayerFacingAngle(playerid,a);
SetPlayerHealth(playerid,health);

i dont know your variables or if you want to save it permanently, then you have to use dini or dudb
What do you mean permanently?

Quote:
Originally Posted by pierhs
what gamemode u use?
Los Angeles Roleplay
Reply
#8

You need to save values in database in order to save them permanently.
Reply
#9

Quote:
Originally Posted by $ЂЯĢ
You need to save values in database in order to save them permanently.
Well, How do you do that? Sorry, I'm still kinda new to this stuff
Reply
#10

You can use dini include.
Combine it with /register, /login

And then you will be able to

pawn Код:
dini_IntSet(userfile,"Health",floatround(GetPlayerHealth(playerid));
pawn Код:
SetPlayerHealth(playerid,dini_Int(userfile,"Health"));
Reply
#11

Quote:
Originally Posted by Luka™
You can use dini include.
Combine it with /register, /login

And then you will be able to

pawn Код:
dini_IntSet(userfile,"Health",floatround(GetPlayerHealth(playerid));
pawn Код:
SetPlayerHealth(playerid,dini_Int(userfile,"Health"));
Thanks, but the weird thing is my /login and /register, aren't dini
Reply
#12

Ok, in what extension your user account saves?
Reply
#13

Oops, double post
Reply
#14

Quote:
Originally Posted by Luka™
Ok, in what extension your user account saves?
Well
Quote:

format(string, sizeof(string), "users/%s.ini", sendername);

Reply
#15

Okay, ini file.. So in /register command just put

pawn Код:
new pName[MAX_PLAYER_NAME],string[128];
GetPlayerName(playerid,pName,sizeof(pName));
format(string,sizeof(string),"users/%s.ini",pName);

dini_IntSet(string,"Health",0);
And then use my previous posted code.
Reply
#16

Quote:
Originally Posted by Luka™
Okay, ini file.. So in /register command just put

pawn Код:
new pName[MAX_PLAYER_NAME],string[128];
GetPlayerName(playerid,pName,sizeof(pName));
format(string,sizeof(string),"users/%s.ini",pName);

dini_IntSet(string,"Health",0);
And then use my previous posted code.
replace string with userfile.
Reply
#17

Quote:
Originally Posted by Luka™
Okay, ini file.. So in /register command just put

pawn Код:
new pName[MAX_PLAYER_NAME],string[128];
GetPlayerName(playerid,pName,sizeof(pName));
format(string,sizeof(string),"users/%s.ini",pName);

dini_IntSet(string,"Health",0);
And then use my previous posted code.
Alright, thanks :P, Sorry to for a nubby question but where do I put your previous code under? and where do i put dini_Intset(string,"Health,0); under?
Reply
#18

hmm... i suggest you deleting whole register/login system if you know what you're doing then i'll give you complete
register/login system + saving health
Reply
#19

Quote:
Originally Posted by Luka™
hmm... i suggest you deleting whole register/login system if you know what you're doing then i'll give you complete
register/login system + saving health
Alright, I deleted it, Yes I know how to :P Also, does it save Armour also?
Reply
#20

Quote:
Originally Posted by Luka™
hmm... i suggest you deleting whole register/login system if you know what you're doing then i'll give you complete
register/login system + saving health
So are you going to give it to me?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)