[Help] Save Weapons with Y_INI
#1

how i do for save this in y_ini?

Код HTML:
enum weap
{
weapon0,
weapon0a,
weapon1,
weapon1a,
weapon2,
weapon2a,
weapon3,
weapon3a,
weapon4,
weapon4a,
weapon5,
weapon5a,
weapon6,
weapon6a,
weapon7,
weapon7a,
weapon8,
weapon8a,
weapon9,
weapon9a,
weapon10,
weapon10a,
weapon11,
weapon11a,
weapon12,
weapon12a
};
new Infow[MAX_PLAYERS][weap];

stock SaveWeapons(playerid)
{
GetPlayerWeaponData(playerid, 0, Infow[playerid][weapon0], Infow[playerid][weapon0a]);
GetPlayerWeaponData(playerid, 1, Infow[playerid][weapon1], Infow[playerid][weapon1a]);
GetPlayerWeaponData(playerid, 2, Infow[playerid][weapon2], Infow[playerid][weapon2a]);
GetPlayerWeaponData(playerid, 3, Infow[playerid][weapon3], Infow[playerid][weapon3a]);
GetPlayerWeaponData(playerid, 4, Infow[playerid][weapon4], Infow[playerid][weapon4a]);
GetPlayerWeaponData(playerid, 5, Infow[playerid][weapon5], Infow[playerid][weapon5a]);
GetPlayerWeaponData(playerid, 6, Infow[playerid][weapon6], Infow[playerid][weapon6a]);
GetPlayerWeaponData(playerid, 7, Infow[playerid][weapon7], Infow[playerid][weapon7a]);
GetPlayerWeaponData(playerid, 8, Infow[playerid][weapon8], Infow[playerid][weapon8a]);
GetPlayerWeaponData(playerid, 9, Infow[playerid][weapon9], Infow[playerid][weapon9a]);
GetPlayerWeaponData(playerid, 10, Infow[playerid][weapon10], Infow[playerid][weapon10a]);
GetPlayerWeaponData(playerid, 11, Infow[playerid][weapon11], Infow[playerid][weapon11a]);
GetPlayerWeaponData(playerid, 12, Infow[playerid][weapon12], Infow[playerid][weapon12a]);
}
stock LoadWeapons(playerid)
{
GivePlayerWeapon(playerid, Infow[playerid][weapon0], Infow[playerid][weapon0]);
GivePlayerWeapon(playerid, Infow[playerid][weapon1], Infow[playerid][weapon1a]);
GivePlayerWeapon(playerid, Infow[playerid][weapon2], Infow[playerid][weapon2a]);
GivePlayerWeapon(playerid, Infow[playerid][weapon3], Infow[playerid][weapon3a]);
GivePlayerWeapon(playerid, Infow[playerid][weapon4], Infow[playerid][weapon4a]);
GivePlayerWeapon(playerid, Infow[playerid][weapon5], Infow[playerid][weapon5a]);
GivePlayerWeapon(playerid, Infow[playerid][weapon6], Infow[playerid][weapon6a]);
GivePlayerWeapon(playerid, Infow[playerid][weapon7], Infow[playerid][weapon7a]);
GivePlayerWeapon(playerid, Infow[playerid][weapon8], Infow[playerid][weapon8a]);
GivePlayerWeapon(playerid, Infow[playerid][weapon9], Infow[playerid][weapon9a]);
GivePlayerWeapon(playerid, Infow[playerid][weapon10], Infow[playerid][weapon10a]);
GivePlayerWeapon(playerid, Infow[playerid][weapon11], Infow[playerid][weapon11a]);
GivePlayerWeapon(playerid, Infow[playerid][weapon12], Infow[playerid][weapon12a]);
}
please help me
Reply
#2

bump, help?
Reply
#3

By writing the information into the files? It's not really rocket science. Just use INI_WriteInt with Infow[playerid] and you should be good to go.
Reply
#4

sorry, but i dont know use y_ini D:
i want help :/

i only know basic...
Reply
#5

Then you should read up on it.

I can tell you this much: You need INI_WriteInt to store the information into files. To load them you need to use INI_ParseFile or INI_Load, and use the callbacks to store information from the files into variables.
Reply
#6

Quote:
Originally Posted by LarzI
Посмотреть сообщение
Then you should read up on it.

I can tell you this much: You need INI_WriteInt to store the information into files. To load them you need to use INI_ParseFile or INI_Load, and use the callbacks to store information from the files into variables.
could you give me an example please?
i use this stock in my minigames :

example /joindm, here when tp i use SaveWeapons(playerid);
when player death, i use LoadWeapons(playerid);

but when disconnect and connect again weapons gg (don't load, because i dont insert y_ini action)
Reply
#7

Quote:
Originally Posted by ******
Посмотреть сообщение
Have you tried reading either the y_ini topic or the y_ini tutorial?
EDIT : I NOW READ TUTORIAL AND YES SAVE
problem now is, don't load.

i use this in OnPlayerConnet

INI_Load(UserPath(playerid));

also i define this #define PATH "/SaveWeapons/%s.ini"

why don't load when i restart server?

this in OnPlayerDisconnect

new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"WeaponsSaved");
INI_WriteInt(File,"weapon0",Infow[playerid][weapon0]);
INI_WriteInt(File,"weapon1",Infow[playerid][weapon1]);
INI_WriteInt(File,"weapon2",Infow[playerid][weapon2]);
INI_WriteInt(File,"weapon3",Infow[playerid][weapon3]);
INI_WriteInt(File,"weapon4",Infow[playerid][weapon4]);
INI_WriteInt(File,"weapon5",Infow[playerid][weapon5]);
INI_WriteInt(File,"weapon6",Infow[playerid][weapon6]);
INI_WriteInt(File,"weapon7",Infow[playerid][weapon7]);
INI_WriteInt(File,"weapon8",Infow[playerid][weapon8]);
INI_WriteInt(File,"weapon9",Infow[playerid][weapon9]);
INI_WriteInt(File,"weapon10",Infow[playerid][weapon10]);
INI_WriteInt(File,"weapon11",Infow[playerid][weapon11]);
INI_WriteInt(File,"weapon12",Infow[playerid][weapon12]);
INI_WriteInt(File,"bullet0",Infow[playerid][weapon0a]);
INI_WriteInt(File,"bullet1",Infow[playerid][weapon1a]);
INI_WriteInt(File,"bullet2",Infow[playerid][weapon2a]);
INI_WriteInt(File,"bullet3",Infow[playerid][weapon3a]);
INI_WriteInt(File,"bullet4",Infow[playerid][weapon4a]);
INI_WriteInt(File,"bullet5",Infow[playerid][weapon5a]);
INI_WriteInt(File,"bullet6",Infow[playerid][weapon6a]);
INI_WriteInt(File,"bullet7",Infow[playerid][weapon7a]);
INI_WriteInt(File,"bullet8",Infow[playerid][weapon8a]);
INI_WriteInt(File,"bullet9",Infow[playerid][weapon9a]);
INI_WriteInt(File,"bullet10",Infow[playerid][weapon10a]);
INI_WriteInt(File,"bullet11",Infow[playerid][weapon11a]);
INI_WriteInt(File,"bullet12",Infow[playerid][weapon12a]);
INI_Close(File);
Reply
#8

If you'd read the tutorials completely, you'd notice that y_ini uses callbacks to load files.
Reply
#9

Quote:
Originally Posted by LarzI
Посмотреть сообщение
If you'd read the tutorials completely, you'd notice that y_ini uses callbacks to load files.
yes bro i add also load and dont load idk why :S
You could not give me any example in FS?
please
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)