SA-MP Forums

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

 
 
Thread Tools Display Modes
Old 11/03/2011, 09:05 AM   #71
Finn
High-roller
 
Join Date: Jan 2008
Posts: 1,464
Reputation: 382
Default Re: Y_Ini - Let's do it!

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]);
}
Finn is offline  
Old 11/03/2011, 09:07 AM   #72
Riddick94
Banned
 
Join Date: Mar 2010
Location: Poland
Posts: 1,767
Reputation: 223
Default Re: Y_Ini - Let's do it!

Omg INT.. sorry : o
Riddick94 is offline  
Old 11/03/2011, 09:22 AM   #73
Riddick94
Banned
 
Join Date: Mar 2010
Location: Poland
Posts: 1,767
Reputation: 223
Default Re: Y_Ini - Let's do it!

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;
}
Riddick94 is offline  
Old 11/03/2011, 09:38 AM   #74
Riddick94
Banned
 
Join Date: Mar 2010
Location: Poland
Posts: 1,767
Reputation: 223
Default Re: Y_Ini - Let's do it!

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.
Riddick94 is offline  
Old 11/03/2011, 09:43 AM   #75
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
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 ] ) );
__________________
Zh3r0 is offline  
Old 11/03/2011, 09:45 AM   #76
Riddick94
Banned
 
Join Date: Mar 2010
Location: Poland
Posts: 1,767
Reputation: 223
Default Re: Y_Ini - Let's do it!

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 (c) 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]);
    }
Riddick94 is offline  
Old 11/03/2011, 09:50 AM   #77
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:
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 (c) 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
__________________
Zh3r0 is offline  
Old 11/03/2011, 10:18 AM   #78
Riddick94
Banned
 
Join Date: Mar 2010
Location: Poland
Posts: 1,767
Reputation: 223
Default Re: Y_Ini - Let's do it!

Are you eating from the trough? xD
Riddick94 is offline  
Old 11/03/2011, 10:24 AM   #79
Finn
High-roller
 
Join Date: Jan 2008
Posts: 1,464
Reputation: 382
Default Re: Y_Ini - Let's do it!

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.
Finn is offline  
Old 11/03/2011, 10:34 AM   #80
Zh3r0
High-roller
 
Join Date: Mar 2008
Posts: 4,510
Reputation: 398
Default Re: Y_Ini - Let's do it!

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
__________________
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 12:50 AM.


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