21.06.2011, 10:15
Payday:
/signcheck
Код:
public PayDay() { new string[128]; //new account,interest; //foreach(Player, i) if(RobStatus[BankReload] == 1) { RobStatus[BankReload] = 0; /* DestroyObject(bankvault1); DestroyObject(bankvault2); bankvault1 = CreateObject(2634,2311.10668945,-0.46759671,26.88641739,0.00000000,0.00000000,270.00000000);*/ } if(RobStatus[BankReload] == 2) { RobStatus[BankReload] = 1; } for(new i; i<MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if(PlayerInfo[i][pLevel] > 0) { CheckNumber[i] = Random(1000,9999); format(string, 128, "** Type /signcheck %d to recive your paycheck", CheckNumber[i]); SendClientMessage(i, COLOR_LIGHTBLUE, string); if(MoneyMessage[i] == 1 && PlayerInfo[i][pJailed] == 0) { SendClientMessage(i, COLOR_LIGHTRED, "You failed to pay your debt, Jail time."); SetPlayerInterior(i, 0); SetPlayerPos(i, 264.6288, 77.5742, 1001.0391); ResetPlayerWeapons(i); ClearGuns(i); TogglePlayerControllable(i, 1); PlayerInfo[i][pWantedLevel] = 0; PlayerInfo[i][pJailed] = 1; PlayerInfo[i][pJailTime] = 240; format(string, sizeof(string), "* You are jailed for %d seconds, Bail: Unavailable.", PlayerInfo[i][pJailTime]); SendClientMessage(i, COLOR_LIGHTBLUE, string); } } } } return 1; } strtok(const string[], &index) { new length = strlen(string); while ((index < length) && (string[index] <= ' ')) { index++; } new offset = index; new result[20]; while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1))) { result[index - offset] = string[index]; index++; } result[index - offset] = EOS; return result; } public split(const strsrc[], strdest[][], delimiter) { new i, li; new aNum; new len; while(i <= strlen(strsrc)){ if(strsrc[i]==delimiter || i==strlen(strsrc)){ len = strmid(strdest[aNum], strsrc, li, i, 128); strdest[aNum][len] = 0; li = i+1; aNum++; } i++; } return 1; }
Код:
if(strcmp(cmd, "/signcheck", true) == 0) { //new string[128]; new account,interest; if(!strlen(cmdtext[11])) { SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /signcheck [check number]"); return 1; } new number = strval(cmdtext[11]); if(number < 1000 || number > 9999) { SendClientMessage(playerid, COLOR_GREY, " You can't use that check number"); return 1; } if(number == CheckNumber[playerid]) { new tmpintrate = 1; //interest rate if(PlayerInfo[playerid][pDonateRank] == 1){ tmpintrate = 2; } GetPlayerName(playerid, sendername, sizeof(sendername)); account = PlayerInfo[playerid][pAccount]; //bank account amount if(PlayerInfo[playerid][pPayDay] >= 5) { new checks = PlayerInfo[playerid][pPayCheck]; //paycheck amount new incometax = PlayerInfo[playerid][pPayCheck] / 100 * Tax; //income tax amount PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]+checks-incometax; //give money GivePlayerMoney(playerid, checks-incometax); //give money //TAX MONEY TaxValue = TaxValue+incometax; //ELECTRICITY //INTEREST interest = (PlayerInfo[playerid][pAccount]/1000)*(tmpintrate); //bank interest PlayerInfo[playerid][pAccount] = account+interest; //add interest money to bank //EXP PlayerInfo[playerid][pExp]++; //experience points SendClientMessage(playerid, COLOR_WHITE, "|___ BANK STATEMENT ___|"); format(string, sizeof(string), " Paycheck: $%d", checks); SendClientMessage(playerid, COLOR_GRAD1, string); format(string, sizeof(string), " Income Tax: -$%d", incometax); SendClientMessage(playerid, COLOR_GRAD1, string); format(string, sizeof(string), " Balance: $%d", account); SendClientMessage(playerid, COLOR_GRAD1, string); format(string, sizeof(string), " Interest Rate: 0.%d percent",tmpintrate); SendClientMessage(playerid, COLOR_GRAD2, string); format(string, sizeof(string), " Interest Gained $%d", interest); SendClientMessage(playerid, COLOR_GRAD3, string); SendClientMessage(playerid, COLOR_GRAD4, "|------------------------------------------|"); format(string, sizeof(string), " New Balance: $%d", PlayerInfo[playerid][pAccount]); SendClientMessage(playerid, COLOR_GRAD5, string); format(string, sizeof(string), "~y~PayDay~n~~w~Paycheck"); GameTextForPlayer(playerid, string, 5000, 1); PlayerInfo[playerid][pPayDay] = 0; PlayerInfo[playerid][pPayCheck] = 0; PlayerInfo[playerid][pConnectTime] += 1; } else { SendClientMessage(playerid, COLOR_LIGHTRED, "* You haven't played long enough to obtain a Paycheck."); } } return 1; }