Y_Ini - Let's do it!
#41

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.
Reply
#42

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!
Reply
#43

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
Reply
#44

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
Reply
#45

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 : )
Reply
#46

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!
Reply
#47

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..)
Reply
#48

So.. anybody ready to help : D?

Third page + Bump : )
Reply
#49

Zh3r0 was helped me with saving weapons. Now i need to load them. Password loging i all okey now : )
Reply
#50

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?
Reply
#51

You have the saving code already:
pawn Code:
new str[32];
foreach2(w, MAX_WEAPON_SLOTS)
{
    GetPlayerWeaponData(playerid, w, PlayerInfo[playerid][Weapons][w], PlayerInfo[playerid][Ammo][w]);

    format(str, sizeof (str), "Weapon_%d", w);
    INI_WriteInt(Account, str, PlayerInfo[playerid][Weapons][w]);

    format(str, sizeof (str), "Ammo_%d", w);
    INI_WriteInt(Account, str, PlayerInfo[playerid][Ammo][w]);
}
It's not too hard to make it load instead:
pawn Code:
// put this inside the loading callback

new str[32];
foreach2(w, MAX_WEAPON_SLOTS)
{
    format(str, sizeof (str), "Weapon_%d", w);
    INI_Int(str, PlayerInfo[playerid][Weapons][w]);

    format(str, sizeof (str), "Ammo_%d", w);
    INI_Int(str, PlayerInfo[playerid][Ammo][w]);

    GivePlayerWeapon(playerid, PlayerInfo[playerid][Weapons][w], PlayerInfo[playerid][Ammo][w]);
}
Reply
#52

Omg INT.. sorry : o
Reply
#53

Not working.. is that good?
pawn Code:
function LoadPlayerStats(playerid, name[], value[])
{
    if(!strcmp(name, "Money"))      GivePlayerMoneyEx(playerid, strval(value));
    if(!strcmp(name, "FightStyle")) SetPlayerFightingStyle(playerid, strval(value));
    if(!strcmp(name, "Armour"))     SetPlayerArmour(playerid, floatstr(value));
   
    foreach2(w, MAX_WEAPON_SLOTS)
    {
        new string[32];
        format(string, sizeof (string), "Weapon_%d", w);
        INI_Int(string, PlayerInfo[playerid][Weapons][w]);
       
        format(string, sizeof (string), "Ammo_%d", w);
        INI_Int(string, PlayerInfo[playerid][Ammo][w]);
        GivePlayerWeaponEx(playerid, PlayerInfo[playerid][Weapons][w], PlayerInfo[playerid][Ammo][w]);
    }
    return true;
}
Reply
#54

You mean this?
pawn Code:
GivePlayerWeaponEx(playerid, strval(PlayerInfo[playerid][Weapons][w]), strval(PlayerInfo[playerid][Ammo][w]));
Not working. And i was try to load on Spawn.. not working too.
Reply
#55

Quote:
Originally Posted by Riddick94
View Post
You mean this?
pawn Code:
GivePlayerWeaponEx(playerid, strval(PlayerInfo[playerid][Weapons][w]), strval(PlayerInfo[playerid][Ammo][w]));
Not working. And i was try to load on Spawn.. not working too.
Not there, in the INI_int function.
pawn Code:
INI_Int( string, strval( PlayerInfo[ playerid ][ Weapons ][ w ] ) );
Reply
#56

Code:
C:\Documents and Settings\Kakarotto\Pulpit\Sa-Mp Serwer 0.3c\gamemodes\pes.pwn(2159) : error 022: must be lvalue (non-constant)
C:\Documents and Settings\Kakarotto\Pulpit\Sa-Mp Serwer 0.3c\gamemodes\pes.pwn(2162) : error 022: must be lvalue (non-constant)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
pawn Code:
foreach2(w, MAX_WEAPON_SLOTS)
    {
        new string[32];
        format(string, sizeof(string), "Weapon_%d", w);
        INI_Int(string, strval(PlayerInfo[playerid][Weapons][w]));
       
        format(string, sizeof(string), "Ammo_%d", w);
        INI_Int(string, strval(PlayerInfo[playerid][Ammo][w]));
        GivePlayerWeaponEx(playerid, PlayerInfo[playerid][Weapons][w], PlayerInfo[playerid][Ammo][w]);
    }
Reply
#57

Quote:
Originally Posted by Riddick94
View Post
Code:
C:\Documents and Settings\Kakarotto\Pulpit\Sa-Mp Serwer 0.3c\gamemodes\pes.pwn(2159) : error 022: must be lvalue (non-constant)
C:\Documents and Settings\Kakarotto\Pulpit\Sa-Mp Serwer 0.3c\gamemodes\pes.pwn(2162) : error 022: must be lvalue (non-constant)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
pawn Code:
foreach2(w, MAX_WEAPON_SLOTS)
    {
        new string[32];
        format(string, sizeof(string), "Weapon_%d", w);
        INI_Int(string, strval(PlayerInfo[playerid][Weapons][w]));
       
        format(string, sizeof(string), "Ammo_%d", w);
        INI_Int(string, strval(PlayerInfo[playerid][Ammo][w]));
        GivePlayerWeaponEx(playerid, PlayerInfo[playerid][Weapons][w], PlayerInfo[playerid][Ammo][w]);
    }
This is why i mostly use INI_ParseFile.
Wait a minute or more, I'm writing the function. AFTER I EAT
Reply
#58

Are you eating from the trough? xD
Reply
#59

Sorry, I forgot how INI_Int worked, do like ****** said and use strval instead.

pawn Code:
format(string, sizeof(string), "Weapon_%d", w);
if(!strcmp(string, name, true)) PlayerInfo[playerid][Weapons][w] = strval(value);
I would use that my old code, but I'd have the script give the weapons to the player when he/she spawns, not in the loading callback.

I'm not sure if you can give weapons before player is spawned anyway.
Reply
#60

Quote:
Originally Posted by Finn
View Post
Sorry, I forgot how INI_Int worked, do like ****** said and use strval instead.

pawn Code:
format(string, sizeof(string), "Weapon_%d", w);
if(!strcmp(string, name, true)) PlayerInfo[playerid][Weapons][w] = strval(value);
I would use that my old code, but I'd have the script give the weapons to the player when he/she spawns, not in the loading callback.

I'm not sure if you can give weapons before player is spawned anyway.
But he uses it when he logins, so
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)