Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define MAX_MBIZZ 5
- new OnMafiaZONE[MAX_MBIZZ][20];
- new allowedmafiafactions[] = { 16, 17, 18};
- new MafiaOnBattle[MAX_MBIZZ];
- new MafiaTimer[MAX_MBIZZ];
- new MZSafeTime[MAX_MBIZZ];
- enum maf_bizz
- {
- id,
- ID,
- Float:mCoord[4],
- mFraction,
- mFractTime,
- mMatsPrice,
- mDrugsPrice,
- mMineral,
- mFuels[128],
- mFuel[5],
- mEntPrice,
- mBarPrice,
- mMetals[128],
- mNapad
- }
- new MafiaInfo[MAX_MBIZZ][maf_bizz];
- new MafiaCD[20];
- stock LoadMafia()
- {
- new time = GetTickCount();
- mysql_query("SELECT * FROM `"TABLE_MAFIA"`");
- mysql_store_result();
- if(mysql_num_rows() > 0)
- {
- for(new idx = 1; idx <= mysql_num_rows(); idx++)
- {
- mysql_fetch_row(query);
- sscanf(query, "p<|>iiffffiiis[128]iiis[128]fi",
- MafiaInfo[idx][id],
- MafiaInfo[idx][mMatsPrice],
- MafiaInfo[idx][mCoord][0],
- MafiaInfo[idx][mCoord][1],
- MafiaInfo[idx][mCoord][2],
- MafiaInfo[idx][mCoord][3],
- MafiaInfo[idx][mFraction],
- MafiaInfo[idx][mFractTime],
- MafiaInfo[idx][mMineral],
- MafiaInfo[idx][mFuels],
- MafiaInfo[idx][mEntPrice],
- MafiaInfo[idx][mBarPrice],
- MafiaInfo[idx][mDrugsPrice],
- MafiaInfo[idx][mMetals]);
- TOTALMAFIA++;
- sscanf(MafiaInfo[idx][mFuels], "p<,>a<i>[5]", MafiaInfo[idx][mFuel]);
- MafiaInfo[idx][ID] = GangZoneCreate(MafiaInfo[idx][mCoord][0],MafiaInfo[idx][mCoord][1],MafiaInfo[idx][mCoord][2],MafiaInfo[idx][mCoord][3]);
- MafiaOnBattle[idx] = 0;
- MZSafeTime[idx] = 0;
- }
- sscanf(MafiaInfo[1][mMetals], "p<,>iiiii", MafiaMetal[1], MafiaMetal[2], MafiaMetal[3], MafiaMetal[4], MafiaMetal[5]);
- }
- mysql_free_result();
- printf(" [Ielade mafijas]: Tikka ieladetas - %d pings %d (ms)", TOTALMAFIA,GetTickCount() - time);
- }
- stock SaveMZ(idx)
- {
- format(query, sizeof(query), "UPDATE "TABLE_MAFIA" SET minx = '%f', miny = '%f', maxx = '%f', maxy = '%f', fraction = %i WHERE id = %i",
- MafiaInfo[idx][mCoord][0], MafiaInfo[idx][mCoord][1],MafiaInfo[idx][mCoord][2],MafiaInfo[idx][mCoord][3],MafiaInfo[idx][mFraction], idx);
- mysql_query(query);
- return 1;
- }
- stock MzCheck()
- {
- for(new i =0;i<sizeof(MafiaInfo);i++)
- {
- if(MafiaOnBattle[i] == 1 && MZSafeTime[i] == 0)
- {
- MafiaTimer[i] -=5;
- new faction;
- new zl;
- zl = i;
- if(MafiaTimer[i] <=0)
- {
- SendFMes(i,COLOR_RED,"[F] Time is up!");
- MafiaOnBattle[i] =0;
- GangZoneStopFlashForAll(MafiaInfo[i][id]);
- SaveMZ(zl);
- }
- for(new x =0;x<MAX_PLAYERS;x++)
- {
- if(PlayerToKvadrat(x,MafiaInfo[i][mCoord][0], MafiaInfo[i][mCoord][1],MafiaInfo[i][mCoord][2],MafiaInfo[i][mCoord][3])&&IsInAllowedMafia(x))
- {
- if(PlayerInfo[x][pLeader] !=0) {faction = PlayerInfo[x][pLeader];}
- else { faction = PlayerInfo[x][pMember];}
- OnMafiaZONE[i][faction] ++;
- }
- }
- new asd;
- for(new x =0;x<20;x++)
- {
- if(OnMafiaZONE[i][x] > 0 && IsInAllowedMafiaF(x)) asd ++;
- }
- if(asd == 1)
- {
- for(new x =0;x<20;x++)
- {
- if(OnMafiaZONE[i][x] > 0)
- {
- new zx;
- zx = x;
- if(MafiaInfo[i][mFraction] == x) {format(string,90,"[F] %s mafia protected his teritorry!",GetMafiaName(zx)); }
- else
- {format(string,90,"[F] %s mafia won and got new territory!",GetMafiaName(zx)); }
- for(new ads = 8; ads <= 12;ads++) SendFMes(ads, COLOR_LIGHTRED,string);
- MafiaOnBattle[zl] =0;
- MafiaInfo[zl][mNapad] = 0;
- MafiaInfo[zl][mFraction] = zx;
- GangZoneStopFlashForAll(MafiaInfo[zl][ID]);
- GangZoneHideForAll(MafiaInfo[zl][ID]);
- GangZoneShowForAll(MafiaInfo[zl][ID],GetMafiaZoneColor(zl));
- SaveMZ(zl);
- break;
- }
- }
- }
- }
- }
- for(new i =0;i<120;i++)
- {
- for(new z = 0;z<20;z++)
- {
- OnMafiaZONE[i][z] =0;
- }
- }
- return 1;
- }
- forward SecUpdate();
- public SecUpdate()
- {
- MzCheck();
- for(new i = 1; i <= TOTALMAFIA; i++)
- {
- if(MZSafeTime[i] > 0)
- {
- MZSafeTime[i]--;
- if(MZSafeTime[i] == 60 || MZSafeTime[i] == 120)
- {
- format(string,127,"[F] You have %d seconds to get ready!",MZSafeTime[i]);
- SendFMes(MafiaInfo[i][mNapad],COLOR_LIGHTRED,string);
- SendFMes(MafiaInfo[i][mFraction],COLOR_LIGHTRED,string);
- }
- if(MZSafeTime[i] == 0)
- {
- format(string,127,"[F] Warm-up time is over! When there are no your mafia players left, the territory will pass to oponnents.");
- SendFMes(MafiaInfo[i][mNapad],COLOR_LIGHTRED,string);
- SendFMes(MafiaInfo[i][mFraction],COLOR_LIGHTRED,string);
- }
- }
- }
- }
- CMD:mafbizz(playerid, params[])
- {
- if(PlayerLogged[playerid] == 0) return 1;
- if(IsAMafia(playerid))
- {
- if(PlayerInfo[playerid][pRank] < 7) return SendClientMessage(playerid,COLOR_LIGHTRED,"This command is available from rank 7!");
- new faction = PlayerInfo[playerid][pMember];
- if(MafiaCD[faction] > 0) return SendClientMessage(playerid, COLOR_GREY, "You can conquer a territory only one time in 40 minutes!");
- if(!IsInAllowedMafia(playerid)) return SendClientMessage(playerid, COLOR_GREY, "Conquering is already in progress!");
- for(new i = 1;i<=TOTALMAFIA;i++)
- {
- if(PlayerToKvadrat(playerid,MafiaInfo[i][mCoord][0], MafiaInfo[i][mCoord][1],MafiaInfo[i][mCoord][2],MafiaInfo[i][mCoord][3]) && MafiaOnBattle[i] == 0)
- {
- if(MafiaInfo[i][mFraction] == faction) return SendClientMessage(playerid, COLOR_GREY, "This terrtitory already belongs to you faction!");
- format(string, 127,"[F] Mafia %s is attacking, you have 5 minutes to ready-up!", FracInfo[PlayerInfo[playerid][pMember]][fName]);
- SendFMes(MafiaInfo[i][mFraction],COLOR_LIGHTRED,string);
- format(string, 127, "[F] If after 5 mintues you wont be at territory, %s will conquer it!",FracInfo[PlayerInfo[playerid][pMember]][fName]);
- SendFMes(MafiaInfo[i][mFraction],COLOR_LIGHTRED,string);
- format(string,128,"[F] %s started attacking %s. You have 5 minutes to ready-up!",sendername(playerid),GetMafiaName(MafiaInfo[i][mFraction]));
- SendFMes(faction,COLOR_LIGHTRED,string);
- GangZoneFlashForAll(MafiaInfo[i][ID],GetMZColorF(faction));
- MZSafeTime[i] = 300;
- MafiaCD[faction] = 4200;
- MafiaInfo[i][mNapad] = faction;
- MafiaTimer[i] = 720;
- MafiaOnBattle[i] = 1;
- break;
- }
- }
- }
- else SendClientMessage(playerid, COLOR_GREY, YouCanNot);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement