Advertisement
Guest User

Last Man Standing

a guest
Jun 17th, 2013
525
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 10.58 KB | None | 0 0
  1. /*========================================
  2.         Event Filterscript
  3.             By AldoT
  4. ==========================================*/
  5.  
  6. //=== Includes ===
  7. #include <a_samp>
  8. #include <zcmd>
  9. //=== Defines ===
  10. #define COLOR_RED 0xFF0000AA
  11. #define COLOR_YELLOW 0xFFFF00AA
  12. //=== Locations ===
  13. new CageFight, CageFightOn;
  14. new CurrentPos, CurrentPosOn;
  15. new EventGoingOn;
  16. //=== Counters ===
  17. new NumCageFighters;
  18. new NumCurrentFighters;
  19. //=== Other ===
  20. new string[128];
  21. new Float:EventLocation[3];
  22. new PlayerAtEvent[MAX_PLAYERS];
  23. new EventInterior;
  24. //=== Forwards ===
  25. forward StartEvent();
  26. forward PrepareEvent();
  27. forward EndEventCheck();
  28. forward SendEventMessage(color, Zstring[]);
  29. forward ResetEventSelectedWeps();
  30. forward EndCuf(playerid);
  31. forward ExitERNING(playerid);
  32. forward EndGet(playerid);
  33. ////////////////
  34. new Text:ERNING;
  35. new Text:weapon;
  36. ////////////////
  37. public OnFilterScriptInit()
  38. {
  39.     print("\n--------------------------------------");
  40.     print(" Last Man Standing was Create by AldoT ");
  41.     print("--------------------------------------\n");
  42.     NumCageFighters = 0;
  43.     NumCurrentFighters = 0;
  44.     CageFight = 0;
  45.     CurrentPos = 0;
  46.     CageFightOn = 0;
  47.     CurrentPosOn = 0;
  48.     EventGoingOn = 0;
  49.     ResetEventSelectedWeps();
  50.     for(new i = 0; i < GetMaxPlayers(); i++) PlayerAtEvent[i] = 0;
  51.     return 1;
  52. }
  53.  
  54. public OnPlayerConnect(playerid)
  55. {
  56.     PlayerAtEvent[playerid] = 0;
  57.     return 1;
  58. }
  59.  
  60. public OnPlayerDisconnect(playerid, reason)
  61. {
  62.     if(PlayerAtEvent[playerid] != 0)
  63.     {
  64.         SetTimer("EndEventCheck", 3000, 0);
  65.         if(CageFightOn == 1) NumCageFighters--;
  66.         else if (CurrentPosOn == 1) NumCurrentFighters--;
  67.         new kick[64], Name[MAX_PLAYER_NAME];
  68.         GetPlayerName(playerid,Name,MAX_PLAYER_NAME);
  69.         format(kick,sizeof kick,"» Last Man Standing ~ Kick: %s",Name);
  70.         SendClientMessageToAll(0xFF7800FF,kick);
  71.     }
  72.     return 1;
  73. }
  74.  
  75. public OnPlayerDeath(playerid, killerid, reason)
  76. {
  77.     if(PlayerAtEvent[playerid] != 0)
  78.     {
  79.         SetTimer("EndEventCheck", 3000, 0);
  80.         if(CageFightOn == 1) NumCageFighters--;
  81.         else if (CurrentPosOn == 1) NumCurrentFighters--;
  82.         PlayerAtEvent[playerid] = 0;
  83.         new Death[64], Name[MAX_PLAYER_NAME];
  84.         GetPlayerName(playerid,Name,MAX_PLAYER_NAME);
  85.         format(Death,sizeof Death,"» Last Man Standing ~ Death: %s",Name);
  86.         SendClientMessageToAll(0xFF7800FF,Death);
  87.         new Float:killerHP;
  88.         GetPlayerHealth(killerid, killerHP);
  89.         SetPlayerHealth(killerid, killerHP+24);
  90.         EventGoingOn = 1;
  91.     }
  92.     return 1;
  93. }
  94.  
  95. public SendEventMessage(color, Zstring[])
  96. {
  97.     for(new i = 0; i < GetMaxPlayers(); i++)
  98.     {
  99.         if(IsPlayerConnected(i))
  100.         {
  101.             if(PlayerAtEvent[i] != 0)
  102.             {
  103.                 SendClientMessage(i, color, string);
  104.             }
  105.         }
  106.     }
  107. }
  108.  
  109. public PrepareEvent()
  110. {
  111.     SetTimer("StartEvent", 30000, 0);
  112.     return 1;
  113. }
  114.  
  115. public StartEvent()
  116. {
  117.     if(NumCageFighters > 1 || NumCurrentFighters > 1)
  118.     {
  119.  
  120.         if(CageFight == 1) CageFightOn = 1; // To let the server know which event a player is eliminated from
  121.         if(CurrentPos == 1) CurrentPosOn = 1;
  122.  
  123.         CageFight = 0; // TO avoid signups after event is started
  124.         CurrentPos = 0;
  125.         for(new i = 0; i < GetMaxPlayers(); i++)
  126.         {
  127.             if(PlayerAtEvent[i] == 1)
  128.             {
  129.                 SetTimerEx("EndGet",9000,0,"i",i);
  130.                 TextDrawShowForPlayer(i,weapon);
  131.                 SetTimerEx("EndCuf",9000,0,"i",i);
  132.                 TogglePlayerControllable(i,true);
  133.                 PlayerPlaySound(i, 3200, 0, 0, 0);
  134.             }
  135.         }
  136.     }
  137.     else
  138.     {
  139.         for(new i = 0; i < GetMaxPlayers(); i++)
  140.         {
  141.             if(PlayerAtEvent[i] != 0)
  142.             {
  143.                 ResetPlayerWeapons(i);
  144.                 SendClientMessage(i,COLOR_RED,"{E8D04C}[EVENT]{FFFFFF} Last Man Standing ended due to lack of contenders.");
  145.                 SpawnPlayer(i);
  146.                 PlayerAtEvent[i] = 0;
  147.                 EventGoingOn = 0;
  148.                 CageFight = 0;
  149.                 CurrentPos = 0;
  150.             }
  151.         }
  152.  
  153.     }
  154.     return 1;
  155. }
  156.  
  157. public EndEventCheck()
  158. {
  159.     for(new i = 0; i < GetMaxPlayers(); i++)
  160.     {
  161.         if(PlayerAtEvent[i] == 1)
  162.         {
  163.             if(NumCageFighters == 1)
  164.             {
  165.                 TextDrawShowForPlayer(i,ERNING);
  166.                 new prize[64], Name[MAX_PLAYER_NAME];
  167.                 GetPlayerName(i,Name,MAX_PLAYER_NAME);
  168.                 SetTimerEx("ExitERNING",3000,0,"i",i);
  169.                 format(prize,sizeof prize,"* %s survived the Last Man Standing. Prize: $2000.",Name);
  170.                 SendClientMessageToAll(0xFF7800FF,prize);
  171.                 GivePlayerMoney(i, 2000);
  172.                 SpawnPlayer(i);
  173.                 PlayerAtEvent[i] = 0;
  174.                 NumCageFighters = 0;
  175.                 ResetEventSelectedWeps();
  176.                 return 1;
  177.             }
  178.             else if(NumCurrentFighters == 1)
  179.             {
  180.                 new prize[64], Name[MAX_PLAYER_NAME];
  181.                 GetPlayerName(i,Name,MAX_PLAYER_NAME);
  182.                 SetTimerEx("ExitERNING",3000,0,"i",i);
  183.                 TextDrawShowForPlayer(i,ERNING);
  184.                 format(prize,sizeof prize,"* %s survived the Last Man Standing. Prize: $2000.",Name);
  185.                 SendClientMessageToAll(0xFF7800FF,prize);
  186.                 GivePlayerMoney(i, 2000);
  187.                 SpawnPlayer(i);
  188.                 PlayerAtEvent[i] = 0;
  189.                 NumCurrentFighters = 0;
  190.                 ResetEventSelectedWeps();
  191.                 return 1;
  192.             }
  193.         }
  194.     }
  195.     return 1;
  196. }
  197.  
  198. public ResetEventSelectedWeps()
  199. {
  200.     CageFight = 0;
  201.     CurrentPos = 0;
  202.  
  203.     CurrentPosOn = 0;
  204.     CageFightOn = 0;
  205.  
  206.     EventGoingOn = 0;
  207.  
  208.     for(new i = 0; i < GetMaxPlayers(); i++) PlayerAtEvent[i] = 0;
  209. }
  210.  
  211. //============================ Commands ========================================
  212.  
  213. CMD:event(playerid, params[])
  214. {
  215.         if(EventGoingOn == 1) return SendClientMessage(playerid, COLOR_RED, "Last Man Standing is alreay started, too late to join. ");
  216.         EventGoingOn = 1;
  217.         CageFight = 1;
  218.         CurrentPos = 1;
  219.         SetTimer("PrepareEvent", 1000, 0);
  220.         new start[200], Name[MAX_PLAYER_NAME];
  221.         GetPlayerName(playerid,Name,MAX_PLAYER_NAME);
  222.         format(start,sizeof start,"* %s is Standing a Last Man Standing, Localition: Jefferson Motel.", Name);
  223.         SendClientMessageToAll(0xFF7800FF,start);
  224.         SendClientMessageToAll(0xFF7800FF ,"* Type ' /lmsjoin ' to participate.");
  225.         return 1;
  226. }
  227.  
  228. CMD:lmsjoin(playerid, params[])
  229. {
  230.     if(PlayerAtEvent[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "You are at an Last Man Standing now.");
  231.     {
  232.         //------------------------- Cage Fight----------------------------------
  233.         if(CageFight == 1)
  234.         {
  235.              TextDrawShowForPlayer(playerid, weapon);
  236.              new join[64], Name[MAX_PLAYER_NAME];
  237.              GetPlayerName(playerid,Name,MAX_PLAYER_NAME);
  238.              format(join,sizeof join,"» Last Man Standing ~ Join: %s",Name);
  239.              SendClientMessageToAll(0xFF7800FF,join);
  240.              TogglePlayerControllable(playerid,false);// Freezing the player until Event start
  241.              SetPlayerSpecialAction(playerid, SPECIAL_ACTION_CUFFED);
  242.              SetPlayerPos(playerid, 2193.3101,-1141.7870,1029.7969);
  243.              SetPlayerInterior(playerid, 15);
  244.              ResetPlayerWeapons(playerid);
  245.              GivePlayerWeapon(playerid,24,44);
  246.              GivePlayerWeapon(playerid,27,44);
  247.              GivePlayerWeapon(playerid,31,200);
  248.              GivePlayerWeapon(playerid,29,150);
  249.              SetPlayerHealth(playerid, 100);
  250.              SetPlayerTeam(playerid, NO_TEAM);
  251.              SetPlayerColor(playerid,0xFF6600FF);
  252.              new skinsLastManStading[3] ={
  253.              84,
  254.              83,
  255.              82,
  256.              };
  257.              SetPlayerSkin(playerid, skinsLastManStading[random(3)]);
  258.              NumCageFighters++;//counter
  259.              PlayerAtEvent[playerid] = 1;
  260.              return 1;
  261.         }
  262.         //------------------------- Current Pos --------------------------------
  263.         if(CurrentPos == 1)
  264.         {
  265.             SetPlayerPos(playerid, EventLocation[0] + (random(3) - random(3)),EventLocation[1] + (random(3) - random(3)),EventLocation[2]);
  266.             SetPlayerInterior(playerid, EventInterior);
  267.             NumCurrentFighters++;
  268.             PlayerAtEvent[playerid] = 1;
  269.             new join[64], Name[MAX_PLAYER_NAME];
  270.             GetPlayerName(playerid,Name,MAX_PLAYER_NAME);
  271.             format(join,sizeof join,"» Last Man Standing ~ Join: %s",Name);
  272.             SendClientMessageToAll(0xFF7800FF,join);
  273.             TogglePlayerControllable(playerid,false);// Freezing the player until Event start
  274.             SetPlayerSpecialAction(playerid, SPECIAL_ACTION_CUFFED);
  275.             SetPlayerPos(playerid, 2193.3101,-1141.7870,1029.7969);
  276.             SetPlayerInterior(playerid, 5);
  277.             ResetPlayerWeapons(playerid);
  278.             SetPlayerTeam(playerid, NO_TEAM);
  279.             GivePlayerWeapon(playerid,24,44);
  280.             GivePlayerWeapon(playerid,27,44);
  281.             GivePlayerWeapon(playerid,31,200);
  282.             GivePlayerWeapon(playerid,29,150);
  283.             SetPlayerHealth(playerid, 100);
  284.             SetPlayerColor(playerid,0xFF6600FF);
  285.             new skinsLastManStading[3] ={
  286.             84,
  287.             83,
  288.             82,
  289.             };
  290.             SetPlayerSkin(playerid, skinsLastManStading[random(3)]);
  291.             return 1;
  292.         }
  293.         //----------------------------------------------------------------------
  294.         else
  295.         {
  296.             SendClientMessage(playerid, COLOR_RED, "There's no Last Man Standing taking place right now.");
  297.             return 1;
  298.         }
  299.     }
  300. }
  301. public EndCuf(playerid)
  302. {
  303. SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
  304. return 1;
  305. }
  306. CMD:endevent(playerid, params[])
  307. {
  308.         CageFight = 0;
  309.         CurrentPos = 0;
  310.  
  311.         CurrentPosOn = 0;
  312.         CageFightOn = 0;
  313.  
  314.         NumCageFighters = 0;
  315.         NumCurrentFighters = 0;
  316.  
  317.         ResetEventSelectedWeps();
  318.  
  319.         for(new i = 0; i < GetMaxPlayers(); i++)
  320.         {
  321.             PlayerAtEvent[i] = 0;
  322.         }
  323.         return 1;
  324. }
  325.  
  326. stock pName(playerid)
  327. {
  328.     new Name[MAX_PLAYER_NAME];
  329.     GetPlayerName(playerid, Name, sizeof(Name));
  330.     return Name;
  331. }
  332. public OnGameModeInit()
  333.    {
  334.    ERNING = TextDrawCreate(250, 171, "EARNINGS ~w~$2000");
  335.    TextDrawFont(ERNING , 2);
  336.    TextDrawLetterSize(ERNING , 0.4, 2.8);
  337.    TextDrawColor(ERNING , 0xA66A00FF);
  338.    TextDrawSetOutline(ERNING , 1);
  339.    TextDrawSetProportional(ERNING , 1);
  340.    TextDrawSetShadow(ERNING , 1);
  341.    //////////////////////////////
  342.    weapon = TextDrawCreate(4.000000,435.000000,"                               GETTING WEAPONS...");
  343.    TextDrawFont(weapon,2);
  344.    TextDrawColor(weapon,0xA66A00FF);
  345.    TextDrawLetterSize(weapon , 0.5, 1.4);
  346.    TextDrawSetOutline(weapon,1);
  347.    TextDrawSetShadow(weapon,1);
  348.    TextDrawSetProportional(weapon,1);
  349.    TextDrawBackgroundColor(weapon,0x000000ff);
  350.    return 1;
  351. }
  352. public ExitERNING(playerid)
  353. {
  354. TextDrawHideForPlayer(playerid,ERNING);
  355. return 1;
  356. }
  357. public EndGet(playerid)
  358. {
  359. TextDrawHideForPlayer(playerid,weapon);
  360. return 1;
  361. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement