22.07.2012, 16:36
pawn Код:
//================================== HElper=======================================//
enum Helper
{
HMembro[MAX_PLAYER_NAME],
HelpersVaga,
};
new HelperInfo[15][Helper];
forward HelpersCheck(playerid);
forward HelpersVaga();
public HelpCheck(playerid)
{
new idx = 0;
while(idx < sizeof(HelperInfo))
{
if(strcmp(HelperInfo[idx][HMembro],PlayerName(playerid), true ) == 0 )
{
return 1;
}
idx++;
}
return 0;
}
public HelpersVaga()
{
new storedcopname[64];
new File: file = fopen("Configs/Helpers.cfg", io_read);
if (file)
{
new valtmp[MAX_PLAYER_NAME];
while (fread(file, valtmp) > 0)
{
strmid(storedcopname, valtmp, 0, strlen("Vazio"), 255);
if ((strcmp(storedcopname, "Vazio", true, strlen("Vazio")) == 0) && (strlen("Vazio") == strlen(storedcopname)))
{
fclose(file);
VagaSobrando = 1;
return 1;
}
}
}
fclose(file);
VagaSobrando = 0;
return 0;
}
forward LoadHelpers();
forward SaveHelpers();
public SaveHelpers()
{
new idx;
new File: file2;
while (idx < sizeof(HelperInfo))
{
new coordsstring[256];
format(coordsstring, sizeof(coordsstring), "%s,%d\n",HelperInfo[idx][HMembro],HelperInfo[idx][HelpersVaga]);
if(idx == 0)
{
file2 = fopen("Configs/Helpers.cfg", io_write);
}
else
{
file2 = fopen("Configs/Helpers.cfg", io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
return 1;
}
public LoadHelpers()
{
new arrCoords[2][64];
new strFromFile2[256];
new File: file = fopen("Configs/Helpers.cfg", io_read);
if (file)
{
new idx = 0;
while(idx < sizeof(HelperInfo))
{
fread(file, strFromFile2);
split(strFromFile2, arrCoords, ',');
strmid(HelperInfo[idx][HMembro], arrCoords[0], 0, strlen(arrCoords[0]), 255);
HelperInfo[idx][HelpersVaga] = strval(arrCoords[1]);
idx++;
}
}
fclose(file);
return 1;
}