Quests System

Unpaid Requests, Public Plugins
Post Reply
Templaso
Senior Member
Senior Member
Romania
Posts: 119
Joined: 5 years ago
Location: Bucharest
Contact:

Quests System

#1

Post by Templaso » 3 years ago

I mae an idea of 1.6 version with quests and this can be made as a separate addon. So here it is to be converted. Honestly i don't know how this works and to be converted for our mode. As i said it can be like this: destroy 10 planks or win 10 rounds as a zm or human or infect 15 people or be the first that call the helicopter or press the button.
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <cstrike>
  4. #include <fun>
  5. #include <engine>
  6. #include <fakemeta>
  7. #include <hamsandwich>
  8. #include <zombieplague>
  9. #pragma compress 1 // Защита от декомпиляра
  10.  
  11. // -> Инфо о плагине <- //{
  12. new g_Plugin[] = "[ZP] Quests";
  13. new g_Version[] = "29.05.2018";
  14. new g_Author[] = "vk.com/cs_jump";
  15. // -> Инфо о плагине <- //}
  16.  
  17. native zp_get_user_ptz(id, ptz)
  18.  
  19. const RIGHT_PER_PAGE = 8; // Игроков на одной странице (9 - далее | 0 - выход)
  20. new g_iMenuPosition[33], Target[33];
  21.  
  22. enum _:DATA_LIST { Name[64], Description[64], Number[64], Type[64], Reward[64] }
  23. new aDataLIST[DATA_LIST]
  24. new Array:g_aList;
  25. new g_iListSize;
  26. new iKillerNum[33][15];
  27.  
  28. public plugin_init()
  29. {
  30.     register_plugin(g_Plugin, g_Version, g_Author);
  31.  
  32.     register_menucmd(register_menuid("Show_MainMenu"), (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9), "Handle_MainMenu");
  33.  
  34.     register_clcmd("say /quests", "ClientCmd");
  35.     register_clcmd("zp_quests", "ClientCmd");
  36.     RegisterHam(Ham_Killed, "player", "Ham_PlayerKilled_Post");
  37.     RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage");
  38. }
  39.  
  40. public plugin_precache()
  41. {
  42.     new szCfgDir[64], szCfgFile[128];
  43.     get_localinfo("amxx_configsdir", szCfgDir, charsmax(szCfgDir));
  44. // Получаем список Квестов
  45.     formatex(szCfgFile, charsmax(szCfgFile), "%s/zp_quests.ini", szCfgDir);
  46.     switch(file_exists(szCfgFile))
  47.     {
  48.         case 0:
  49.         {
  50.             write_file(szCfgFile, "; Файл добавления квестов");
  51.             write_file(szCfgFile, "; ^"Название^" ^"Описание^" ^"Кол-во для награды^" ^"Тип^" ^"Награда Аммо^"");
  52.             write_file(szCfgFile, "; Типы:");
  53.             write_file(szCfgFile, "; 1 - Заражение");
  54.             write_file(szCfgFile, "; 2 - Убийство Зомби");
  55.             write_file(szCfgFile, "; 3 - Убийство первого Зомби");
  56.             write_file(szCfgFile, "; 4 - Убийство последнего Зомби");
  57.             write_file(szCfgFile, "; 5 - Убийство Дьявола");
  58.             write_file(szCfgFile, "; 6 - Убийство Выжившего");
  59.             write_file(szCfgFile, "; 7 - Нанесение Урона");
  60.             write_file(szCfgFile, "");
  61.             write_file(szCfgFile, "^"Убийца^" ^"Убить зомби^" ^"10^" ^"2^" ^"20^"");
  62.             write_file(szCfgFile, "^"Киллер^" ^"Убить зомби^" ^"15^" ^"2^" ^"30^"");
  63.             write_file(szCfgFile, "^"1-я Зараза^" ^"Убить первых зомби^" ^"5^" ^"3^" ^"40^"");
  64.             write_file(szCfgFile, "^"Последняя Зараза^" ^"Убить последних зомби^" ^"5^" ^"4^" ^"50^"");
  65.             write_file(szCfgFile, "^"Охотник^" ^"Убить выживших^" ^"5^" ^"6^" ^"70^"");
  66.             write_file(szCfgFile, "^"Мясник^" ^"Убить дьяволов^" ^"5^" ^"5^" ^"70^"");
  67.             write_file(szCfgFile, "^"Зараза^" ^"Заразить людей^" ^"15^" ^"1^" ^"20^"");
  68.             write_file(szCfgFile, "^"Токсичный^" ^"Заразить людей^" ^"25^" ^"1^" ^"40^"");
  69.             write_file(szCfgFile, "^"Ликвидатор^" ^"Нанести урона^" ^"100000^" ^"7^" ^"500^"");
  70.         }
  71.         case 1:
  72.         {
  73.             new szBuffer[128], iLine, iLen;
  74.             g_aList = ArrayCreate(DATA_LIST);
  75.             while(read_file(szCfgFile, iLine++, szBuffer, charsmax(szBuffer), iLen))
  76.             {
  77.                 if(!iLen || szBuffer[0] == ';') continue;
  78.                 parse
  79.                 (
  80.                     szBuffer,
  81.                     aDataLIST[Name], charsmax(aDataLIST[Name]),
  82.                     aDataLIST[Description], charsmax(aDataLIST[Description]),
  83.                     aDataLIST[Number], charsmax(aDataLIST[Number]),
  84.                     aDataLIST[Type], charsmax(aDataLIST[Type]),
  85.                     aDataLIST[Reward], charsmax(aDataLIST[Reward])
  86.                 );
  87.                 ArrayPushArray(g_aList, aDataLIST);
  88.             }
  89.             g_iListSize = ArraySize(g_aList);
  90.         }
  91.     }
  92. }
  93.  
  94. public plugin_natives()
  95. {
  96.     register_native("zp_open_quests", "ClientCmd", 1);
  97. }
  98.  
  99. public zp_user_infected_pre(id, infector)
  100. {
  101.         iKillerNum[infector][1]++;
  102. }
  103.  
  104. public Ham_PlayerKilled_Post(iVictim, iKiller)
  105. {
  106.     if(iVictim != iKiller)
  107.     {
  108.         if(zp_get_user_nemesis(iVictim)) iKillerNum[iKiller][5]++;
  109.         else if(zp_get_user_survivor(iVictim)) iKillerNum[iKiller][6]++;
  110.         else if(zp_get_user_first_zombie(iVictim)) iKillerNum[iKiller][3]++;
  111.         else if(zp_get_user_last_zombie(iVictim)) iKillerNum[iKiller][4]++;
  112.         else if(zp_get_user_zombie(iVictim)) iKillerNum[iKiller][2]++;
  113.     }
  114. }
  115.  
  116. public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
  117. {
  118.     if (victim == attacker || zp_get_user_zombie(attacker))
  119.         return HAM_IGNORED;
  120.  
  121.     iKillerNum[attacker][7] += floatround(damage)
  122.     return HAM_IGNORED// HAM_SUPERCEDE;
  123. }
  124.  
  125. public ClientCmd(id) return Show_MainMenu(id, g_iMenuPosition[id] = 0);
  126. Show_MainMenu(id, iPos)
  127. {
  128.  
  129.     if(zp_get_user_ptz(id, 5)>=1) return PLUGIN_HANDLED;
  130.    
  131.     new iPlayersNum = g_iListSize;
  132.     new iStart = iPos * RIGHT_PER_PAGE;
  133.     if(iStart > iPlayersNum) iStart = iPlayersNum;
  134.     iStart = iStart - (iStart % RIGHT_PER_PAGE);
  135.     g_iMenuPosition[id] = iStart / RIGHT_PER_PAGE;
  136.     new iEnd = iStart + RIGHT_PER_PAGE;
  137.     if(iEnd > iPlayersNum) iEnd = iPlayersNum;
  138.     new szMenu[512], iLen, iPagesNum = (iPlayersNum / RIGHT_PER_PAGE + ((iPlayersNum % RIGHT_PER_PAGE) ? 1 : 0));
  139.     switch(iPagesNum)
  140.     {
  141.         case 0:
  142.         {
  143.             UTIL_SayText(id, "!g[ZP] !yНет квестов!t.");
  144.             return PLUGIN_HANDLED;
  145.         }
  146.         default: iLen = formatex(szMenu, charsmax(szMenu), "\r[ZM] \wКвесты \r[%d|%d]^n^n", iPos + 1, iPagesNum);
  147.     }
  148.     new iKeys = (1<<9), b;
  149.     for(new a = iStart; a < iEnd; a++)
  150.     {
  151.         ArrayGetArray(g_aList, a, aDataLIST);
  152.         iKeys |= (1<<b);
  153.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[%d]\w%s %s \r[%d\d|\r%s]^n", ++b, iKillerNum[id][str_to_num(aDataLIST[Type])] >= str_to_num(aDataLIST[Number]) ? "\w":"\d", aDataLIST[Name], iKillerNum[id][str_to_num(aDataLIST[Type])], aDataLIST[Number]);
  154.     }
  155.     for(new i = b; i < 8; i++) iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n");
  156.     if(iEnd < iPlayersNum)
  157.     {
  158.         iKeys |= (1<<8);
  159.         formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r[9]\w Далее^n\r[0]\w %s", iPos ? "Назад" : "Выход");
  160.     }
  161.     else formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r[0]\w %s", iPos ? "Назад" : "Выход");
  162.     return show_menu(id, iKeys, szMenu, -1, "Show_MainMenu");
  163. }
  164.  
  165. public Handle_MainMenu(id, iKey)
  166. {
  167.     if(zp_get_user_ptz(id, 5)>=1) return PLUGIN_HANDLED;
  168.  
  169.     switch(iKey)
  170.     {
  171.         case 8: return Show_MainMenu(id, ++g_iMenuPosition[id]);
  172.         case 9: return Show_MainMenu(id, --g_iMenuPosition[id]);
  173.         default:
  174.         {
  175.             Target[id] = g_iMenuPosition[id] * RIGHT_PER_PAGE + iKey;
  176.             ArrayGetArray(g_aList, Target[id], aDataLIST);
  177.             if(iKillerNum[id][str_to_num(aDataLIST[Type])] >= str_to_num(aDataLIST[Number]))
  178.             {
  179.                 iKillerNum[id][str_to_num(aDataLIST[Type])] -= str_to_num(aDataLIST[Number]);
  180.                 zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + str_to_num(aDataLIST[Reward]))
  181.                 UTIL_SayText(id, "!g[ZP] !yВы выполнили задание '!t%s!y' и получили !g%d Аммо!y.", aDataLIST[Name], str_to_num(aDataLIST[Reward]));
  182.             }
  183.             else UTIL_SayText(id, "!g[ZP] !yВы должны: !t%s !g%d !yраз(а). Вам осталось !t%d !yраз(а).", aDataLIST[Description], str_to_num(aDataLIST[Number]), str_to_num(aDataLIST[Number]) - iKillerNum[id][str_to_num(aDataLIST[Type])]);
  184.         }
  185.     }
  186.     return Show_MainMenu(id, g_iMenuPosition[id]);
  187. }
  188.  
  189. stock UTIL_SayText(pPlayer, const szMessage[], any:...)
  190. {
  191.     new szBuffer[190];
  192.     if(numargs() > 2) vformat(szBuffer, charsmax(szBuffer), szMessage, 3);
  193.     else copy(szBuffer, charsmax(szBuffer), szMessage);
  194.     while(replace(szBuffer, charsmax(szBuffer), "!y", "^1")) {}
  195.     while(replace(szBuffer, charsmax(szBuffer), "!t", "^3")) {}
  196.     while(replace(szBuffer, charsmax(szBuffer), "!g", "^4")) {}
  197.     switch(pPlayer)
  198.     {
  199.         case 0:
  200.         {
  201.             for(new iPlayer = 1; iPlayer <= get_maxplayers(); iPlayer++)
  202.             {
  203.                 engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, 76, {0.0, 0.0, 0.0}, iPlayer);
  204.                 write_byte(iPlayer);
  205.                 write_string(szBuffer);
  206.                 message_end();
  207.             }
  208.         }
  209.         default:
  210.         {
  211.             engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, 76, {0.0, 0.0, 0.0}, pPlayer);
  212.             write_byte(pPlayer);
  213.             write_string(szBuffer);
  214.             message_end();
  215.         }
  216.     }
  217. }
Last edited by Templaso 3 years ago, edited 1 time in total.

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#2

Post by Raheem » 3 years ago

You don't know how it works? Any description?
He who fails to plan is planning to fail

Templaso
Senior Member
Senior Member
Romania
Posts: 119
Joined: 5 years ago
Location: Bucharest
Contact:

#3

Post by Templaso » 3 years ago

Really dunno. I just get this from other site. What i request is an achievement plugin to work like that.

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 0 guests