SHARE
TWEET

BOSS

a guest Jan 21st, 2020 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <a_samp>
  2.  
  3. #undef MAX_PLAYERS
  4. #define MAX_PLAYERS 50
  5.  
  6. #include <foreach>
  7. #include <fcnpc>
  8. #include <streamer>
  9. #include <zcmd>
  10.  
  11. new boss_cp = 0;
  12. new boss_icon = 0;
  13. new boss = 65535;
  14. new bool:in_boss[MAX_PLAYERS char] = {false,...};
  15. new Text:boss_hp = Text:65535;
  16. new boss_timer = 0;
  17.  
  18. #define BOSS_NAME "BOSS_NPC"  //npc name
  19. #define BOSS_END_TIME 300000  //battle time
  20. #define BOSS_ICON 23          //icon type
  21. #define BOSS_DIALOG 1265      //boss dialog id
  22. #define BOSS_WORLD 5          //boss virtual world
  23. #define BOSS_SKIN 269         //boss skin
  24. #define PLAYER_WEAPON 31      //player weapon
  25. #define BOSS_WEAPON 31        //boss weapon
  26. #define BOSS_HEALTH 5000.0    //boss health
  27. #define BOSS_ACCURACY 0.125   //boss accuracy
  28. #define BOSS_CASH 80000       //victory cash
  29. #define BOSS_SCORE 25          //victory score
  30.  
  31. Float:Pracent(Float:x, Float:y)
  32. {
  33.     return ((x/y)*100);
  34. }
  35.  
  36. public OnFilterScriptInit()
  37. {
  38.     boss_hp = TextDrawCreate(275.0, 420.0, "~w~%~r~~h~100");
  39.     FCNPC_SetWeaponShootTime(boss, BOSS_WEAPON, 200);
  40.     TextDrawFont(boss_hp, 3);
  41.     TextDrawLetterSize(boss_hp, 1.0, 1.2);
  42.     TextDrawSetOutline(boss_hp, 1);
  43.     boss_cp = CreateDynamicCP(1088.3391, 1075.5221, 10.8382, 2.5, 0);
  44.     boss_icon = CreateDynamicMapIcon(1088.3391, 1075.5221, 10.8382, BOSS_ICON, 0, 0);
  45.     boss = FCNPC_Create(BOSS_NAME);
  46.     FCNPC_SetVirtualWorld(boss, BOSS_WORLD);
  47.     FCNPC_Spawn(boss, BOSS_SKIN, 1088.3391, 1075.5221, 10.8382);
  48.     FCNPC_SetWeapon(boss, BOSS_WEAPON);
  49.     FCNPC_SetHealth(boss, BOSS_HEALTH);
  50.     return 1;
  51. }
  52.  
  53. public OnPlayerDeath(playerid, killerid, reason)
  54. {
  55.     new name[47];
  56.     if(in_boss{playerid})
  57.     {
  58.         GetPlayerName(playerid, name, 24);
  59.         strcat(name, " has lost the boss battle!");
  60.         SendClientMessageToAll(0xFFFF00FF, name);
  61.         SetPlayerVirtualWorld(playerid, 0);
  62.         KillTimer(boss_timer);
  63.         boss_timer = 0;
  64.         FCNPC_Respawn(boss);
  65.         TextDrawHideForPlayer(playerid, boss_hp);
  66.         SetPlayerVirtualWorld(playerid, 0);
  67.         SendClientMessage(playerid, 0xFFFF00FF, "You lost the battle!");
  68.     }
  69.     return 1;
  70. }
  71.  
  72. public OnPlayerDisconnect(playerid, reason)
  73. {
  74.     if(in_boss{playerid})
  75.     {
  76.         in_boss{playerid} = false;
  77.         KillTimer(boss_timer);
  78.         boss_timer = 0;
  79.         TextDrawHideForPlayer(playerid, boss_hp);
  80.         FCNPC_Respawn(boss);
  81.         SendClientMessageToAll(0xFFFF00FF, "The boss battle is open now");
  82.     }
  83.     return 1;
  84. }
  85.  
  86. public OnPlayerCommandReceived(playerid, cmdtext[])
  87. {
  88.     if(in_boss{playerid})
  89.     {
  90.         if(strcmp("/leavebossmg", cmdtext) != 0)
  91.         {
  92.             SendClientMessage(playerid, 0xFF0000FF, "You cant use command during boss fight /leavebossmg");
  93.             return 0;
  94.         }
  95.     }
  96.     return 1;
  97. }
  98.  
  99. CMD:leavebossmg(playerid, params[])
  100. {
  101.     new name[47];
  102.     if(!in_boss{playerid}) return SendClientMessage(playerid, 0xFF0000FF, "You are not in boss battle");
  103.     GetPlayerName(playerid, name, 24);
  104.     strcat(name, " has left the boss battle!");
  105.     KillTimer(boss_timer);
  106.     boss_timer = 0;
  107.     SetPlayerVirtualWorld(playerid, 0);
  108.     SpawnPlayer(playerid);
  109.     in_boss{playerid} = false;
  110.     TextDrawHideForPlayer(playerid, boss_hp);
  111.     FCNPC_Respawn(boss);
  112.     SendClientMessage(playerid, 0xFFFF00FF, "You quit the boss battle");
  113.     SendClientMessageToAll(0xFFFF00FF, name);
  114.     return 1;
  115. }
  116.  
  117. public FCNPC_OnTakeDamage(npcid, issuerid, Float:amount, weaponid, bodypart)
  118. {
  119.     new string[18], Float:hp;
  120.     hp = FCNPC_GetHealth(boss)-amount;
  121.     format(string, 18, "~w~%%~r~~h~%d", floatround(Pracent(hp, BOSS_HEALTH), floatround_round));
  122.     TextDrawSetString(boss_hp, string);
  123.     return 1;
  124. }
  125.  
  126. public OnFilterScriptExit()
  127. {
  128.     TextDrawDestroy(boss_hp);
  129.     FCNPC_Destroy(boss);
  130.     DestroyDynamicCP(boss_cp);
  131.     DestroyDynamicMapIcon(boss_icon);
  132.     if(boss_timer != 0)
  133.     {
  134.         KillTimer(boss_timer);
  135.         boss_timer = 0;
  136.         foreach(new i : Player)
  137.         {
  138.             if(!in_boss{i}) continue;
  139.             SetPlayerVirtualWorld(i, 0);
  140.             SetPlayerHealth(i, 100.0);
  141.             break;
  142.         }
  143.     }
  144.     return 1;
  145. }
  146.  
  147. public OnPlayerEnterDynamicCP(playerid, checkpointid)
  148. {
  149.     new Float:HP;
  150.     if(checkpointid == boss_cp)
  151.     {
  152.         SendClientMessage(playerid, 0xFFFF00FF, "Check if the boss battle is open from anywhere /boss");
  153.         if(boss_timer != 0)
  154.         {
  155.             SendClientMessage(playerid, 0xFF0000FF, "Someone is in this challange please wait");
  156.             return 1;
  157.         }
  158.         GetPlayerHealth(playerid, HP);
  159.         if(HP <= 100.0)
  160.         {
  161.             ShowPlayerDialog(playerid, BOSS_DIALOG, 0, "{FF0000}Boss Battle", "{FF0000}Are you ready to fight the boss?", "{00FF00}Ready", "{FF0000}Im Out");
  162.         }
  163.     }
  164.     return 1;
  165. }
  166.  
  167. forward BOSS_END();
  168.  
  169. public BOSS_END()
  170. {
  171.     foreach(new i : Player)
  172.     {
  173.         if(!in_boss{i}) continue;
  174.         SetPlayerVirtualWorld(i, 0);
  175.         SpawnPlayer(i);
  176.         PlayerPlaySound(i, 1058, 0.0, 0.0, 0.0);
  177.         SendClientMessage(i, 0xFFFF00FF, "Boss Battle out of time!");
  178.         in_boss{i} = false;
  179.         TextDrawHideForPlayer(i, boss_hp);
  180.     }
  181.     FCNPC_Respawn(boss);
  182.     boss_timer = 0;
  183.     return 1;
  184. }
  185.  
  186. public FCNPC_OnDeath(npcid, killerid, reason)
  187. {
  188.     new name[24], string[74];
  189.     if(npcid == boss)
  190.     {
  191.         if(boss_timer == 0) return 1;
  192.         GetPlayerName(killerid, name, 24);
  193.         KillTimer(boss_timer);
  194.         boss_timer = 0;
  195.         SetPlayerVirtualWorld(killerid, 0);
  196.         SpawnPlayer(killerid);
  197.         in_boss{killerid} = false;
  198.         FCNPC_Respawn(boss);
  199.         TextDrawHideForPlayer(killerid, boss_hp);
  200.         PlayerPlaySound(killerid, 1057, 0.0, 0.0, 0.0);
  201.         GivePlayerMoney(killerid, BOSS_CASH);
  202.         SetPlayerScore(killerid, GetPlayerScore(killerid)+BOSS_SCORE);
  203.         SendClientMessage(killerid, 0x00FF00FF, "You won the boss battle!");
  204.         format(string, 74, "%s won the boss battle and got +$%d and %d scores", name, BOSS_CASH, BOSS_SCORE);
  205.         SendClientMessageToAll(0x00FF00FF, string);
  206.     }
  207.     return 1;
  208. }
  209.  
  210. CMD:boss(playerid, params[])
  211. {
  212.     if(boss_timer != 0) return SendClientMessage(playerid, 0xFF0000FF, "Boss battle is closed currently");
  213.     SendClientMessage(playerid, 0x00FF00FF, "Boss battle is open");
  214.     return 1;
  215. }
  216.  
  217. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  218. {
  219.     switch(dialogid)
  220.     {
  221.         case BOSS_DIALOG:
  222.         {
  223.             if(response)
  224.             {
  225.                 //Save Weapons Here
  226.                 if(boss_timer != 0) return SendClientMessage(playerid, 0xFF0000FF, "Someone allready started this challange you gotta click faster on the buttons!");
  227.                 ResetPlayerWeapons(playerid);
  228.                 SendClientMessage(playerid, 0xFFFF00FF, "To leave boss battle /leavebossmg");
  229.                 boss_timer = SetTimer("BOSS_END", BOSS_END_TIME, false);
  230.                 GivePlayerWeapon(playerid, PLAYER_WEAPON, 9999999);
  231.                 TextDrawShowForPlayer(playerid, boss_hp);
  232.                 SetPlayerPos(playerid, 1142.1877, 1101.8240, 11.0000);
  233.                 in_boss{playerid} = true;
  234.                 FCNPC_Respawn(boss);
  235.                 FCNPC_SetHealth(boss, BOSS_HEALTH);
  236.                 FCNPC_SetWeaponAccuracy(boss, BOSS_WEAPON, BOSS_ACCURACY);
  237.                 FCNPC_SetWeapon(boss, BOSS_WEAPON);
  238.                 TextDrawSetString(boss_hp, "~w~%~r~~h~100");
  239.                 FCNPC_UseInfiniteAmmo(boss, true);
  240.                 FCNPC_AimAtPlayer(boss, playerid, true);
  241.                 SetPlayerVirtualWorld(playerid, BOSS_WORLD);
  242.                 return 1;
  243.             }
  244.             SendClientMessage(playerid, 0xFF0000FF, "Haha chicken!");
  245.         }
  246.     }
  247.     return 0;
  248. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top