| Stepan23 | Дата: Среда, 15.12.2010, 21:17 | Сообщение # 1 |
 Майор
Группа: Администраторы
Сообщений: 91
Статус: Offline
| Здравствуите с вами снова Stepan23 И сегодня будет урок на тему: (Создание АТМ банкомата) Code if(strcmp(cmd, “/putmoney”, true) == 0) { if(IsPlayerConnected(playerid)) { if(IsAtBankoms(playerid)) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_GRAD2, ” Используйте: /putmoney [значение]“); format(string, sizeof(string), ” Вы имеите $%d на вашем счету.”, PlayerInfo[playerid][pAccount]); SendClientMessage(playerid, COLOR_GRAD3, string); return 1; } new cashdeposit = strval(tmp); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_GRAD2, ” Используйте: /putmoney [значение]“); format(string, sizeof(string), ” Вы имеите $%d на вашем счету.”, PlayerInfo[playerid][pAccount]); SendClientMessage(playerid, COLOR_GRAD3, string); return 1; } if (cashdeposit > GetPlayerCash(playerid) || cashdeposit < 1) { SendClientMessage(playerid, COLOR_GRAD2, ” У вас нет столько денег”); return 1; } GivePlayerMoney(playerid,-cashdeposit); new curfunds = PlayerInfo[playerid][pAccount]; PlayerInfo[playerid][pAccount]=cashdeposit+PlayerInfo[playerid][pAccount]; SendClientMessage(playerid, COLOR_WHITE, “|___ Чек ___|”); format(string, sizeof(string), ” Старый баланс: $%d”, curfunds); SendClientMessage(playerid, COLOR_GRAD2, string); format(string, sizeof(string), ” Депозит: $%d”,cashdeposit); SendClientMessage(playerid, COLOR_GRAD4, string); SendClientMessage(playerid, COLOR_GRAD6, “|—————————————–|”); format(string, sizeof(string), ” Новый баланс: $%d”, PlayerInfo[playerid][pAccount]); SendClientMessage(playerid, COLOR_WHITE, string); return 1; } SendClientMessage(playerid, COLOR_GREY, ” Вы не у банкомата !”); return 1; } return 1; } IsAtBankoms(playerid) – Это проверка на координаты, сюда вы встваите свои координаоты, например PlayerToPoint итд итп /putmoney это у нас положить деньги … Теперь что касаеться снятия Code if(strcmp(cmd, “/getmoney”, true) == 0) { if(IsPlayerConnected(playerid)) { if(IsAtBankoms(playerid)) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_GRAD2, ” Используйте: /getmoney [значение]“); format(string, sizeof(string), ” Bы имеите $%d на счету.”, PlayerInfo[playerid][pAccount]); SendClientMessage(playerid, COLOR_GRAD3, string); return 1; } new cashdeposit = strval(tmp); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_GRAD2, ” Используйте: /getmoney [значение]“); format(string, sizeof(string), ” Вы имеите $%d на счету.”, PlayerInfo[playerid][pAccount]); SendClientMessage(playerid, COLOR_GRAD3, string); return 1; } if (cashdeposit > PlayerInfo[playerid][pAccount] || cashdeposit < 1) { SendClientMessage(playerid, COLOR_GRAD2, ” У вас нету столько денег !”); return 1; } ConsumingMoney[playerid] = 1; GivePlayerMoney(playerid,cashdeposit); PlayerInfo[playerid][pAccount]=PlayerInfo[playerid][pAccount]-cashdeposit; format(string, sizeof(string), ” Вы сняли с вашего счета$%d Остаток: $%d “, cashdeposit,PlayerInfo[playerid][pAccount]); SendClientMessage(playerid, COLOR_YELLOW, string); return 1; } SendClientMessage(playerid, COLOR_GREY, ” Вы не у банкомата !”); return 1; } return 1; } опятьже IsAtBankoms – проверка на координаты Если у вас много бонкаматов, то можите координаты обьединить в IsAtBankoms, для этого в самое начало Code forward IsAtBankoms(playerid); После этого в любом удобном месте создаёте Code public IsAtBankoms(playerid) { if(IsPlayerConnected(playerid)) { if(PlayerToPoint(4.0,playerid,-2052.7466,-83.6653,35.3203) || PlayerToPoint(4.0,playerid,-2052.7466,-83.6653,35.3203)) {//Облась действия Банкоматов return 1; } if(PlayerToPoint(4.0,playerid,58.9129,-1533.4987,5.2239) || PlayerToPoint(4.0,playerid,58.9129,-1533.4987,5.2239)) {//Облась действия Банкоматов return 1; } } return 0; } На этом урок закончен.
|
| |
|
|