stariy_fighter
Новичок
Привет всем, есть баг с выборами при сохранении в файл добавляется новое число через запятую, помогите плз с меня +
PHP:
Диалог выбора кандидата:
else if(dialogid == 9216)
{
if(!response)
{
new String_[MAX_CANDIDATES*(MAX_PLAYER_NAME+36)];
ini_openFile("candidates.ini");
new File = ini_openFile("candidates.ini");
new temp_string[9];
for(new i = 0; i < MAX_CANDIDATES; i++)
{
format(temp_string, sizeof temp_string, "Cand%d", i+1);
if(ini_getString(File, temp_string, Candidates[i]) == INI_KEY_NOT_FOUND) break;
new startbracket = strfind(Candidates[i], "(", true),
endbracket = strfind(Candidates[i], ")", true);
strmid(temp_string, Candidates[i], startbracket+1, endbracket);
Votes[i] = strval(temp_string);
strdel(Candidates[i], startbracket, endbracket);
f(String,"%d. Èìÿ: %s,\n", i+1, Candidates[i], Votes[i]);
strcat(String_, String);
}
ini_closeFile(File);
ShowPlayerDialog(playerid, 9215, DIALOG_STYLE_LIST, "{ECCC15}Çà êîãî âû õîòèòå ïðîãîëîñîâàòü?", String_, "Ãîëîñîâàòü", "Îòìåíà");
}
else
{
ApplyAnimation(playerid,"CRIB","CRIB_Use_Switch",4.0,0,0,0,0,0);
RemovePlayerAttachedObject(playerid, 8);
Voting[playerid] = false;
format(String, sizeof(String), "Âû îòäàëè ñâîé ãîëîñ çà %s", Candidates[GetPVarInt(playerid, "Vote")]);
SendClientMessage(playerid, -1, String);
Voted[playerid] = true;
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
format(String, sizeof String, "%s/%s.ini", ACCOUNTS_DIRECTORY, Name);
new File = ini_openFile(String);
ini_setInteger(File, "Voted", 1);
ini_closeFile(File);
Votes[GetPVarInt(playerid, "Vote")] ++;
SaveCandidate(GetPVarInt(playerid, "Vote"));
}
}
Сток сохранения кандидата:
stock SaveCandidate(candidate) // ?????????? ?????????
{
new temp_string[9];
format(temp_string, sizeof temp_string, "Cand%d", candidate+1);
format(String, sizeof String, "%s ãîëîñà: %d", Candidates[candidate], Votes[candidate]);
new File = ini_openFile("candidates.ini");
ini_setString(File, temp_string, String);
ini_closeFile(File);
}
