20.04.2014, 05:18
//Gangs And Families
I Need help finishing/fixing it... HELP Pleasee
Код:
#define MAX_TURFS 40 #define TWADMINMENU 4050 #define TWEDITTURFSSELECTION 4051 #define TWEDITTURFSMENU 4052 #define TWEDITFCOLORSSELECTION 4053 #define TWEDITFCOLORSMENU 4054 #define TWEDITTURFSOWNER 4055 #define TWEDITTURFSLOCKED 4056 #define TWEDITTURFSVUL 4057 #define TWEDITTURFSPERKS 4058
Код:
TurfWarsAdminMenu(playerid) { new string[128]; format(string,sizeof(string),"Edit Turfs...\nEdit Family Colors..."); ShowPlayerDialog(playerid,TWADMINMENU,DIALOG_STYLE_LIST,"Turf Wars - Admin Menu:",string,"Select","Exit"); } TurfWarsEditTurfsSelection(playerid) { new string[2048]; for(new i = 0; i < MAX_TURFS; i++) { if(TurfWars[i][twOwnerId] != -1) { if(TurfWars[i][twOwnerId] < 0 || TurfWars[i][twOwnerId] > MAX_FAMILY-1) { format(string,sizeof(string),"%s%s - \t(Invalid Family)\n",string,TurfWars[i][twName]); } else { format(string,sizeof(string),"%s%s - \t(%s)\n",string,TurfWars[i][twName],FamilyInfo[TurfWars[i][twOwnerId]][FamilyName]); } } else { format(string,sizeof(string),"%s%s - \t(%s)\n",string,TurfWars[i][twName],"Vacant"); } } ShowPlayerDialog(playerid,TWEDITTURFSSELECTION,DIALOG_STYLE_LIST,"Turf Wars - Edit Turfs Selection Menu:",string,"Select","Back"); } TurfWarsEditTurfsMenu(playerid) { new string[128]; format(string,sizeof(string),"Edit Dimensions...\nEdit Owners...\nEdit Vulnerable Time...\nEdit Locked...\nEdit Perks...\nReset War...\nDestroy Turf"); ShowPlayerDialog(playerid,TWEDITTURFSMENU,DIALOG_STYLE_LIST,"Turf Wars - Edit Turfs Menu:",string,"Select","Back"); } TurfWarsEditTurfsOwner(playerid) { new string[128]; format(string,sizeof(string),"Please enter a family id that you wish to assign to this turf:\n\nHint: Enter -1 if you wish to vacant the turf."); ShowPlayerDialog(playerid,TWEDITTURFSOWNER,DIALOG_STYLE_INPUT,"Turf Wars - Edit Turfs Owner Menu:",string,"Change","Back"); } TurfWarsEditTurfsVul(playerid) { new string[128]; format(string,sizeof(string),"Please enter a Vulnerable countdown time for the turf:"); ShowPlayerDialog(playerid,TWEDITTURFSVUL,DIALOG_STYLE_INPUT,"Turf Wars - Edit Turfs Vulnerable Menu:",string,"Change","Back"); } TurfWarsEditTurfsLocked(playerid) { new string[128]; format(string,sizeof(string),"Lock\nUnlock"); ShowPlayerDialog(playerid,TWEDITTURFSLOCKED,DIALOG_STYLE_LIST,"Turf Wars - Edit Turfs Locked Menu:",string,"Change","Back"); } TurfWarsEditTurfsPerks(playerid) { new string[128]; format(string,sizeof(string),"None\nExtortion"); ShowPlayerDialog(playerid,TWEDITTURFSPERKS,DIALOG_STYLE_LIST,"Turf Wars - Edit Turfs Perks Menu:",string,"Change","Back"); } TurfWarsEditFColorsSelection(playerid) { new string[1024]; for(new i = 0; i < MAX_FAMILY; i++) { format(string,sizeof(string),"%s(ID: %d) %s - (%d)\n",string,i,FamilyInfo[i][FamilyName],FamilyInfo[i][FamilyColor]); } ShowPlayerDialog(playerid,TWEDITFCOLORSSELECTION,DIALOG_STYLE_LIST,"Turf Wars - Edit Family Colors Selection:",string,"Select","Back"); } TurfWarsEditFColorsMenu(playerid) { new string[128]; format(string,sizeof(string),"Please enter a family color id that wish to assign to the family:\n"); ShowPlayerDialog(playerid,TWEDITFCOLORSMENU,DIALOG_STYLE_INPUT,"Turf Wars - Edit Family Colors Menu:",string,"Select","Back"); } InitTurfWars() { for(new i = 0; i < MAX_TURFS; i++) { TurfWars[i][twOwnerId] = -1; TurfWars[i][twActive] = 0; TurfWars[i][twLocked] = 0; TurfWars[i][twSpecial] = 0; TurfWars[i][twTimeLeft] = 0; TurfWars[i][twVulnerable] = 12; TurfWars[i][twAttemptId] = -1; TurfWars[i][twGangZoneId] = -1; TurfWars[i][twAreaId] = -1; TurfWars[i][twFlash] = -1; TurfWars[i][twFlashColor] = 0; } return 1; } CreateTurfWarsZone(forcesync, zone) { if(TurfWars[zone][twMinX] != 0.0 && TurfWars[zone][twMinY] != 0.0 && TurfWars[zone][twMaxX] != 0.0 && TurfWars[zone][twMaxY] != 0.0) { TurfWars[zone][twGangZoneId] = GangZoneCreate(TurfWars[zone][twMinX],TurfWars[zone][twMinY],TurfWars[zone][twMaxX],TurfWars[zone][twMaxY]); TurfWars[zone][twAreaId] = CreateDynamicRectangle(TurfWars[zone][twMinX],TurfWars[zone][twMinY],TurfWars[zone][twMaxX],TurfWars[zone][twMaxY],-1,-1,-1); } if(forcesync) { SyncTurfWarsRadarToAll(); } SaveTurfWars(); } ResetTurfWarsZone(forcesync, zone) { TurfWars[zone][twActive] = 0; TurfWars[zone][twFlash] = -1; TurfWars[zone][twFlashColor] = 0; TurfWars[zone][twTimeLeft] = 0; TurfWars[zone][twAttemptId] = -1; if(forcesync) { SyncTurfWarsRadarToAll(); } SaveTurfWars(); } SetOwnerTurfWarsZone(forcesync, zone, ownerid) { TurfWars[zone][twOwnerId] = ownerid; if(forcesync) { SyncTurfWarsRadarToAll(); } SaveTurfWars(); } DestroyTurfWarsZone(zone) { TurfWars[zone][twActive] = 0; if(TurfWars[zone][twGangZoneId] != -1) { GangZoneDestroy(TurfWars[zone][twGangZoneId]); } if(TurfWars[zone][twAreaId] != -1) { DestroyDynamicArea(TurfWars[zone][twAreaId]); } TurfWars[zone][twMinX] = 0; TurfWars[zone][twMinY] = 0; TurfWars[zone][twMaxX] = 0; TurfWars[zone][twMaxY] = 0; TurfWars[zone][twOwnerId] = -1; TurfWars[zone][twGangZoneId] = -1; TurfWars[zone][twAreaId] = -1; TurfWars[zone][twFlash] = -1; TurfWars[zone][twFlashColor] = 0; TurfWars[zone][twActive] = 0; TurfWars[zone][twLocked] = 0; TurfWars[zone][twSpecial] = 0; TurfWars[zone][twTimeLeft] = 0; TurfWars[zone][twAttemptId] = -1; TurfWars[zone][twVulnerable] = 12; SyncTurfWarsRadarToAll(); SaveTurfWars(); } GetPlayerTurfWarsZone(playerid) { for(new i = 0; i < MAX_TURFS; i++) { if(IsPlayerInDynamicArea(playerid, TurfWars[i][twAreaId])) { return i; } } return -1; } ShutdownTurfWarsZone(zone) { new string[128]; foreach(Player, i) { if(IsPlayerInDynamicArea(i, TurfWars[zone][twAreaId])) { format(string,sizeof(string),"Law Enforcement has attempted to shutdown this turf!"); SendClientMessageEx(i,COLOR_YELLOW,string); } } ResetTurfWarsZone(0, zone); TurfWars[zone][twActive] = 1; TurfWars[zone][twTimeLeft] = 600; TurfWars[zone][twVulnerable] = 0; TurfWars[zone][twAttemptId] = -1; TurfWars[zone][twFlash] = 1; TurfWars[zone][twFlashColor] = 0; SyncTurfWarsRadarToAll(); SaveTurfWars(); } TakeoverTurfWarsZone(familyid, zone) { new string[128]; foreach(Player, i) { if(IsPlayerInDynamicArea(i, TurfWars[zone][twAreaId])) { format(string,sizeof(string),"%s has attempted to takeover this turf for their own!",FamilyInfo[familyid][FamilyName]); SendClientMessageEx(i,COLOR_YELLOW,string); } } ResetTurfWarsZone(0, zone); TurfWars[zone][twActive] = 1; TurfWars[zone][twTimeLeft] = 600; TurfWars[zone][twVulnerable] = 0; TurfWars[zone][twAttemptId] = familyid; TurfWars[zone][twFlash] = 1; TurfWars[zone][twFlashColor] = FamilyInfo[familyid][FamilyColor]; SyncTurfWarsRadarToAll(); } CaptureTurfWarsZone(familyid, zone) { new string[128]; foreach(Player, i) { if(IsPlayerInDynamicArea(i, TurfWars[zone][twAreaId])) { format(string,sizeof(string),"%s has successfully claimed this turf for their own!",FamilyInfo[familyid][FamilyName]); SendClientMessageEx(i,COLOR_RED,string); SendAudioToPlayer(i, 1184, 100, 0); } if(PlayerInfo[i][pGangModerator] == 1) { format(string,sizeof(string),"%s has successfully claimed turf %d",FamilyInfo[familyid][FamilyName], zone); SendClientMessageEx(i,COLOR_RED,string); } } TurfWars[zone][twOwnerId] = familyid; TurfWars[zone][twVulnerable] = 12; ResetTurfWarsZone(1, zone); SaveTurfWars(); } ExtortionTurfsWarsZone(playerid, type, money) { if(GetPlayerTurfWarsZone(playerid) != -1) { if(GetPlayerInterior(playerid) != 0) return 1; // Interior fix new string[128]; new tw = GetPlayerTurfWarsZone(playerid); switch(type) { case 1: // Drugs { if(TurfWars[tw][twOwnerId] != -1) { new ownerid = TurfWars[tw][twOwnerId]; new famid = PlayerInfo[playerid][pFMember]; if(famid != ownerid) { format(string,sizeof(string),"* You have been taxed $%d dollars for selling drugs on %s's Turf.",money/4,FamilyInfo[ownerid][FamilyName]); FamilyInfo[ownerid][FamilyCash] += money/4; GivePlayerCash(playerid, -money/4); SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string); SaveFamilies(); } } } case 2: // Vests { if(TurfWars[tw][twOwnerId] != -1) { new ownerid = TurfWars[tw][twOwnerId]; new famid = PlayerInfo[playerid][pFMember]; if(famid != ownerid) { format(string,sizeof(string),"* You have been taxed $%d dollars for selling vests on %s's Turf.",money/4,FamilyInfo[ownerid][FamilyName]); FamilyInfo[ownerid][FamilyCash] += money/4; GivePlayerCash(playerid, -money/4); SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string); SaveFamilies(); } } } case 3: // Weapons { if(TurfWars[tw][twOwnerId] != -1) { new ownerid = TurfWars[tw][twOwnerId]; new famid = PlayerInfo[playerid][pFMember]; if(famid != ownerid) { format(string,sizeof(string),"* You have been taxed $%d dollars for selling weapons on %s's Turf.",money/4,FamilyInfo[ownerid][FamilyName]); FamilyInfo[ownerid][FamilyCash] += money/4; GivePlayerCash(playerid, -money/4); SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string); SaveFamilies(); } } } case 4: // Sex { if(TurfWars[tw][twOwnerId] != -1) { new ownerid = TurfWars[tw][twOwnerId]; new famid = PlayerInfo[playerid][pFMember]; if(famid != ownerid) { format(string,sizeof(string),"* You have been taxed $%d dollars for selling sex on %s's Turf.",money/4,FamilyInfo[ownerid][FamilyName]); FamilyInfo[ownerid][FamilyCash] += money/4; GivePlayerCash(playerid, -money/4); SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string); SaveFamilies(); } } } } } return 1; } ShowTurfWarsRadar(playerid) { if(turfWarsRadar[playerid] == 1) { return 1; } turfWarsRadar[playerid] = 1; SyncTurfWarsRadar(playerid); return 1; } HideTurfWarsRadar(playerid) { if(turfWarsRadar[playerid] == 0) { return 1; } for(new i = 0; i < MAX_TURFS; i++) { if(TurfWars[i][twGangZoneId] != -1) { GangZoneHideForPlayer(playerid,TurfWars[i][twGangZoneId]); } } turfWarsRadar[playerid] = 0; return 1; } SyncTurfWarsRadarToAll() { foreach(Player, i) { SyncTurfWarsRadar(i); } } SyncTurfWarsRadar(playerid) { if(turfWarsRadar[playerid] == 0) { return 1; } HideTurfWarsRadar(playerid); turfWarsRadar[playerid] = 1; for(new i = 0; i < MAX_TURFS; i++) { if(TurfWars[i][twGangZoneId] != -1) { if(TurfWars[i][twOwnerId] >= 0 && TurfWars[i][twOwnerId] <= MAX_FAMILY-1) { switch(FamilyInfo[TurfWars[i][twOwnerId]][FamilyColor]) { case 0: // Black { GangZoneShowForPlayer(playerid,TurfWars[i][twGangZoneId],COLOR_TWBLACK); } case 1: // White { GangZoneShowForPlayer(playerid,TurfWars[i][twGangZoneId],COLOR_TWWHITE); } case 2: // Red { GangZoneShowForPlayer(playerid,TurfWars[i][twGangZoneId],COLOR_TWRED); } case 3: // Blue { GangZoneShowForPlayer(playerid,TurfWars[i][twGangZoneId],COLOR_TWBLUE); } case 4: // Yellow { GangZoneShowForPlayer(playerid,TurfWars[i][twGangZoneId],COLOR_TWYELLOW); } case 5: // Purple { GangZoneShowForPlayer(playerid,TurfWars[i][twGangZoneId],COLOR_TWPURPLE); } case 6: // Pink { GangZoneShowForPlayer(playerid,TurfWars[i][twGangZoneId],COLOR_TWPINK); } case 7: // Brown { GangZoneShowForPlayer(playerid,TurfWars[i][twGangZoneId],COLOR_TWBROWN); } case 8: // Gray { GangZoneShowForPlayer(playerid,TurfWars[i][twGangZoneId],COLOR_TWGRAY); } case 9: // Olive { GangZoneShowForPlayer(playerid,TurfWars[i][twGangZoneId],COLOR_TWOLIVE); } case 10: // Tan { GangZoneShowForPlayer(playerid,TurfWars[i][twGangZoneId],COLOR_TWTAN); } case 11: // Aqua { GangZoneShowForPlayer(playerid,TurfWars[i][twGangZoneId],COLOR_TWAQUA); } case 12: // Orange { GangZoneShowForPlayer(playerid,TurfWars[i][twGangZoneId],COLOR_TWORANGE); } case 13: // Azure { GangZoneShowForPlayer(playerid,TurfWars[i][twGangZoneId],COLOR_TWAZURE); } case 14: // Green { GangZoneShowForPlayer(playerid,TurfWars[i][twGangZoneId],COLOR_TWGREEN); } } } else { GangZoneShowForPlayer(playerid,TurfWars[i][twGangZoneId],COLOR_BLACK); } if(TurfWars[i][twFlash] == 1) { switch(TurfWars[i][twFlashColor]) { case 0: // Black { GangZoneFlashForPlayer(playerid, TurfWars[i][twGangZoneId],COLOR_TWBLACK); } case 1: // White { GangZoneFlashForPlayer(playerid, TurfWars[i][twGangZoneId],COLOR_TWWHITE); } case 2: // Red { GangZoneFlashForPlayer(playerid, TurfWars[i][twGangZoneId],COLOR_TWRED); } case 3: // Blue { GangZoneFlashForPlayer(playerid, TurfWars[i][twGangZoneId],COLOR_TWBLUE); } case 4: // Yellow { GangZoneFlashForPlayer(playerid, TurfWars[i][twGangZoneId],COLOR_TWYELLOW); } case 5: // Purple { GangZoneFlashForPlayer(playerid, TurfWars[i][twGangZoneId],COLOR_TWPURPLE); } case 6: // Pink { GangZoneFlashForPlayer(playerid, TurfWars[i][twGangZoneId],COLOR_TWPINK); } case 7: // Brown { GangZoneFlashForPlayer(playerid, TurfWars[i][twGangZoneId],COLOR_TWBROWN); } case 8: // Gray { GangZoneFlashForPlayer(playerid, TurfWars[i][twGangZoneId],COLOR_TWGRAY); } case 9: // Olive { GangZoneFlashForPlayer(playerid, TurfWars[i][twGangZoneId],COLOR_TWOLIVE); } case 10: // Tan { GangZoneFlashForPlayer(playerid, TurfWars[i][twGangZoneId],COLOR_TWTAN); } case 11: // Aqua { GangZoneFlashForPlayer(playerid, TurfWars[i][twGangZoneId],COLOR_TWAQUA); } case 12: // Orange { GangZoneFlashForPlayer(playerid, TurfWars[i][twGangZoneId],COLOR_TWORANGE); } case 13: // Azure { GangZoneFlashForPlayer(playerid, TurfWars[i][twGangZoneId],COLOR_TWAZURE); } case 14: // Green { GangZoneFlashForPlayer(playerid, TurfWars[i][twGangZoneId],COLOR_TWGREEN); } } } else { GangZoneStopFlashForPlayer(playerid, TurfWars[i][twGangZoneId]); } } } return 1; } LoadTurfWars() { print("Loading Turfs."); if(!fexist("turfwars.cfg")) return 1; new szFileStr[1024], File: fHandle = fopen("turfwars.cfg", io_read), iIndex; while(iIndex < MAX_TURFS && fread(fHandle, szFileStr)) { sscanf(szFileStr, "p<|>s[64]iiiiffff", TurfWars[iIndex][twName], TurfWars[iIndex][twOwnerId], TurfWars[iIndex][twLocked], TurfWars[iIndex][twSpecial], TurfWars[iIndex][twVulnerable], TurfWars[iIndex][twMinX], TurfWars[iIndex][twMinY], TurfWars[iIndex][twMaxX], TurfWars[iIndex][twMaxY] ); CreateTurfWarsZone(0, iIndex++); } return fclose(fHandle); } CMD:twmenu(playerid, params[]) { if(PlayerInfo[playerid][pAdmin] > 3 || PlayerInfo[playerid][pGangModerator] == 1) { TurfWarsAdminMenu(playerid); } else { SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use this command!"); } return 1; } CMD:claim(playerid, params[]) { new string[128]; new tw = GetPlayerTurfWarsZone(playerid); new family = PlayerInfo[playerid][pFMember]; new rank = PlayerInfo[playerid][pRank]; if(family == 255) { SendClientMessageEx(playerid, COLOR_GRAD2, "You are not in a family/gang, you can not claim turfs!"); return 1; } if(rank < 5) { SendClientMessageEx(playerid, COLOR_GRAD2, "You have to be at least Rank 5 to claim turfs!"); return 1; } if(FamilyInfo[family][FamilyTurfTokens] < 12) { SendClientMessageEx(playerid, COLOR_GRAD2, "Your family/gang does not have any turf claim tokens, please wait at least 12 hours."); return 1; } if(tw != -1) { if(TurfWars[tw][twLocked] == 1) { SendClientMessageEx(playerid, COLOR_GRAD2, "The turf is currently locked by a admin, you can not claim it!"); return 1; } if(TurfWars[tw][twVulnerable] == 0) { if(TurfWars[tw][twActive] == 0) { if(TurfWars[tw][twOwnerId] == family) { SendClientMessageEx(playerid, COLOR_GRAD2, "Your family/gang already owns this turf, you are unable to claim it!"); return 1; } new count = 0; foreach(Player, i) { if(family == PlayerInfo[i][pFMember]) { if(GetPlayerTurfWarsZone(i) == tw) { count++; } } } if(count > 2) { FamilyInfo[family][FamilyTurfTokens] -= 12; TakeoverTurfWarsZone(family, tw); } else { SendClientMessageEx(playerid, COLOR_GRAD2, "You need at least 3 of your family/gang members on the turf, to be able to claim it!"); } } else { new count = 0; new leocount = 0; if(TurfWars[tw][twAttemptId] == family) { SendClientMessageEx(playerid, COLOR_GRAD2, "You are already attempting to capture this turf!"); return 1; } foreach(Player, i) { if(TurfWars[tw][twAttemptId] == PlayerInfo[i][pFMember]) { if(GetPlayerTurfWarsZone(i) == tw) { count++; } } if(TurfWars[tw][twAttemptId] == -1) { if(IsACop(i)) { if(GetPlayerTurfWarsZone(i) == tw) { leocount++; } } } } if(count == 0 && leocount == 0) { if(family != TurfWars[tw][twOwnerId]) { FamilyInfo[family][FamilyTurfTokens] -= 12; } foreach(Player, i) { if(PlayerInfo[i][pGangModerator] == 1) { format(string,sizeof(string),"%s has attempted to takeover turf %d for family %s",GetPlayerNameEx(playerid),tw,FamilyInfo[family][FamilyName]); SendClientMessageEx(i,COLOR_YELLOW,string); } } TakeoverTurfWarsZone(family, tw); } else { if(leocount == 0) { format(string,sizeof(string),"There is still %d Attacking Members on the Turf, you must get rid of them before reclaiming!",count); SendClientMessageEx(playerid, COLOR_GRAD2, string); } else { format(string,sizeof(string),"There is still %d Officers on the Turf, you must get rid of them before reclaiming!",leocount); SendClientMessageEx(playerid, COLOR_GRAD2, string); } } } } else { SendClientMessageEx(playerid, COLOR_GRAD2, "This turf is currently not vulnerable, you are unable to claim it!"); } } else { SendClientMessageEx(playerid, COLOR_GRAD2, "You have to be in a turf to be able to claim turfs!"); } if(turfWarsRadar[playerid] == 0) { ShowTurfWarsRadar(playerid); } return 1; } CMD:turfinfo(playerid, params[]) { if(GetPlayerTurfWarsZone(playerid) != -1) { new string[128]; new tw = GetPlayerTurfWarsZone(playerid); format(string,sizeof(string),"|___________ (ID: %d) %s ___________|",tw,TurfWars[tw][twName]); SendClientMessageEx(playerid, COLOR_GREEN, string); if(TurfWars[tw][twOwnerId] != -1) { format(string,sizeof(string),"Owner: %s.",FamilyInfo[TurfWars[tw][twOwnerId]][FamilyName]); } else { format(string,sizeof(string),"Owner: Vacant."); } SendClientMessageEx(playerid, COLOR_WHITE, string); format(string,sizeof(string),"Vulnerable: %d Hours.",TurfWars[tw][twVulnerable]); SendClientMessageEx(playerid, COLOR_WHITE, string); format(string,sizeof(string),"Locked: %d.",TurfWars[tw][twLocked]); SendClientMessageEx(playerid, COLOR_WHITE, string); format(string,sizeof(string),"Active: %d.",TurfWars[tw][twActive]); SendClientMessageEx(playerid, COLOR_WHITE, string); if(TurfWars[tw][twActive] != 0) { format(string,sizeof(string),"Time Left: %d Secs.",TurfWars[tw][twTimeLeft]); SendClientMessageEx(playerid, COLOR_WHITE, string); if(TurfWars[tw][twAttemptId] == -1) { format(string,sizeof(string),"Takeover Faction: Law Enforcement."); SendClientMessageEx(playerid, COLOR_WHITE, string); } else { format(string,sizeof(string),"Takeover Family: %s.",FamilyInfo[TurfWars[tw][twAttemptId]][FamilyName]); SendClientMessageEx(playerid, COLOR_WHITE, string); } } switch(TurfWars[tw][twSpecial]) { case 1: { format(string,sizeof(string),"Special Perks: Extortion."); } default: { format(string,sizeof(string),"Special Perks: None."); } } SendClientMessageEx(playerid, COLOR_WHITE, string); } else { SendClientMessageEx(playerid, COLOR_WHITE, "You are not in a turf!"); } return 1; }