SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 13/06/2018, 07:39 PM   #1
Mike861
Big Clucker
 
Join Date: Feb 2018
Location: Serbia, Europe
Posts: 173
Reputation: 12
Default Health/Armour saving issue

So every time i join the server i keep on dying per every spawn.What could be the issue?
Under enum
Code:
Float:pHealth,
Float:pArmor
Under load user callback
Code:
INI_Float("Health",PlayerInfo[playerid][pHealth]);
INI_Float("Armour",PlayerInfo[playerid][pArmor]);
Under OnPlayerDisconnect
Code:
new Float:health = PlayerInfo[playerid][pHealth],Float:armor = PlayerInfo[playerid][pArmor];
GetPlayerHealth(playerid,health);
GetPlayerArmour(playerid,armor);
INI_WriteFloat(File,"Health", PlayerInfo[playerid][pHealth]);
INI_WriteFloat(File,"Armour", PlayerInfo[playerid][pArmor]);
Under OnPlayerSpawn for already registered players
Code:
SetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
SetPlayerArmour(playerid, PlayerInfo[playerid][pArmor]);

Last edited by Mike861; 13/06/2018 at 07:42 PM. Reason: Forgot the armour aswell
Mike861 is offline   Reply With Quote
Old 13/06/2018, 07:50 PM   #2
Lokii
Huge Clucker
 
Join Date: Sep 2017
Posts: 283
Reputation: 72
Default Re: Health/Armour saving issue

did u add INI_ParseFile??
Lokii is offline   Reply With Quote
Old 13/06/2018, 07:51 PM   #3
xMoBi
Big Clucker
 
xMoBi's Avatar
 
Join Date: Jul 2017
Location: Islamic Republic of Pakistan
Posts: 110
Reputation: 26
Default Re: Health/Armour saving issue

print those values before you set them.
xMoBi is offline   Reply With Quote
Old 13/06/2018, 07:53 PM   #4
Mike861
Big Clucker
 
Join Date: Feb 2018
Location: Serbia, Europe
Posts: 173
Reputation: 12
Default Re: Health/Armour saving issue

Quote:
Originally Posted by Lokii View Post
did u add INI_ParseFile??
Nope
Mike861 is offline   Reply With Quote
Old 13/06/2018, 07:56 PM   #5
Lokii
Huge Clucker
 
Join Date: Sep 2017
Posts: 283
Reputation: 72
Default Re: Health/Armour saving issue

thats why you die you dont load the data and the health enum = 0

add INI_ParseFile on top of OnPlayerSpawn
Lokii is offline   Reply With Quote
Old 13/06/2018, 08:03 PM   #6
Mike861
Big Clucker
 
Join Date: Feb 2018
Location: Serbia, Europe
Posts: 173
Reputation: 12
Default Re: Health/Armour saving issue

Quote:
Originally Posted by Lokii View Post
thats why you die you dont load the data and the health enum = 0

add INI_ParseFile on top of OnPlayerSpawn
I did it this way but its still the same
Code:
INI_ParseFile("%s.ini", "LoadUser_Data", .bPassTag = true);
Mike861 is offline   Reply With Quote
Old 13/06/2018, 08:08 PM   #7
Lokii
Huge Clucker
 
Join Date: Sep 2017
Posts: 283
Reputation: 72
Default Re: Health/Armour saving issue

Quote:
Originally Posted by Mike861 View Post
I did it this way but its still the same
Code:
INI_ParseFile("%s.ini", "LoadUser_Data", .bPassTag = true);
PHP Code:
new name[24], path[29];
GetPlayerName(playeridnamesizeof(name));
format(pathsizeof(path), "%s.ini"name);
INI_ParseFile(path"LoadUser_Data_%s", .bExtra true, .extra playerid); 
Lokii is offline   Reply With Quote
Old 14/06/2018, 06:23 AM   #8
Mike861
Big Clucker
 
Join Date: Feb 2018
Location: Serbia, Europe
Posts: 173
Reputation: 12
Default Re: Health/Armour saving issue

Quote:
Originally Posted by Lokii View Post
PHP Code:
new name[24], path[29];
GetPlayerName(playeridnamesizeof(name));
format(pathsizeof(path), "%s.ini"name);
INI_ParseFile(path"LoadUser_Data_%s", .bExtra true, .extra playerid); 
Still the same
Mike861 is offline   Reply With Quote
Old 14/06/2018, 01:56 PM   #9
Exhibit
Big Clucker
 
Join Date: Dec 2015
Location: Basement.
Posts: 167
Reputation: 19
Default Re: Health/Armour saving issue

INI_ParseFile should be added on OnPlayerConnect considering you are also loading the password?

Are the values saving?
__________________
rg-clan.eu | relentlessdm.com
Exhibit is offline   Reply With Quote
Old 14/06/2018, 02:42 PM   #10
Akeem
Big Clucker
 
Join Date: Aug 2017
Location: Guyana
Posts: 97
Reputation: 0
Default Re: Health/Armour saving issue

First you have to set this values to 0 under OnPlayerDisconnect: PlayerInfo[playerid][pHealth], PlayerInfo[playerid][pArmour] and on player connect equal then to what is in there file. Then you can setplayerhp and so on.
Akeem is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Health Issue AlexuTzVs Scripting Help 0 05/09/2016 08:54 PM
infinity health variable issue HeLiOn_PrImE Scripting Help 7 24/08/2014 06:54 PM
Health issue CROSS_Hunter Scripting Help 2 25/02/2013 01:55 AM
Vehicle health issue HeLiOn_PrImE Scripting Help 4 25/09/2011 06:02 AM
Saving Player Health/Spawning With Health Despare Help Archive 21 25/11/2009 05:20 AM


All times are GMT. The time now is 03:04 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.