SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 17/04/2018, 03:54 AM   #1
Mobtiesgangsa
Big Clucker
 
Mobtiesgangsa's Avatar
 
Join Date: Oct 2016
Location: Skopje, Macedonia
Posts: 108
Reputation: 10
Default 2 Issues after Logging

The problem to this Bug is i register perfect it stores my HP 100 when /relog HP is saved but there is 1 problem if i fell in ground trying to relog again HP loads as 0HP not as

Exaplme my hp was 100.0 and decressed to 94.6 lets say it doesnt saves 94.6HP it hits 0




Quote:
[PlayerData]
IP = 192.168.2.3
Password = 87080FA830CE1AB39F51A78DCE5D0F325300C6E77CB42A3D61 D38E049CF650E0D37B72B6C292D6072ECF944860646F1A4206 7E1FD1872056F738AC67689FDDE6
Armour = 0.000000
Health = 0.000000
Angle = 0.000000
Z = 63.564025
Y = -2018.722900
X = 1228.179931
Money = 15000
Skin = 47
here is my ini file
__________________
YSI User

Code:
public e_COMMAND_ERRORS:OnPlayerCommandReceived(playerid, cmdtext[], e_COMMAND_ERRORS:success)
{
	switch(success)
	{
	    case COMMAND_UNDEFINED:
	    {
		    TextDrawShowForPlayer(playerid, cmdinfo[playerid]);
		    SetTimerEx("UnknownCommand", 3000, false, "d", playerid);
	    }
	}
	return COMMAND_OK;
}
Mobtiesgangsa is offline   Reply With Quote
Old 17/04/2018, 02:06 PM   #2
ProScripter
Banned
 
Join Date: Apr 2018
Location: India
Posts: 18
Reputation: 0
Default Re: 2 Issues after Logging

Quote:
Originally Posted by Mobtiesgangsa View Post
The problem to this Bug is i register perfect it stores my HP 100 when /relog HP is saved but there is 1 problem if i fell in ground trying to relog again HP loads as 0HP not as

Exaplme my hp was 100.0 and decressed to 94.6 lets say it doesnt saves 94.6HP it hits 0






here is my ini file
make timer which will check health after few seconds and save it in your ini file ok.
ProScripter is offline   Reply With Quote
Old 17/04/2018, 02:28 PM   #3
JesterlJoker
Huge Clucker
 
Join Date: Apr 2015
Location: Cagayan de Oro, Philippines
Posts: 263
Reputation: 27
Default Re: 2 Issues after Logging

Quote:
Originally Posted by ProScripter View Post
make timer which will check health after few seconds and save it in your ini file ok.
He already said that it saves to 0, doing that would just do the same thing. look at his ini file.


First of all too answer your vague problem, a small snippet would have been good

PHP Code:
GetPlayerHP(playerid){
    new 
Floathp;
    
GetPlayerHealth(playeridhp); //fixed mistype
    
return hp;

I use this small snippet when getting HP, after getting HP, I do a save such as

PHP Code:
SaveData(playerid){
    new 
string[15+MAX_USERNAME];
    
format(stringsizeof string"Accounts/%s.ini"PlayerData[playerid][username]);
    new 
INI:File INI_Open(string);

    
INI_SetTag(File"Information");
    
INI_WriteFloat(File"Health"GetPlayerHP(playerid));
    
INI_Close(File);
    return 
1;

Then that's a small snippet when I saved, assuming that you are doing it that way... Which is actually wrong.
The Player's HP is an integer and not a float, if you are saving an integer into a float then it will go into an error by saving 0.000


PHP Code:
SaveData(playerid){
    new 
string[15+MAX_USERNAME];
    
format(stringsizeof string"Accounts/%s.ini"PlayerData[playerid][username]);
    new 
INI:File INI_Open(string);

    
INI_SetTag(File"Information");
    
INI_WriteFloat(File"Health"float(GetPlayerHP(playerid))); // Which is slow but I'll use this for education purposes
    
INI_Close(File);
    return 
1;

that snippet above would do the job, if it doesn't then there should be something wrong in your code somewhere. Like you empty a data accidently and save it along the others.

EDIT: Sorry there was a mistype, Thanks @StrikerZ
__________________
My Projects:

JesterlJoker is offline   Reply With Quote
Old 17/04/2018, 02:37 PM   #4
StrikerZ
High-roller
 
StrikerZ's Avatar
 
Join Date: Mar 2016
Location: India
Posts: 1,109
Reputation: 154
Default Re: 2 Issues after Logging

PHP Code:
GetPlayerHP(playerid){
    new 
Floathp;
    
GetPlayerHP(playeridhp); // This
    
return hp;

The line I marked should be
GetPlayerHealth(playerid, hp);
__________________
StrikerZ is offline   Reply With Quote
Old 18/04/2018, 04:26 AM   #5
Mobtiesgangsa
Big Clucker
 
Mobtiesgangsa's Avatar
 
Join Date: Oct 2016
Location: Skopje, Macedonia
Posts: 108
Reputation: 10
Default Re: 2 Issues after Logging

Well i humbly apologize i try'd your methods it didn't work all i went wrong is my enumerator and a native func
called GetPlayerHealth

i tought it was just GetPlayerHealth(playerid, /* i forgot to sign the enumerator here */ PlayerInfo[playerid][pHealth]); on playerdisconnect that is all
__________________
YSI User

Code:
public e_COMMAND_ERRORS:OnPlayerCommandReceived(playerid, cmdtext[], e_COMMAND_ERRORS:success)
{
	switch(success)
	{
	    case COMMAND_UNDEFINED:
	    {
		    TextDrawShowForPlayer(playerid, cmdinfo[playerid]);
		    SetTimerEx("UnknownCommand", 3000, false, "d", playerid);
	    }
	}
	return COMMAND_OK;
}
Mobtiesgangsa is offline   Reply With Quote
Old 18/04/2018, 05:36 AM   #6
JesterlJoker
Huge Clucker
 
Join Date: Apr 2015
Location: Cagayan de Oro, Philippines
Posts: 263
Reputation: 27
Default Re: 2 Issues after Logging

Quote:
Originally Posted by Mobtiesgangsa View Post
Well i humbly apologize i try'd your methods it didn't work all i went wrong is my enumerator and a native func
called GetPlayerHealth

i tought it was just GetPlayerHealth(playerid, /* i forgot to sign the enumerator here */ PlayerInfo[playerid][pHealth]); on playerdisconnect that is all
Good to know that you solved it

Just next time though, show us a little code snippet, just a small one to show us how your code works and so most of us can sort it out, that's only two of us tried to help since no one would help you if you don't show us any information on how things work on your server.

Best wishes bruh.
__________________
My Projects:

JesterlJoker 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
[FilterScript] Logging BiosMarcel Filterscripts 12 31/01/2016 09:49 AM
Having issues with logging in. Dokins Scripting Help 1 16/05/2015 11:36 AM
Need help with logging in. Type-R Scripting Help 2 08/01/2012 04:49 PM
ban logging... Face9000 Help Archive 12 10/09/2010 02:41 AM
Logging in... Ren Sawaki Client Support 1 25/07/2009 04:57 PM


All times are GMT. The time now is 07:51 AM.


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