weapon save ? have solution?
#1

can you have solution ?
i create this system weapon save from the beginning
and i use Y_INI for System Saving why cannot save....


This my enum
PHP код:
enum ammoSave{
    
wId0,
    
wAmmo0,
    
wId1,
    
wAmmo1,
    
wId2,
    
wAmmo2

stock for weaponfile
PHP код:
stock WeaponFile(playerid)
{
    new 
string[128],playername[MAX_PLAYER_NAME];
    
GetPlayerName(playerid,playername,sizeof(playername));
    
format(string,sizeof(string),"akun/Weapon/%s.ini",playername);
    return 
string;

Onplayerconnect
PHP код:
INI_ParseFile(WeaponFile(playerid), "LoadUser_%s", .bExtra true, .extra playerid); 
onplayerdisconnect
PHP код:
//----------------------Weapon Save--------------------------//
    
new weapons[13][6];
    
    for(new 
i=0i<=12i++)
    {
        
GetPlayerWeaponData(playerid,i,weapons[i][0],weapons[i][1]);
        new 
INI:filew INI_Open(WeaponFile(playerid));
        
INI_SetTag(filew,"WeaponSave");
         
INI_WriteInt(filew,"Weapon1",weapons[i][0]);
          
INI_WriteInt(filew,"Ammo1",weapons[i][1]);
          
INI_WriteInt(filew,"Weapon2",weapons[i][2]);
          
INI_WriteInt(filew,"Ammo2",weapons[i][3]);
          
INI_WriteInt(filew,"Weapon3",weapons[i][4]);
          
INI_WriteInt(filew,"Ammo3",weapons[i][5]);
          
INI_Close(filew);
    } 
Load User Weapon
PHP код:
public LoadUser_weapon(playerid,name[],value[])
{
    
INI_Int("Weapon1",SenjataInfo[playerid][wId0]);
    
INI_Int("Ammo1",SenjataInfo[playerid][wAmmo0]);
    
INI_Int("Weapon2",SenjataInfo[playerid][wId1]);
    
INI_Int("Ammo2",SenjataInfo[playerid][wAmmo1]);
    
INI_Int("Weapon3",SenjataInfo[playerid][wId2]);
    
INI_Int("Ammo3",SenjataInfo[playerid][wAmmo2]);
    return 
1;

Onplayerspawn
PHP код:
GivePlayerWeapon(playerid,SenjataInfo[playerid][wId0],SenjataInfo[playerid][wAmmo0]);
    
GivePlayerWeapon(playerid,SenjataInfo[playerid][wId1],SenjataInfo[playerid][wAmmo1]);
    
GivePlayerWeapon(playerid,SenjataInfo[playerid][wId1],SenjataInfo[playerid][wAmmo2]); 

Please Help me bro i will give you rep+ and add credit
Reply
#2

I don't know much about Y_INI, but I think you should make the tag the same as your public tag, so, instead of this:

Код:
 INI_SetTag(filew,"WeaponSave");
You'd do this

Код:
 INI_SetTag(filew,"weapon");
Also, the entire code of saving weapon is wrong, you loop through the opening and closing of the file, which totally destroys the reason why Y_INI exists, i'd do something like this:


EDIT before even posting:

Nevermind everything, while I was writing up an example for you, I noticed not only the mentioned above is wrong, but everything else from loading to saving.

I found this while ******-ing, please use it as an example, try to understand it and make your code from it:

http://pastebin.com/6ABeNvDu
Reply
#3

Quote:
Originally Posted by Troydere
Посмотреть сообщение
I don't know much about Y_INI, but I think you should make the tag the same as your public tag, so, instead of this:

Код:
 INI_SetTag(filew,"WeaponSave");
You'd do this

Код:
 INI_SetTag(filew,"weapon");
Also, the entire code of saving weapon is wrong, you loop through the opening and closing of the file, which totally destroys the reason why Y_INI exists, i'd do something like this:


EDIT before even posting:

Nevermind everything, while I was writing up an example for you, I noticed not only the mentioned above is wrong, but everything else from loading to saving.

I found this while ******-ing, please use it as an example, try to understand it and make your code from it:

http://pastebin.com/6ABeNvDu
thanks for the solution I would understand more deeply
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)