// simple banking script // // thanks to jerbob 1992 // for bank stuff // this script needs >> scriptfiles/banks.txt << to exist #include #include #include #pragma tabsize 0 #define CP_BANK 0 #define CP_BANK_2 2 #define CP_BANK_3 3 #define COLOR_GREY 0xAFAFAFAA //---MAFIA #define COLOR_GREEN 0x33AA33AA //---NEWS #define COLOR_RED 0xAA3333AA //--ZOMBI #define COLOR_YELLOW 0xFFFF00AA //---PIMPS #define COLOR_WHITE 0xFFFFFFAA //---civillian #define COLOR_WHITE2 0xFF4080AA //--- #define COLOR_LIGHTBLUE 0x33CCFFAA //---ARMY #define COLOR_ORANGE 0xFF9900AA //---GANGSTAS #define BANKFILE "banks.txt" new bmsg[250]; new bmsg_s[250]; new File:bfileh; new b_name[MAX_PLAYER_NAME]; new str_b[256]; forward fcreate(filename[]); forward getCheckpointType(playerID); forward checkpointUpdate(); forward SendPlayerFormattedText(playerid, const str[], define); forward SendAllFormattedText(playerid, const str[], define); forward isPlayerInArea(playerID, Float:data[4]); new bank[MAX_PLAYERS]; new playerCheckpoint[MAX_PLAYERS]; #define MAX_POINTS 3 new Float:checkCoords[MAX_POINTS][4] = { {-36.5483,-57.9948, -17.2655,-49.2967}, //BANK {-37.2183,-91.8006, -14.1099,-74.6845}, //BANK_2 {-34.6621,-31.4095, -2.6782,-25.6232} //BANK_3 }; new Float:checkpoints[MAX_POINTS][3] = { {-22.2549,-55.6575,1003.5469}, {-23.0664,-90.0882,1003.5469}, {-33.9593,-29.0792,1003.5573} }; new checkpointType[MAX_POINTS] = { CP_BANK, CP_BANK_2, CP_BANK_3 }; #define MAX_GANGS 20 new gangBank[MAX_GANGS]; new playerGang[MAX_PLAYERS]; main() { print("\n--------------------------------------"); print(" Corpse's Simple Banking FilterScript 0.1 "); print("--------------------------------------\n"); } //----- /*GetVal(numb, str[]) { new bmsg[256], idx; for(new i=0; i= data[0] && X <= data[2] && Y >= data[1] && Y <= data[3]) { return 1; } return 0; } public checkpointUpdate() { for(new i=0; i gangBank[playerGang[playerid]]) moneys = gangBank[playerGang[playerid]]; } else { if(moneys > bank[playerid]) moneys = bank[playerid]; } GivePlayerMoney(playerid, moneys); if(gang) gangBank[playerGang[playerid]] -= moneys; else bank[playerid] -= moneys; if(gang) format(string, sizeof(string), "You have withdrawn $%d, your gang's balance is $%d.", moneys, gangBank[playerGang[playerid]]); else format(string, sizeof(string), "You have withdrawn $%d, your current balance is $%d.", moneys, bank[playerid]); SendClientMessage(playerid, COLOR_YELLOW, string); GetPlayerName(playerid, b_name, MAX_PLAYER_NAME); format(bmsg,sizeof(bmsg),"%s $%d\r\n",b_name,bank[playerid]); bfileh = fopen(BANKFILE,io_append); while(fread(bfileh, bmsg)) { if(strcmp(str_b, b_name, false, strlen(b_name))==0) { str_replace(BANKFILE, bmsg, bmsg); fwrite(bfileh,bmsg); } // else if(strcmp(str_b, b_name, false, strlen(b_name))!=0) { // Its NOT true fwrite(bfileh,bmsg); // } fclose(bfileh); } return 1; } //------------------- /balance if(strcmp(cmd, "/balance", true) == 0 || strcmp(cmd, "/gbalance", true) == 0) { new gang; if(strcmp(cmd, "/gbalance", true) == 0) gang = 1; if(IsPlayerInCheckpoint(playerid) == 0 || getCheckpointType(playerid) != CP_BANK && getCheckpointType(playerid) != CP_BANK_2 && getCheckpointType(playerid) != CP_BANK_3) { SendClientMessage(playerid, COLOR_YELLOW, "You must be at a bank area to use this. ATMs are located in convenience stores."); return 1; } if(gang && playerGang[playerid]==0) { SendClientMessage(playerid, COLOR_RED, "You are not in a gang!"); return 1; } if(gang) format(string, sizeof(string), "Your gang has $%d in the bank.", gangBank[playerGang[playerid]]); else GetPlayerName(playerid, b_name, MAX_PLAYER_NAME); // format(bmsg,sizeof(bmsg),"%s $%d\r\n",b_name,bank[playerid]); bfileh = fopen(BANKFILE,io_read); while(fread(bfileh, bmsg)) { if(strcmp(str_b, b_name, false, strlen(b_name))==0) { format(bmsg, sizeof(bmsg), "%s you have $%d banked",b_name,bank[playerid]); SendClientMessage(playerid, COLOR_YELLOW, bmsg); fclose(bfileh); } else if(strcmp(str_b, b_name, false, strlen(b_name))!=0) { // Its NOT true fclose(bfileh); } } return 1; } return 0; } public OnPlayerEnterCheckpoint(playerid) { switch(getCheckpointType(playerid)) { case CP_BANK: { SendClientMessage(playerid, COLOR_YELLOW, "You are at an ATM. To store money use '/bank amount', to withdraw"); SendClientMessage(playerid, COLOR_YELLOW, "money use '/withdraw amount', and '/balance' to see your balance."); } case CP_BANK_2: { SendClientMessage(playerid, COLOR_YELLOW, "You are at an ATM. To store money use '/bank amount', to withdraw"); SendClientMessage(playerid, COLOR_YELLOW, "money use '/withdraw amount', and '/balance' to see your balance."); } case CP_BANK_3: { SendClientMessage(playerid, COLOR_YELLOW, "You are at an ATM. To store money use '/bank amount', to withdraw"); SendClientMessage(playerid, COLOR_YELLOW, "money use '/withdraw amount', and '/balance' to see your balance."); } } } //-- //-- public OnFilterScriptInit() { SetTimer("checkpointUpdate", 1100, 1); if(!bfileh) {fcreate(BANKFILE);} print("\n--------------------------------------"); print(" corpse's simple banking filterscript 0.1 "); print("--------------------------------------\n"); return 1; } //--- public SendPlayerFormattedText(playerid, const str[], define) { new tmpbuf[256]; format(tmpbuf, sizeof(tmpbuf), str, define); SendClientMessage(playerid, 0xFFFF00AA, tmpbuf); } public SendAllFormattedText(playerid, const str[], define) { new tmpbuf[256]; format(tmpbuf, sizeof(tmpbuf), str, define); SendClientMessageToAll(0xFFFF00AA, tmpbuf); } //--strtok 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 OnFilterScriptExit() { return 1; }