SA-MP Forums Archive
How do I load and save this enum - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How do I load and save this enum (/showthread.php?tid=468734)



How do I load and save this enum - lramos15 - 10.10.2013

I have this enum
PHP код:
enum fInfo
{
    
fName[100],
    
factionid,
    
rank1[100],
    
rank2[100],
    
rank3[100],
    
rank4[100],
    
rank5[100],
    
rank6[100],
    
rank7[100],
    
rank8[100],
    
rank9[100],
    
rank10[100],
    
skinidrank1,
    
skinidrank2,
    
skinidrank3,
    
skinidrank4,
    
skinidrank5,
    
skinidrank6,
    
skinidrank7,
    
skinidrank8,
    
skinidrank9,
    
skinidrank10
}
new 
FactionInfo[MAX_FACTION][fInfo]; 
but I have no idea how to save or load it can anyone tell me how because I'm almost positive it's not the same as my PlayerInfo which is this
PHP код:
forward LoadUser_data(playerid,name[],value[]);
public 
LoadUser_data(playerid,name[],value[])
{
    
INI_Int("Name"PlayerInfo[playerid][pName]);
    
INI_Int("Password",PlayerInfo[playerid][pPass]);
    
INI_Int("Cash",PlayerInfo[playerid][pCash]);
    
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    
INI_Int("Kills",PlayerInfo[playerid][pKills]);
    
INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    
INI_Int("Skin",PlayerInfo[playerid][pSkin]);
    
INI_Int("aJailed",PlayerInfo[playerid][aJailed]);
    
INI_Bool("Material_Job",PlayerInfo[playerid][MaterialJob]);
    
INI_Int("Materials",PlayerInfo[playerid][pMaterial]);
    
INI_Int("IP_Adress",PlayerInfo[playerid][pAdress]);
    
INI_Int("Faction",PlayerInfo[playerid][Faction]);
    
INI_Int("Rank",PlayerInfo[playerid][Rank]);
    return 
1;




Re: How do I load and save this enum - xVIP3Rx - 10.10.2013

Read this, y_ini tutorial


Re: How do I load and save this enum - Pottus - 10.10.2013

I'm going to recommend from experience to use sqlite instead of ini once you get the hang of it you'll laugh at yourself for using ini. Now don't get me wrong ini can be useful and there is nothing wrong with it at all but when it comes to saving data nothing beats saving to a database.

Wise man says "Know your DB", and there is a wonderful tutorial here to help you every step of the way.

https://sampforum.blast.hk/showthread.php?tid=449536


Re: How do I load and save this enum - lramos15 - 10.10.2013

But I don't want to use databases especially because they are so much harder I just want to know how to load and save that enum


Re: How do I load and save this enum - Misiur - 10.10.2013

They aren't harder. But you have bigger problems than that - you don't know how to use arrays, which will be a pain in the ass in the long run.

pawn Код:
enum fInfo
{
    fName[100],
    factionid,
    skinidrank[10],
}
new FactionRanks[MAX_FACTION][10][100];
new FactionInfo[MAX_FACTION][fInfo];
Why another table? There are problems with strings in 3rd dimension (and you can't access characters the "normal" way). Additionally, read up about custom iterators from y_iterate (known as good ol' foreach), they are awesome.


Re: How do I load and save this enum - edzis84 - 10.10.2013

Databases are much better than saving stats to ini file but anyways.


Код:
#define PATH "/Players/%s.ini"
//you can choose any path and name you want.

Код:
enum fInfo 
{ 
    fName[100], 
    factionid

new FactionInfo[MAX_FACTION][fInfo];
Код:
public OnPlayerDisconnect(playerid, reason)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"FactionData");
    INI_WriteInt(File,"Name",PlayerInfo[playerid][fName]);
    INI_WriteInt(File,"ID",PlayerInfo[playerid][factionid]);
    INI_Close(File);
    return 1;
}
Код:
forward LoadUser_data(playerid,name[],value[]); 
public LoadUser_data(playerid,name[],value[]) 
{ 
    INI_Int("Name", PlayerInfo[playerid][fName]); 
    INI_Int("ID",PlayerInfo[playerid][factionid]); 
    return 1;
}
Код:
stock UserPath(playerid)
{
    new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),PATH,playername);
    return string;
}
P.S not tested.


Re: How do I load and save this enum - lramos15 - 10.10.2013

I dont want to load user data I already have that I want to load the faction enum and sorry about not know how to use arrays Im very new to coding I want each file to save by Factionname.ini


Re: How do I load and save this enum - edzis84 - 10.10.2013

Ohh man, then i don't know cuz im not using ini. When i started to script i also used ini saving but now i realised that mysql are much better and easier.


Re: How do I load and save this enum - lramos15 - 10.10.2013

I find INI the easiest and I'm just starting. Does anyone know who to save and load that faction enum


Re: How do I load and save this enum - xVIP3Rx - 10.10.2013

Did you read ******'s tutorial ?
If not then do so, It'll learn you all about saving and loading from ini files