Дмитрий
Дата: Четверг, 29.03.2012, 22:26 | Сообщение # 1 | Сообщить о нерабочей теме
Регистрация: 03.12.2011
Страна: Российская Федерация
Репутация:
14
Сообщений: 1421
Награды:
4
+
Статус:
Сегодня я поажу вам как можно зделать систему кредита Для начало в enum pInfo в public OnPlayerConnect(playerid) в public PayDay()
if(PlayerInfo[i][pCashCredit] != 0) { if(PlayerInfo[i][pCreditTime] == 0) { new playername[MAX_PLAYER_NAME]; GetPlayerName(i,playername,sizeof(playername)); if(PlayerInfo[i][pPhousekey] != 255 && strcmp(playername, HouseInfo[PlayerInfo[i][pPhousekey]][hOwner], true) == 0) { strmid(HouseInfo[PlayerInfo[i][pPhousekey]][hOwner], "The State", 0, strlen("The State"), 255); PlayerInfo[i][pPhousekey] = 255; SendClientMessage(i, COLOR_YELLOW, "Ты не погасил кредит в банке, у тебя отобрали дом"); PlayerInfo[i][pCredit] = 0; PlayerInfo[i][pCashCredit] = 0; PlayerInfo[i][pCreditTime] = 0; OnPropUpdate(); SavePlayer(i); } else { new newcar = -1; new sendername[MAX_PLAYER_NAME]; GetPlayerName(i,sendername,sizeof(sendername)); for(new cars = 1; cars < CAR_AMOUNT; cars ++) { if(IsAOwnableVehicle(cars) && newcar == -1) { if(!strcmp(CarInfo[cars-SIMPLECARS-1][cOwner],sendername,true)) { newcar = cars-SIMPLECARS-1; strmid(CarInfo[newcar][cOwner], "The State", 0, strlen("The State"), 999); SendClientMessage(i, COLOR_YELLOW, "Ты не погасил кредит в банке, у тебя отобрали машину"); PlayerInfo[i][pCredit] = 0; PlayerInfo[i][pCashCredit] = 0; PlayerInfo[i][pCreditTime] = 0; OnPropUpdate(); SavePlayer(i); } } } if(newcar == -1) { SendClientMessage(i, COLOR_YELLOW, "Ты не погасил кредит в банке, ты в долгах"); ServerGivePlayerMoney(i,-PlayerInfo[i][pCashCredit]); PlayerInfo[i][pCredit] = 0; PlayerInfo[i][pCashCredit] = 0; PlayerInfo[i][pCreditTime] = 0; OnPropUpdate(); SavePlayer(i); } } } else { PlayerInfo[i][pCreditTime] -=1; format(string, sizeof(string), "У тебя осталось %d дней, чтобы погасить кредит в банке", PlayerInfo[i][pCreditTime]); SendClientMessage(i, COLOR_YELLOW, string); } }
в public OnPlayerRegister(playerid, password[])
format(var, 32, "CashCredit=%d\n",PlayerInfo[playerid][pCashCredit]);fwrite(hFile, var); format(var, 32, "Credit=%d\n",PlayerInfo[playerid][pCredit]);fwrite(hFile, var); format(var, 32, "CreditTime=%d\n",PlayerInfo[playerid][pCreditTime]);fwrite(hFile, var);
в public SavePlayer(playerid)
format(var, 32, "CashCredit=%d\n",PlayerInfo[playerid][pCashCredit]);fwrite(hFile, var); format(var, 32, "Credit=%d\n",PlayerInfo[playerid][pCredit]);fwrite(hFile, var); format(var, 32, "CreditTime=%d\n",PlayerInfo[playerid][pCreditTime]);fwrite(hFile, var);
в public OnPlayerLogin(playerid,password[]) Ко всем командам
if(strcmp(cmd, "/кредит", true) == 0)//Дает игроку кредит { if(IsPlayerConnected(playerid)) { if(PlayerInfo[playerid][pLocal] == 103 || PlayerToPoint(1.5, playerid, 1346.5016,-1758.7649,13.5156) || PlayerToPoint(1.5, playerid, 1592.7152,-2335.3748,13.5400) || PlayerToPoint(1.5, playerid, 2308.4612,-1634.4176,14.8270) || PlayerToPoint(1.5, playerid, 2865.9014,-1415.4203,11.0061) || PlayerToPoint(1.5, playerid, 2404.5913,-1229.8973,23.8301) || PlayerToPoint(1.5, playerid, 1172.5912,-1328.4365,15.4034)) { if(PlayerInfo[playerid][pLevel] < 2) { SendClientMessage(playerid, COLOR_GRAD2, "Банк отказал вам в кредите ((кредит со 2 лвла))"); return 1; } if(PlayerInfo[playerid][pCredit] == 5) { SendClientMessage(playerid, COLOR_YELLOW, "Ты уже взял максимально доступную сумму кредита"); return 1; } ServerGivePlayerMoney(playerid,10000); PlayerInfo[playerid][pCashCredit] += 13520; PlayerInfo[playerid][pCredit] += 1; if(PlayerInfo[playerid][pCredit] == 1) { PlayerInfo[playerid][pCreditTime] = 30; } SendClientMessage(playerid, COLOR_YELLOW, "Ты взял кредит в банке на сумму $10000"); format(string, sizeof(string), "Всего вместе с процентами ты должен банку $%d", PlayerInfo[playerid][pCashCredit]); SendClientMessage(playerid, COLOR_YELLOW, string); SavePlayer(playerid); return 1; } else { SendClientMessage(playerid, COLOR_GREY, "Ты не в банке"); return 1; } } return 1; } if(strcmp(cmd, "/погасить", true) == 0)//Забирает кредитные деньги у игрока { if(IsPlayerConnected(playerid)) { if(PlayerInfo[playerid][pLocal] == 103 || PlayerToPoint(1.5, playerid, 1346.5016,-1758.7649,13.5156) || PlayerToPoint(1.5, playerid, 1592.7152,-2335.3748,13.5400) || PlayerToPoint(1.5, playerid, 2308.4612,-1634.4176,14.8270) || PlayerToPoint(1.5, playerid, 2865.9014,-1415.4203,11.0061) || PlayerToPoint(1.5, playerid, 2404.5913,-1229.8973,23.8301) || PlayerToPoint(1.5, playerid, 1172.5912,-1328.4365,15.4034)) { if(PlayerInfo[playerid][pLevel] < 5) { SendClientMessage(playerid, COLOR_GRAD2, " Отказано в кредите!Слишком мало проживаете в штате!"); return 1; } if(PlayerInfo[playerid][pCredit] == 0) { SendClientMessage(playerid, COLOR_YELLOW, " Ты ничего не должен банку!"); return 1; } if(PlayerInfo[playerid][pCash] < PlayerInfo[playerid][pCashCredit]) { format(string, sizeof(string), " За тобой числится кредит на сумму $%d , у тебя нет таких денег", PlayerInfo[playerid][pCashCredit]); SendClientMessage(playerid, COLOR_YELLOW, string); return 1; } ServerGivePlayerMoney(playerid,-PlayerInfo[playerid][pCashCredit]); PlayerInfo[playerid][pCashCredit] = 0; PlayerInfo[playerid][pCredit] = 0; PlayerInfo[playerid][pCreditTime] = 0; SendClientMessage(playerid, COLOR_YELLOW, " Ты погасил свой кредит"); SavePlayer(playerid); return 1; } else { SendClientMessage(playerid, COLOR_GREY, "Ты не в банке"); return 1; } } return 1; }
Вот и все!!!
From Russia With Love!