admin | Дата: Среда, 18.05.2011, 16:22:29 | Сообщение # 1 |
Группа: Администраторы
Сообщений: 3869
| В самое начало мода поместим следующие строки: Code enum orgInfo { orgMoney, orgCharity, }; new OrgInfo[13][orgInfo];// Кол-во фракций(у меня 12) Такс, далее нам надо загрузить наши орг банки: Для этого мы добавляем следующую строку в OnGameModeInit: Теперь управление всем этим: Добавляем в OnPLayerCommandText Code if (strcmp(cmd, "/orgcharity", true) == 0) { if(IsPlayerConnected(playerid)) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_GRAD3,"Используй: /orgcharity [номер орг.] [сумма]"); return 1; } new orgid = strval(tmp); if(orgid < 1 || orgid > 11) { SendClientMessage(playerid, COLOR_GRAD3," Неверный ИД фракции!"); return 1; } tmp = strtok(cmdtext, idx); new orgmoney = strval(tmp); if(orgmoney < 1 || orgmoney > 99999) { SendClientMessage(playerid, COLOR_GRAD3," Неверная сумма (от 1$ до 99999$)!"); return 1; } if(GetPlayerMoney(playerid) < orgmoney) { SendClientMessage(playerid, COLOR_GRAD3," Нема баблишек пацык!"); return 1; } OrgInfo[orgid][orgMoney] += orgmoney; ServerGivePlayerMoney(playerid, -orgmoney); format(string, sizeof(string), " Вы пожертвовали %d$ фракции номер %d (Всего: %d$)", orgmoney, orgid, OrgInfo[orgid][orgMoney]); SendClientMessage(playerid, COLOR_YELLOW, string); SaveOrgs(); } } if (strcmp(cmd, "/orgwithdraw", true) == 0) { if(IsPlayerConnected(playerid)) { if(PlayerInfo[playerid][pLeader] > 0) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_GRAD3,"Используй: /orgcharity [сумма]"); return 1; } new orgmoney = strval(tmp); if(orgmoney < 0 || orgmoney > OrgInfo[PlayerInfo[playerid][pLeader]][orgMoney]) { SendClientMessage(playerid, COLOR_GRAD3," Неверная сумма!"); return 1; } OrgInfo[PlayerInfo[playerid][pLeader]][orgMoney] -= orgmoney; ServerGivePlayerMoney(playerid, orgmoney); format(string, sizeof(string), " Вы снаяли %d$ баблишко осталось: %d$)", orgmoney, OrgInfo[PlayerInfo[playerid][pLeader]][orgMoney]); SendClientMessage(playerid, COLOR_YELLOW, string); } } } if (strcmp(cmd, "/orgmoney", true) == 0) { if(IsPlayerConnected(playerid)) { if(PlayerInfo[playerid][pLeader] > 0) { format(string, sizeof(string), " На счету фракции %d$", OrgInfo[PlayerInfo[playerid][pLeader]][orgMoney]); SendClientMessage(playerid, COLOR_YELLOW, string); } } } Далее собственно создаем наши паблики: Добавляем их после LoadBizz и прочей ереси Code public LoadOrgs() { new arrCoords[2][64]; new strFromFile2[256]; new File: file = fopen("orgbanks.cfg", io_read); if (file) { new idx; while (idx < sizeof(OrgInfo)) { fread(file, strFromFile2); split(strFromFile2, arrCoords, '|'); OrgInfo[idx][orgMoney] = strval(arrCoords[0]); idx++; } fclose(file); } return 1; }
public SaveOrgs() { new idx; new File: file2; while (idx < sizeof(OrgInfo)) { new coordsstring[256]; format(coordsstring, sizeof(coordsstring), "%d\n", OrgInfo[idx][orgMoney]); if(idx == 0) { file2 = fopen("orgbanks.cfg", io_write); } else { file2 = fopen("orgbanks.cfg", io_append); } fwrite(file2, coordsstring); idx++; fclose(file2); } return 1; } Урок окончен Источник:forum.pawno.ru
zm-jail.ru Разработка сайта samp-pawno.ru
|
|
|
|