#define MAX_CLANS 50
enum ClanInfo
{
Test[64]
}
new ClanDB[MAX_CLANS][ClanInfo];
#define LoadClanData INI_ParseFile(clanFile(), "LoadClan", .bExtra = true);
public OnGameModeInit()
{
LoadClanData();
return 1;
}
function LoadClan(name[], value[])
{
for(new i = 0; i < MAX_CLANS; i++){
INI_String("Test",ClanDB[i][Test],64);}
return 1;
}
stock SaveClanFile()
{
for(new i = 0; i < MAX_CLANS; i++){
new INI:cf = INI_Open(clanFile());
INI_SetTag(cf, "Database");
INI_WriteString(cf,"Test",ClanDB[MAX_CLANS][Test]);
INI_Close(cf);}
}
stock clanFile()
{
new String[64];
for(new i = 0; i < MAX_CLANS; i++){
format(String,sizeof(String),"Clans/%s.ini",i);}
return String;
}
CMD:test(playerid,params[]){
LoggedCMD OwnerCMD
new String[128];
for(new i = 0; i < MAX_CLANS; i++){
format(String,sizeof(String),"%s",ClanDB[i][Test]);
MSG(playerid,-1,String);}
return 1;}
I tried to get a string from a file of a clan but when i try to use /test it shows nothing
PHP код:
|
Rewrite your whole code:
There is no intendation. Your LoadClanData is completly wrong. Your LoadClan is wrong too. DB[playerid][Clan] is an intenger and a string as the same time in your script. Your whole code is horrible to read. NB: Don't use stock. |
I fixed most of the issues, please check again the code up there I edited it.
and yea, I'm aware to the fact my code is horrible to read but I got used to it and I hate making it normal it takes a lot of space. I like it all tiny. |
#define MAX_CLANS 50
enum ClanInfo
{
Test[64]
}
new ClanDB[MAX_CLANS][ClanInfo];
public OnGameModeInit()
{
LoadClanData();
return 1;
}
forward LoadClan_data(clanid, name[],value[]);
public LoadClan_data(clanid, name[],value[])
{
INI_String("Test",ClanDB[clanid][Test],64);
return 1;
}
SaveClanFile()
{
for(new i = 0; i < MAX_CLANS; i++)
{
new INI:cf = INI_Open(clanFile(i));
INI_SetTag(cf, "Database");
INI_WriteString(cf,"Test",ClanDB[i][Test]);
INI_Close(cf);
}
}
clanFile(const clanid)
{
static String[64];
format(String,sizeof(String),"Clans/%s.ini",clanid);
return String;
}
LoadClanData()
{
for(new i; i<MAX_CLANS; i++)
{
if(!fexist(clanFile(i))) continue;
INI_ParseFile(clanFile(i), "LoadClan_data", .bExtra = true);
//INI_ParseFile(clanFile(i), "LoadClan_data", .bExtra = true, .extra = i); -> Only if the line above doesn't work.
}
}
/*
CMD:test(playerid,params[]){
LoggedCMD OwnerCMD
new String[128];
for(new i = 0; i < MAX_CLANS; i++){
format(String,sizeof(String),"%s",ClanDB[i][Test]);
MSG(playerid,-1,String);}
return 1;} */
CMD:test(playerid)
{
for(new i; i<MAX_CLANS; i++)
{
format(String,sizeof(String),"%s",ClanDB[i][Test]);
MSG(playerid,-1,String);
}
return 1;
}