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, 06:26 PM   #61
Riddick94
Banned
 
Join Date: Mar 2010
Location: Poland
Posts: 1,767
Reputation: 223
Default Re: Y_Ini - Let's do it!

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);

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

Quote:
Originally Posted by Riddick94 View Post
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);

It's saving but Weapon = 0, Ammo = 0. Should save all weapon slots and ammo.
It's because you need new name for every single weapon.
So i made this,

pawn Code:
foreach2(w, MAX_WEAPON_SLOTS)
{
    GetPlayerWeaponData(playerid, w, PlayerInfo[playerid][Weapons][w], PlayerInfo[playerid][Ammo][w]);
    new Str[2][10];
    format( Str[0], sizeof (Str[0]), "Weapon_%d", PlayerInfo[playerid][Weapons][w] );
    format( Str[1], sizeof (Str[1]), "Ammo_%d",   PlayerInfo[playerid][Ammo][w] );
    INI_WriteInt(Account, Str[0], PlayerInfo[playerid][Weapons][w]);
    INI_WriteInt(Account, Str[1], PlayerInfo[playerid][Ammo][w]);
}

Didn't test it, should work!
__________________
Zh3r0 is offline  
Old 10/03/2011, 06:38 PM   #63
Riddick94
Banned
 
Join Date: Mar 2010
Location: Poland
Posts: 1,767
Reputation: 223
Default Re: Y_Ini - Let's do it!

Works correctly but i was need to change variabli str to:
pawn Code:
new wString[10], aString[10];
Okey.. now how to load?

Code:
Weapon_1 = 1
Ammo_1 = 1
Weapon_0 = 0
Ammo_0 = 0
Weapon_22 = 22
Ammo_34 = 34
Weapon_29 = 29
Ammo_120 = 120
Riddick94 is offline  
Old 10/03/2011, 06:40 PM   #64
Zh3r0
High-roller
 
Join Date: Mar 2008
Posts: 4,510
Reputation: 398
Default Re: Y_Ini - Let's do it!

Quote:
Originally Posted by Riddick94 View Post
Works correctly but i was need to change variabli str to:
pawn Code:
new wString[10], aString[10];
Okey.. now how to load?

Code:
Weapon_1 = 1
Ammo_1 = 1
Weapon_0 = 0
Ammo_0 = 0
Weapon_22 = 22
Ammo_34 = 34
Weapon_29 = 29
Ammo_120 = 120
Wait wait wait! I've made a mistake! I should have used w instead of the variable.

pawn Code:
foreach2(w, MAX_WEAPON_SLOTS)
{
    GetPlayerWeaponData(playerid, w, PlayerInfo[playerid][Weapons][w], PlayerInfo[playerid][Ammo][w]);
    new Str1[10], Str2[10]
    format( Str1, sizeof (Str1), "Weapon_%d", w );
    format( Str2, sizeof (Str2), "Ammo_%d",   w );
    INI_WriteInt(Account, Str,  PlayerInfo[playerid][Weapons][w]);
    INI_WriteInt(Account, Str2, PlayerInfo[playerid][Ammo][w]);
}
The result should have been
pawn Code:
Weapon_0 = 1
Ammo_0 = 1
Weapon_1 = 0
Ammo_1 = 0
Weapon_2 = 22
Ammo_2 = 34
Weapon_3 = 29
Ammo_3 = 120
__________________
Zh3r0 is offline  
Old 10/03/2011, 06:47 PM   #65
Riddick94
Banned
 
Join Date: Mar 2010
Location: Poland
Posts: 1,767
Reputation: 223
Default Re: Y_Ini - Let's do it!

Code:
Weapon_0 = 1
Ammo_0 = 1
Weapon_1 = 0
Ammo_1 = 0
Weapon_2 = 22
Ammo_2 = 34
Weapon_3 = 0
Ammo_3 = 0
Weapon_4 = 0
Ammo_4 = 0
Weapon_5 = 31
Ammo_5 = 120
Weapon_6 = 0
Ammo_6 = 0
Weapon_7 = 0
Ammo_7 = 0
Weapon_8 = 0
Ammo_8 = 0
Weapon_9 = 0
Ammo_9 = 0
Weapon_10 = 0
Ammo_10 = 0
Weapon_11 = 0
Ammo_11 = 0
Weapon_12 = 0
Ammo_12 = 0
Now need to load : )
Riddick94 is offline  
Old 10/03/2011, 06:52 PM   #66
Zh3r0
High-roller
 
Join Date: Mar 2008
Posts: 4,510
Reputation: 398
Default Re: Y_Ini - Let's do it!

Quote:
Originally Posted by Riddick94 View Post
Code:
Weapon_0 = 1
Ammo_0 = 1
Weapon_1 = 0
Ammo_1 = 0
Weapon_2 = 22
Ammo_2 = 34
Weapon_3 = 0
Ammo_3 = 0
Weapon_4 = 0
Ammo_4 = 0
Weapon_5 = 31
Ammo_5 = 120
Weapon_6 = 0
Ammo_6 = 0
Weapon_7 = 0
Ammo_7 = 0
Weapon_8 = 0
Ammo_8 = 0
Weapon_9 = 0
Ammo_9 = 0
Weapon_10 = 0
Ammo_10 = 0
Weapon_11 = 0
Ammo_11 = 0
Weapon_12 = 0
Ammo_12 = 0
Now need to load : )
I'll let ****** now to help you, I have to go to sleep for now, can't write the code to you, however, i know the right code!
__________________
Zh3r0 is offline  
Old 10/03/2011, 07:02 PM   #67
Riddick94
Banned
 
Join Date: Mar 2010
Location: Poland
Posts: 1,767
Reputation: 223
Default Re: Y_Ini - Let's do it!

Quote:
Originally Posted by Zh3r0 View Post
I'll let ****** now to help you, I have to go to sleep for now, can't write the code to you, however, i know the right code!
: D okey thanks for the help and with everything with that shit. Have a good night : ]

pawn Code:
foreach2(w, MAX_WEAPON_SLOTS)
    {
        new wString[32], aString[32];
        format(wString, sizeof(wString), "Weapon_%d", w);
        format(aString, sizeof(aString), "Ammo_%d",   w);
        GivePlayerWeaponEx(playerid, strval(wString), strval(aString));
    }

I was try to do something with load but.. sizeof in GivePlayerWeaponEx? it's not corectly for me too.. but i don't know what to do..

P.S
Lag after player logged. After i putted this foreach.

edit://
Not sizeof but strval you idiot! (i'm talking to me.. damn..)
Riddick94 is offline  
Old 11/03/2011, 08:21 AM   #68
Riddick94
Banned
 
Join Date: Mar 2010
Location: Poland
Posts: 1,767
Reputation: 223
Default Re: Y_Ini - Let's do it!

So.. anybody ready to help : D?

Third page + Bump : )
Riddick94 is offline  
Old 11/03/2011, 08:56 AM   #69
Riddick94
Banned
 
Join Date: Mar 2010
Location: Poland
Posts: 1,767
Reputation: 223
Default Re: Y_Ini - Let's do it!

Zh3r0 was helped me with saving weapons. Now i need to load them. Password loging i all okey now : )
Riddick94 is offline  
Old 11/03/2011, 09:04 AM   #70
Riddick94
Banned
 
Join Date: Mar 2010
Location: Poland
Posts: 1,767
Reputation: 223
Default Re: Y_Ini - Let's do it!

You're talking to me about INI_ParseFile? i was made this yesterday:

pawn Code:
foreach2(w, MAX_WEAPON_SLOTS)
    {
        new wString[32], aString[32];
        format(wString, sizeof(wString), "Weapon_%d", w);
        format(aString, sizeof(aString), "Ammo_%d",   w);
        GivePlayerWeaponEx(playerid, strval(wString), strval(aString));
    }

But not working.. what need to do with it?
Riddick94 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 12:53 AM.


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