How-To -
Lixyde - 27.03.2018
How do i save the
score of the player?
I mean when it says for example: type: 13912 to get 500$ and 5 points.
Then the player gets 5 points but doesn't save ? How to do it?
Re: How-To -
ForCop - 27.03.2018
Quote:
Originally Posted by Lixyde
How do i save the score of the player?
I mean when it says for example: type: 13912 to get 500$ and 5 points.
Then the player gets 5 points but doesn't save ? How to do it?
|
for it you need mysql or dini or sql-lite.
https://sampforum.blast.hk/showthread.php?tid=627222
Re: How-To -
Lixyde - 27.03.2018
I have, YSI/y_ini. And i need to add on my pInfo:
pScore?
And then on register, and login type:
Код:
INI_WriteInt(File,"Deaths",0);
I need to do another 1:
Код:
INI_WriteInt(File,"Score",0);
And on OnPlayerDisconnect
Код:
INI_WriteInt(File,"Score",GetPlayerScore(playerid));
Is this the way?
But in this way, wil there be a problem, because on pInfo i set it as
pScore.
And there is only
Score ?
Re: How-To -
jasperschellekens - 27.03.2018
You have to load them them after login, you actually set it to 0 when the player logs in.
Re: How-To -
Lixyde - 27.03.2018
No, they are in DIALOG REGISTER.
And my question is does will work like the example i gived. And if not how to make it work?
Re: How-To -
FaLLenGirL - 27.03.2018
Hello there.
I will respond to all your questions from this topic in the following sentences and examples.
I see that you use YINI so, here is it.
1. When a player register:
- The player that joins the server must type his password, right ?
- So, you must reset all the player variables from your "pInfo" i think, that's the name of your enum.
- To reset them you must have something like this into your "DIALOG_REGISTER" (your register dialog) after he enter his pass:
PHP код:
new INI:File = INI_Open( UserPath( playerid ) );
INI_SetTag( File, "data" );
INI_WriteInt( File, "Password", inputtext );
INI_WriteInt( File, "Cash", 0 );
INI_WriteInt( File, "Admin", 0 );
INI_WriteInt( File, "Kills", 0 );
INI_WriteInt( File, "Deaths", 0 )
INI_Close( File )
2. When a player login:
- So, you must know that when a player login is not the same thing with when a player register, i think u get that already.
- And if you know, you must load their dates from their own paths from your scriptfiles folder from folder "Users" or another folder that contain your player paths.
- So after the enteres his password into the "DIALOG_LOGIN" (your login dialog) you must have something like this:
PHP код:
INI_Int( "Password", PlayerInfo[ playerid ][ pPass ] );
INI_Int( "Cash", PlayerInfo[ playerid ][ pCash] );
INI_Int( "Admin", PlayerInfo[ playerid ][ pAdmin] );
INI_Int( "Kills", PlayerInfo[ playerid ][ pKills] );
INI_Int( "Deaths", PlayerInfo[ playerid ][ pDeaths ] );
So, that's all that you must to know when you want to make another variables that stores another things into the player path.
You said that you want to add "
Score", yea that's ok. At your enum "
pInfo" you added: "
pScore", after that you will name this into the player path "
Score". You asked if this is a problem, this is not a problem, at all. All you must to do is to add at your register dialog this: "
INI_WriteInt( File, "Score", 0 )", and at your login dialog (Load Player Dates Function or another function that loads dates) this: "
INI_Int( "Score", PlayerInfo[ playerid ][ pScore ] ), SetPlayerScore( playerid, PlayerInfo[ playerid ][ pScore ] );"
ALSO, VERY IMPORTANT:
1. At "OnPlayerDisconnect" you must save the player variables (dates) before you reset them or another things. Example here:
PHP код:
public OnPlayerDisconnect( playerid, reason )
{
new INI:File = INI_Open( UserPath( playerid ) );
INI_SetTag( File, "data" );
INI_WriteInt( File,"Cash", GetPlayerMoney( playerid ) );
INI_WriteInt( File,"Admin", PlayerInfo[ playerid ][ pAdmin ] );
INI_WriteInt( File,"Kills", PlayerInfo[ playerid ][ pKills ] );
INI_WriteInt( File,"Deaths", PlayerInfo[ playerid ][ pDeaths ] );
INI_Close( File );
return 1;
}
I hope you get all the informations that i gave you here.
Re: How-To -
Lixyde - 28.03.2018
*****