Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <mxINI>
- #include <streamer>
- #define MAX_MAP 50 //Максимум загруженных карт
- #define MAX_PLAYER_DM 10 //Максимум игроков в одной ДМ зоне
- #define MAX_DM 100 //Максимум ДМ зон
- #define PLAYER_AMMO 50 //Патроны, выдаваемые игроку
- #define Map::%0() forward %0(); public %0()
- new MapLoaded = -1;
- new MapName[MAX_MAP][50];
- new Float:MapCordSpawn[MAX_MAP][MAX_PLAYER_DM][3];
- new MapInt[MAX_MAP];
- enum Dinfo
- {
- Mapid,
- Name[40],
- Gun,
- PlayerCol,
- Players,
- }
- enum PDMi
- {
- Mapid,
- Name[40],
- Gun,
- PlayerCol,
- did,
- }
- new PlayerDM[MAX_PLAYERS][PDMi];
- new DM_info[MAX_DM][Dinfo];
- new DM_Created[MAX_DM];
- new DD[MAX_PLAYERS][MAX_DM];
- new DD1[MAX_PLAYERS];
- new RandomGun[21] = {16,18,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,41,42,4};
- //==============================================================================
- #include "../Map"
- //==============================================================================
- public OnFilterScriptInit()
- {
- Map_load("Map1","Карта #1");
- Map_load("Angar","Ангар");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- PlayerDM[playerid][did] = -1;
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- print("Go");
- DM_reconnect(playerid);
- print("Go1");
- return 0;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(!strcmp(cmdtext, "/дм", true))
- {
- ShowPlayerDialog(playerid,1,DIALOG_STYLE_LIST,"DM Zones","Создать\nПрисоединиться","Выбор","Отмена");
- return 1;
- }
- if(!strcmp(cmdtext, "/s", true)) return SetPlayerHealth(playerid,0.0);
- if(!strcmp(cmdtext, "/выход", true)) return DM_exit(playerid);
- if(!strcmp(cmdtext, "/ЫЫ", true)) return SetPlayerPos(playerid,218.2859955,-2238.4440918,6.1450000);
- return 0;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == 1)
- {
- if(response)
- {
- if(!listitem)
- {
- ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"DM Zones","Введите название ДМ зоны","Ввод","Отмена");
- }
- if(listitem == 1)
- {
- new string[250],str[40],
- col = -1;
- for(new i;i<MAX_DM;i++)
- {
- if(DM_Created[i] == 0) continue;
- col++;
- DD[playerid][col] = i;
- format(str,sizeof(str),"%s\n",DM_info[i][Name]);
- strcat(string,str);
- }
- if(col != -1) ShowPlayerDialog(playerid,7,DIALOG_STYLE_LIST,"Выберите DM зону",string,"Выбор","Отмена");
- else SendClientMessage(playerid,0xFF0000AA,"Ни одной DM зоны не создано!");
- }
- }
- return 1;
- }
- if(dialogid == 2)
- {
- if(response)
- {
- if(!strlen(inputtext)) return ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"DM Zones","Введите название ДМ зоны","Ввод","Отмена");
- strmid(PlayerDM[playerid][Name], inputtext, 0, strlen(inputtext), 255);
- ShowPlayerDialog(playerid,3,DIALOG_STYLE_INPUT,"DM Zones","Введите максимальное количество игроков","Ввод","Отмена");
- }
- }
- if(dialogid == 3)
- {
- if(response)
- {
- new col = strval(inputtext);
- if(col < 2 || col > 10)
- {
- ShowPlayerDialog(playerid,3,DIALOG_STYLE_INPUT,"DM Zones","Введите максимальное количество игроков","Ввод","Отмена");
- SendClientMessage(playerid,0xFF0000AA,"Не меньше 2 и не больше 10 игроков!");
- return 1;
- }
- PlayerDM[playerid][PlayerCol] = col;
- ShowPlayerDialog(playerid,4,DIALOG_STYLE_LIST,"Выберите Режим","Одно оружие\nСлучайное оружие","Выбор","Отмена");
- }
- }
- if(dialogid == 4)
- {
- if(response)
- {
- if(!listitem)
- {
- ShowPlayerDialog(playerid,5,DIALOG_STYLE_LIST,"Выберите Оружие","\
- 9mm\n\
- Deagle\n\
- ShotGun\n\
- Combat Shotgun\n\
- Micro UZI\n\
- MP5\n\
- AK-47\n\
- M4\n\
- Tec9\n\
- Country Rifle\n\
- RPG\n\
- HS Rocket\n","Выбор","Отмена");
- }
- if(listitem)
- {
- PlayerDM[playerid][Gun] = -1;
- new string[200],str[40];
- for(new i;i<MapLoaded+1;i++)
- {
- format(str,sizeof(str),"%s\n",MapName[i]);
- strcat(string, str);
- }
- ShowPlayerDialog(playerid,6,DIALOG_STYLE_LIST,"Выберите карту",string,"Выбор","Отмена");
- }
- }
- }
- if(dialogid == 5)
- {
- if(response)
- {
- switch(listitem)
- {
- case 0: PlayerDM[playerid][Gun] = 23;
- case 1: PlayerDM[playerid][Gun] = 24;
- case 2: PlayerDM[playerid][Gun] = 25;
- case 3: PlayerDM[playerid][Gun] = 26;
- case 4: PlayerDM[playerid][Gun] = 28;
- case 5: PlayerDM[playerid][Gun] = 29;
- case 6: PlayerDM[playerid][Gun] = 30;
- case 7: PlayerDM[playerid][Gun] = 31;
- case 8: PlayerDM[playerid][Gun] = 32;
- case 9: PlayerDM[playerid][Gun] = 33;
- case 10: PlayerDM[playerid][Gun] = 35;
- case 11: PlayerDM[playerid][Gun] = 36;
- }
- new string[200],
- str[40];
- for(new i;i<MapLoaded+1;i++)
- {
- format(str,sizeof(str),"%s\n",MapName[i]);
- strcat(string, str);
- }
- ShowPlayerDialog(playerid,6,DIALOG_STYLE_LIST,"Выберите карту",string,"Выбор","Отмена");
- }
- }
- if(dialogid == 6)
- {
- if(response)
- {
- if(PlayerDM[playerid][did] != -1) DM_exit(playerid);
- new col = DM_create(PlayerDM[playerid][Name],PlayerDM[playerid][Gun],listitem,PlayerDM[playerid][PlayerCol]);
- if(col == -1) return 1;
- DM_connect(playerid,col);
- new str[128];
- new name[MAX_PLAYER_NAME+1];
- GetPlayerName(playerid, name, sizeof(name));
- format(str,sizeof(str),"{3caa3c}[DM] {3ca99f}Игрок %s создал DM зону '%s'!",name,PlayerDM[playerid][Name]);
- SendClientMessageToAll(0xFFFFFFAA,str);
- }
- }
- if(dialogid == 7)
- {
- if(response) DM_si(playerid,DD[playerid][listitem]),DD1[playerid] = DD[playerid][listitem];
- }
- if(dialogid == 8)
- {
- if(response)
- {
- if(DM_info[DD1[playerid]][Players] >= DM_info[DD1[playerid]][PlayerCol]) return SendClientMessage(playerid,0xFF0000AA,"На этой DM зоне нету мест!");
- if(PlayerDM[playerid][did] == DD1[playerid]) return SendClientMessage(playerid,0xFF0000AA,"Вы уже на этой DM зоне!");
- if(PlayerDM[playerid][did] != -1) DM_exit(playerid);
- DM_connect(playerid,DD1[playerid]);
- }
- }
- return 0;
- }
- stock Map_load(pub[],mapname[])
- {
- if(MapLoaded >= (MAX_MAP-1)) return printf(" Невозможно загрузить карту '%s'!",mapname);
- MapLoaded++;
- CallLocalFunction(pub, "s", "Call" );
- strmid(MapName[MapLoaded], mapname, 0, strlen(mapname), 255);
- printf(" Карта '%s' загружена!",mapname);
- return MapLoaded;
- }
- stock Map_setSpawn(pslot,Float:x,Float:y,Float:z)
- {
- MapCordSpawn[MapLoaded][pslot][0] = x;
- MapCordSpawn[MapLoaded][pslot][1] = y;
- MapCordSpawn[MapLoaded][pslot][2] = z;
- }
- stock Map_setInterior(id) MapInt[MapLoaded] = id;
- stock DM_create(name[],gun,mapid,maxplayers)
- {
- for(new i;i<MAX_DM;i++)
- {
- if(DM_Created[i] == 0)
- {
- DM_Created[i] = 1;
- DM_info[i][Mapid] = mapid;
- DM_info[i][Gun] = gun;
- DM_info[i][PlayerCol] = maxplayers;
- DM_info[i][Players] = 0;
- strmid(DM_info[i][Name], name, 0, strlen(name), 255);
- return i;
- }
- }
- print("Невозможно создать DM зону!");
- return -1;
- }
- stock DM_connect(playerid,DM_id)
- {
- new r = random(MAX_PLAYER_DM);
- PlayerDM[playerid][did] = DM_id;
- SetPlayerPos(playerid,
- MapCordSpawn[DM_info[DM_id][Mapid]][r][0],
- MapCordSpawn[DM_info[DM_id][Mapid]][r][1],
- MapCordSpawn[DM_info[DM_id][Mapid]][r][2]);
- SetPlayerInterior(playerid,MapInt[DM_info[DM_id][Mapid]]);
- SetPlayerVirtualWorld(playerid,DM_id+1);
- DM_info[DM_id][Players]++;
- if(DM_info[DM_id][Gun] > 0) GivePlayerWeapon(playerid, DM_info[DM_id][Gun], PLAYER_AMMO);
- else
- {
- new g = random(sizeof(RandomGun));
- GivePlayerWeapon(playerid,RandomGun[g],PLAYER_AMMO);
- }
- new str[128];
- new name[MAX_PLAYER_NAME+1];
- GetPlayerName(playerid, name, sizeof(name));
- format(str,sizeof(str),"{3caa3c}[DM] {3ca99f}Игрок %s подключился к DM зоне '%s'!",name,DM_info[DM_id][Name]);
- SendClientMessageToAll(0xFFFFFFAA,str);
- }
- stock DM_reconnect(playerid)
- {
- if(PlayerDM[playerid][did] == -1) return 1;
- new r = random(MAX_PLAYER_DM);
- SetPlayerPos(playerid,
- MapCordSpawn[DM_info[PlayerDM[playerid][did]][Mapid]][r][0],
- MapCordSpawn[DM_info[PlayerDM[playerid][did]][Mapid]][r][1],
- MapCordSpawn[DM_info[PlayerDM[playerid][did]][Mapid]][r][2]);
- SetPlayerInterior(playerid,MapInt[DM_info[PlayerDM[playerid][did]][Mapid]]);
- SetPlayerVirtualWorld(playerid,PlayerDM[playerid][did]+1);
- if(DM_info[PlayerDM[playerid][did]][Gun] > 0) GivePlayerWeapon(playerid, DM_info[PlayerDM[playerid][did]][Gun], PLAYER_AMMO);
- else
- {
- new g = random(sizeof(RandomGun));
- GivePlayerWeapon(playerid,RandomGun[g],PLAYER_AMMO);
- }
- return 1;
- }
- stock DM_exit(playerid)
- {
- if(PlayerDM[playerid][did] == -1) return 1;
- new str[128];
- new name[MAX_PLAYER_NAME+1];
- GetPlayerName(playerid, name, sizeof(name));
- format(str,sizeof(str),"{3caa3c}[DM] {3ca99f}Игрок %s вышел с DM зоны '%s'!",name,DM_info[PlayerDM[playerid][did]][Name]);
- DM_info[PlayerDM[playerid][did]][Players]--;
- DM_playerCheck(PlayerDM[playerid][did]);
- SetPlayerVirtualWorld(playerid,0);
- PlayerDM[playerid][did] = -1;
- SpawnPlayer(playerid);
- return 1;
- }
- stock DM_si(playerid,DM_id)
- {
- new rez[50];
- if(DM_info[DM_id][Gun] > 0) GetWeaponName(DM_info[DM_id][Gun],rez,sizeof(rez));
- else rez = "Случайное оружие";
- new string[200];
- format(string,sizeof(string),"\
- Название: %s\n\
- Игроков: %d/%d\n\
- Режим: %s",
- DM_info[DM_id][Name],
- DM_info[DM_id][Players],
- DM_info[DM_id][PlayerCol],
- rez);
- ShowPlayerDialog(playerid,8,DIALOG_STYLE_MSGBOX,"Информация",string,"Connect","Cancel");
- }
- stock DM_playerCheck(DM_id)
- {
- if(DM_info[DM_id][Players] <= 0)
- {
- DM_Created[DM_id] = 0;
- new str[128];
- format(str,sizeof(str),"{3caa3c}[DM] {3ca99f}DM зона '%s' была удалена из-за отсутствия игроков!",DM_info[DM_id][Name]);
- SendClientMessageToAll(-1,str);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement