SA-MP Forums

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

 
 
Thread Tools Display Modes
Old 10/03/2011, 05:13 PM   #51
Zh3r0
High-roller
 
Join Date: Mar 2008
Posts: 4,512
Reputation: 398
Default Re: Y_Ini - Let's do it!

Quote:
Originally Posted by Riddick94 View Post
pawn Code:
stock LoadStats(playerid, name[], value[])
{
    if(!strcmp(name, "Money"))      SetPlayerMoneyEx(playerid) = strval(value);
    if(!strcmp(name, "FightStyle")) SetPlayerFightingStyle(playerid) = strval(value);
}

pawn Code:
stock OnPlayerLogin(playerid, password[])
{
    INI_ParseFile(PlayerFile(playerid), "GetPlayerPassword");
    new PlayerPass[129], buf[129];
    GetPVarString(playerid, "pPass", PlayerPass, 129);
    WP_Hash(buf, sizeof(buf), password);
   
    if(!strcmp(PlayerPass, buf))
    {
        PlayerInfo[playerid][pLogged] = true;
        TogglePlayerClock(playerid, true);
       
        INI_ParseFile(PlayerFile(playerid), "LoadStats", .bExtra = true, .extra = playerid);

        SendDeathMessage(INVALID_PLAYER_ID, playerid, ICON_CONNECT);
        SendFormattedMessageToAll(COLOR_WHITE, "***  %s [{FF003F}ID{FFFFFF}: {FF003F}%d{FFFFFF}] dołączył do serwera.", PlayerName(playerid), playerid);
        SendFormattedMessage(playerid, COLOR_LIMON, "{1BE03F}* Zalogowany jako {EDBC6D}%s {FFFFFF}[{FF003F}ID{FFFFFF}: {FF003F}%d{FFFFFF}]{1BE03F}. Witamy spowrotem na Polskim eXtra Serwerze!", PlayerName(playerid), playerid);
        }else{
        new string[128];
        format(string,sizeof(string),"{9EB8E8}Witamy ponownie {F2EE0C}%s{9EB8E8}. Proszę wpisać poniżej swoje hasło, aby zalogować się i grać:", PlayerName(playerid));
        ShowPlayerDialog(playerid, DIALOG_LOGOWANIE, DIALOG_STYLE_INPUT, "Logowanie", string, "Zaloguj", "Wyjdź");
        GameTextForPlayer(playerid, " ~n~ ~n~ ~n~ ~n~ ~n~ ~r~Nieprawidlowe haslo!", SECONDS(3), 3);
    }
    return true;
}
Don't do it stock! It must be a public!
__________________
Zh3r0 is offline  
Old 10/03/2011, 05:15 PM   #52
Riddick94
Banned
 
Join Date: Mar 2010
Location: Poland
Posts: 1,767
Reputation: 223
Default Re: Y_Ini - Let's do it!

Okey.. can you tell me why? : )
Riddick94 is offline  
Old 10/03/2011, 05:21 PM   #53
Zh3r0
High-roller
 
Join Date: Mar 2008
Posts: 4,512
Reputation: 398
Default Re: Y_Ini - Let's do it!

Quote:
Originally Posted by Riddick94 View Post
Okey.. can you tell me why? : )
stock is mostly used for fast functions like:

pawn Code:
stock SetPlayerPosEx( playerid, Float:X, Float:Z, Float:Y, Float:A )
{
    SetPlayerPos( playerid, X, Y, Z );
    SetPlayerFacingAngle( playerid, A );
}

+ the fact that i think INI_ParseFile at the callback param uses CallLocalFunction which needs to be a public ones because stocks aren't counted.
__________________
Zh3r0 is offline  
Old 10/03/2011, 05:23 PM   #54
Riddick94
Banned
 
Join Date: Mar 2010
Location: Poland
Posts: 1,767
Reputation: 223
Default Re: Y_Ini - Let's do it!

Aaaaa! allright. Now need waiting only for ******..
Riddick94 is offline  
Old 10/03/2011, 06:09 PM   #55
Riddick94
Banned
 
Join Date: Mar 2010
Location: Poland
Posts: 1,767
Reputation: 223
Default Re: Y_Ini - Let's do it!

GetPlayerPassword is a Public too.

Debug:
I change it:
pawn Code:
printf("%s %s", PlayerPass, buf);
to
pawn Code:
printf("%s | %s", PlayerPass, buf);
to better read.

Code:
| 45046CDE2CB147890DC563A8A112A4A3BA20D9B27BAD4AB810BD341C59922991175AC6FAEB9E0BF7C71C7A971A643A5C8586F40FC8E69082361672A4DC7FB3D2
On the left side - nothing.
Riddick94 is offline  
Old 10/03/2011, 06:12 PM   #56
Zh3r0
High-roller
 
Join Date: Mar 2008
Posts: 4,512
Reputation: 398
Default Re: Y_Ini - Let's do it!

Quote:
Originally Posted by Riddick94 View Post
GetPlayerPassword is a Public too.

Debug:
I change it:
pawn Code:
printf("%s %s", PlayerPass, buf);
to
pawn Code:
printf("%s | %s", PlayerPass, buf);
to better read.

Code:
| 45046CDE2CB147890DC563A8A112A4A3BA20D9B27BAD4AB810BD341C59922991175AC6FAEB9E0BF7C71C7A971A643A5C8586F40FC8E69082361672A4DC7FB3D2
On the left side - nothing.
Like i told you, the password seems to be NULL! This is the problem.


I just noticed:

Replace:
pawn Code:
INI_ParseFile(PlayerFile(playerid), "GetPlayerPassword");

With:
pawn Code:
INI_ParseFile(PlayerFile(playerid), "GetPlayerPassword", .bExtra = true, .extra = playerid);

You forgot to parse the file with player's ID!
__________________
Zh3r0 is offline  
Old 10/03/2011, 06:14 PM   #57
Riddick94
Banned
 
Join Date: Mar 2010
Location: Poland
Posts: 1,767
Reputation: 223
Default Re: Y_Ini - Let's do it!

Um.. i already gave that.. lot of times.

pawn Code:
stock OnPlayerLogin(playerid, password[])
{
    INI_ParseFile(PlayerFile(playerid), "GetPlayerPassword");
    new PlayerPass[129], buf[129];
    GetPVarString(playerid, "pPass", PlayerPass, 129);
    WP_Hash(buf, sizeof(buf), password);
    printf("%s | %s", PlayerPass, buf);
   
    if(!strcmp(PlayerPass, buf))
    {
        PlayerInfo[playerid][pLogged] = true;
        TogglePlayerClock(playerid, true);
       
        INI_ParseFile(PlayerFile(playerid), "LoadStats");

        SendDeathMessage(INVALID_PLAYER_ID, playerid, ICON_CONNECT);
        SendFormattedMessageToAll(COLOR_WHITE, "***  %s [{FF003F}ID{FFFFFF}: {FF003F}%d{FFFFFF}] dołączył do serwera.", PlayerName(playerid), playerid);
        SendFormattedMessage(playerid, COLOR_LIMON, "{1BE03F}* Zalogowany jako {EDBC6D}%s {FFFFFF}[{FF003F}ID{FFFFFF}: {FF003F}%d{FFFFFF}]{1BE03F}. Witamy spowrotem na Polskim eXtra Serwerze!", PlayerName(playerid), playerid);
        }else{
        new string[128];
        format(string,sizeof(string),"{9EB8E8}Witamy ponownie {F2EE0C}%s{9EB8E8}. Proszę wpisać poniżej swoje hasło, aby zalogować się i grać:", PlayerName(playerid));
        ShowPlayerDialog(playerid, DIALOG_LOGOWANIE, DIALOG_STYLE_INPUT, "Logowanie", string, "Zaloguj", "Wyjdź");
        GameTextForPlayer(playerid, " ~n~ ~n~ ~n~ ~n~ ~n~ ~r~Nieprawidlowe haslo!", SECONDS(3), 3);
    }
    return true;
}
Riddick94 is offline  
Old 10/03/2011, 06:17 PM   #58
Zh3r0
High-roller
 
Join Date: Mar 2008
Posts: 4,512
Reputation: 398
Default Re: Y_Ini - Let's do it!

Quote:
Originally Posted by Riddick94 View Post
Um.. i already gave that.. lot of times.

pawn Code:
stock OnPlayerLogin(playerid, password[])
{
    INI_ParseFile(PlayerFile(playerid), "GetPlayerPassword");
    new PlayerPass[129], buf[129];
    GetPVarString(playerid, "pPass", PlayerPass, 129);
    WP_Hash(buf, sizeof(buf), password);
    printf("%s | %s", PlayerPass, buf);
   
    if(!strcmp(PlayerPass, buf))
    {
        PlayerInfo[playerid][pLogged] = true;
        TogglePlayerClock(playerid, true);
       
        INI_ParseFile(PlayerFile(playerid), "LoadStats");

        SendDeathMessage(INVALID_PLAYER_ID, playerid, ICON_CONNECT);
        SendFormattedMessageToAll(COLOR_WHITE, "***  %s [{FF003F}ID{FFFFFF}: {FF003F}%d{FFFFFF}] dołączył do serwera.", PlayerName(playerid), playerid);
        SendFormattedMessage(playerid, COLOR_LIMON, "{1BE03F}* Zalogowany jako {EDBC6D}%s {FFFFFF}[{FF003F}ID{FFFFFF}: {FF003F}%d{FFFFFF}]{1BE03F}. Witamy spowrotem na Polskim eXtra Serwerze!", PlayerName(playerid), playerid);
        }else{
        new string[128];
        format(string,sizeof(string),"{9EB8E8}Witamy ponownie {F2EE0C}%s{9EB8E8}. Proszę wpisać poniżej swoje hasło, aby zalogować się i grać:", PlayerName(playerid));
        ShowPlayerDialog(playerid, DIALOG_LOGOWANIE, DIALOG_STYLE_INPUT, "Logowanie", string, "Zaloguj", "Wyjdź");
        GameTextForPlayer(playerid, " ~n~ ~n~ ~n~ ~n~ ~n~ ~r~Nieprawidlowe haslo!", SECONDS(3), 3);
    }
    return true;
}
Read my post again, you may have read it before me editing it.
__________________
Zh3r0 is offline  
Old 10/03/2011, 06:20 PM   #59
Riddick94
Banned
 
Join Date: Mar 2010
Location: Poland
Posts: 1,767
Reputation: 223
Default Re: Y_Ini - Let's do it!

Quote:
I just noticed:

Replace:
pawn Code:
INI_ParseFile(PlayerFile(playerid), "GetPlayerPassword");

With:
pawn Code:
INI_ParseFile(PlayerFile(playerid), "GetPlayerPassword", .bExtra = true, .extra = playerid);

You forgot to parse the file with player's ID!
IT WORKING!
Code:
45046CDE2CB147890DC563A8A112A4A3BA20D9B27BAD4AB810BD341C59922991175AC6FAEB9E0BF7C71C7A971A643A5C8586F40FC8E69082361672A4DC7FB3D2 | 34DD680448B47AEB3593CFA3DF71E0115E96634B0E3529DAC9333206213452B801E68378CA342022216FC4604548C4C67F78D01FFE5B48D47453C9DCA0BA70BE
It's fucking working! finally! thank you so much!

Next stop is:
How to save player weapons and load them?

pawn Code:
INI_WriteInt(Account, "Money", GetPlayerMoney(playerid));
    INI_WriteInt(Account, "FightStyle", GetPlayerFightingStyle(playerid));

    foreach2(w, MAX_WEAPON_SLOTS)
    {
        GetPlayerWeaponData(playerid, w, PlayerInfo[playerid][Weapons][w], PlayerInfo[playerid][Ammo][w]);
        INI_WriteInt(Account, "Weapon", PlayerInfo[playerid][Weapons][w]);
        INI_WriteInt(Account, "Ammo", PlayerInfo[playerid][Ammo][w]);
    }
    INI_Close(Account);

@UP
It's saving but Weapon = 0, Ammo = 0. Should save all weapon slots and ammo.
Riddick94 is offline  
Old 10/03/2011, 06:25 PM   #60
Zh3r0
High-roller
 
Join Date: Mar 2008
Posts: 4,512
Reputation: 398
Default Re: Y_Ini - Let's do it!

Quote:
Originally Posted by Riddick94 View Post
IT WORKING!

Next stop is:
How to save player weapons and load them?

pawn Code:
INI_WriteInt(Account, "Money", GetPlayerMoney(playerid));
    INI_WriteInt(Account, "FightStyle", GetPlayerFightingStyle(playerid));

    foreach2(w, MAX_WEAPON_SLOTS)
    {
        GetPlayerWeaponData(playerid, w, PlayerInfo[playerid][Weapons][w], PlayerInfo[playerid][Ammo][w]);
        INI_WriteInt(Account, "Weapon", PlayerInfo[playerid][Weapons][w]);
        INI_WriteInt(Account, "Ammo", PlayerInfo[playerid][Ammo][w]);
    }
    INI_Close(Account);
Does that code work?
__________________
Zh3r0 is offline  
 

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
Y_ini Stefans94 Help Archive 4 07/03/2011 07:57 PM
y_ini Help Linus- Help Archive 6 22/01/2011 01:09 PM
Y_INI [HELP] park4bmx Help Archive 14 15/01/2011 03:18 PM
Y_ini help. Haydz Help Archive 0 12/01/2011 11:35 AM


All times are GMT. The time now is 09:26 AM.


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