fiki574_CRO

Last Man Standing

Jan 4th, 2013
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.46 KB | None | 0 0
  1. new Float:RandomLMSSpawns[][] =
  2. {
  3.     {-2433.3643,1529.3511,31.8594,308.0968},
  4.     {-2393.2271,1538.8435,31.8594,113.8518},
  5.     {-2372.3481,1560.5588,31.8594,126.6751},
  6.     {-2372.1155,1530.4330,31.8594,85.0248},
  7.     {-2408.5549,1544.2440,31.8594,288.3565},
  8.     {-2425.8440,1560.9408,31.8594,254.8529}
  9. };
  10.  
  11. new CountLMSPlayers;
  12. new inLMS[MAX_PLAYERS];
  13. new LMSinProgress;
  14. forward StartLast();
  15.  
  16. public OnPlayerConnect(playerid)
  17. {
  18.     inLMS[playerid] = 0;
  19.     return 1;
  20. }
  21.  
  22. public OnPlayerDisconnect(playerid, reason)
  23. {  
  24.     if(inLMS[playerid] == 1)
  25.     {
  26.             inLMS[playerid] = 0;
  27.             isInDM[playerid] = 0;
  28.             CountLMSPlayers--;
  29.             new pname[MAX_PLAYER_NAME];
  30.         GetPlayerName(playerid,pname,sizeof(pname));
  31.             new string[256];
  32.         format(string,sizeof(string),"{03F2FF}[LMS]: {FFFFFF}%s has left the Last Man Standing! {FF0000}(Disconnected)",pname);
  33.         SendClientMessageToAll(-1,string);
  34.     }
  35.         return 1;
  36. }
  37.  
  38. public OnPlayerDeath(playerid, killerid, reason)
  39. {
  40.     if(LMSinProgress == 1)
  41.     {
  42.         if(CountLMSPlayers > 0)
  43.         {
  44.             if(inLMS[playerid] == 1)
  45.             {
  46.                     CountLMSPlayers--;
  47.                     new name[MAX_PLAYER_NAME];
  48.                     new string[256];
  49.                     GetPlayerName(playerid,name,sizeof(name));
  50.                 format(string,sizeof(string),"{03F2FF}[LMS]: {FFFFFF}%s has died!",name);
  51.                 SendClientMessageToAll(-1,string);
  52.                 inLMS[playerid] = 0;
  53.                 return 1;
  54.             }
  55.             return 1;
  56.         }
  57.         return 1;
  58.     }
  59.     return 1;
  60. }
  61.  
  62. public OnPlayerCommandText(playerid, cmdtext[])
  63. {
  64.     if (strcmp("/resetevent", cmdtext, true, 10) == 0)
  65.     {
  66.         if(IsPlayerAdmin(playerid))
  67.         {
  68.                 LMSinProgress = 0;
  69.             GameTextForAll("~r~EVENTS ARE RESET!", 5000, 3);
  70.         }
  71.             return 1;
  72.     }
  73.     if (strcmp("/lms", cmdtext, true, 10) == 0)
  74.     {
  75.         if(inLMS[playerid] == 1)
  76.         {
  77.                 GameTextForPlayer(playerid,"~r~YOU ARE IN ~n~LAST MAN STANDING!",3000,3);
  78.             return 1;
  79.         }
  80.         if(LMSinProgress == 1)
  81.         {
  82.             GameTextForPlayer(playerid,"~r~LAST MAN STANDING ~n~ALREADY STARTED!",3000,3);
  83.             return 1;
  84.         }
  85.         if(CountLMSPlayers == 6)
  86.         {
  87.             GameTextForPlayer(playerid,"~r~LAST MAN STANDING ~n~FULL!",3000,3);
  88.                 return 1;
  89.         }
  90.             inLMS[playerid] = 1;
  91.             isInDM[playerid] = 1;
  92.             SetPlayerVirtualWorld(playerid,10);
  93.             ResetPlayerWeapons(playerid);
  94.             SetPlayerHealth(playerid,100);
  95.             GivePlayerWeapon(playerid,24,1000000);
  96.             GivePlayerWeapon(playerid,27,1000000);
  97.             new rand = random(sizeof(RandomLMSSpawns));
  98.         SetPlayerPos(playerid,RandomLMSSpawns[rand][0],RandomLMSSpawns[rand][1],RandomLMSSpawns[rand][2]);
  99.         SetPlayerFacingAngle(playerid,RandomLMSSpawns[rand][3]);
  100.         TogglePlayerControllable(playerid,0);
  101.         GameTextForPlayer(playerid,"~g~LAST MAN STANDING ~n~STARTING SOON!",3000,3);
  102.         CountLMSPlayers++;
  103.         new pname[MAX_PLAYER_NAME];
  104.         GetPlayerName(playerid,pname,sizeof(pname));
  105.         new string[256];
  106.         format(string,sizeof(string),"{03F2FF}[LMS]: {FFFFFF}%s has joined the Last Man Standing!",pname);
  107.         SendClientMessageToAll(-1,string);
  108.         if(CountLMSPlayers == 1)
  109.         {
  110.                 SetTimer("StartLast",15000,false);
  111.                     for(new i=0; i < MAX_PLAYERS; i++) return PlayerPlaySound(i, 1056, 0.0, 0.0, 10.0);
  112.             return 1;
  113.         }
  114.         return 1;
  115.     }
  116.     return 1;
  117. }
  118.  
  119. public StartLast()
  120. {
  121.         for(new i=0; i < MAX_PLAYERS; i++)
  122.         {
  123.             if(inLMS[i] == 1)
  124.             {
  125.                     if(CountLMSPlayers >= 2)
  126.             {
  127.                     TogglePlayerControllable(i,1);
  128.                     GameTextForPlayer(i,"~g~GO GO GO !!!",3000,3);
  129.                     LMSinProgress = 1;
  130.             }
  131.             else if(CountLMSPlayers < 2)
  132.             {
  133.                     inLMS[i] = 0;
  134.                     CountLMSPlayers = 0;
  135.                     LMSinProgress = 0;
  136.                     SetPlayerVirtualWorld(i,0);
  137.                 TogglePlayerControllable(i,1);
  138.                 SendClientMessageToAll(-1,"{03F2FF}[LMS]: {FFFFFF}No one joined Last Man Standing, so its canceled!");
  139.                     }
  140.         }
  141.     }
  142. }
  143.  
  144. public OnPlayerUpdate(playerid)
  145. {
  146.     for(new i=0; i < MAX_PLAYERS; i++)
  147.     {
  148.         if(inLMS[i] == 1)
  149.             {
  150.                 if(LMSinProgress == 1)
  151.                 {
  152.                 if(CountLMSPlayers == 1)
  153.                 {
  154.                     inLMS[i] = 0;
  155.                     CountLMSPlayers = 0;
  156.                     LMSinProgress = 0;
  157.                     new name[MAX_PLAYER_NAME];
  158.                     GetPlayerName(i,name,sizeof(name));
  159.                     new string[256];
  160.                     format(string,sizeof(string),"{03F2FF}[LMS]: {FFFFFF}Last Man Standing finished! Winner is {FF0000}%s! {FFFFFF}He won 30 000$ and 20 Score!",name);
  161.                     SendClientMessageToAll(-1,string);
  162.                     GiveMoney(i,30000);
  163.                     SetPlayerScore(i,GetPlayerScore(i)+20);
  164.                 }
  165.             }
  166.         }
  167.     }
  168.     return 1;
  169. }
Advertisement
Add Comment
Please, Sign In to add comment