Advertisement
BlueRey

war

Oct 12th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 7.28 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #pragma tabsize 0
  4.  
  5. #define COLOR_RED 0xFF0000AA
  6. #define COLOR_WHITE 0xFFFFFFAA
  7. #define COLOR_LIGHTGREEN 0x24FF0AB9
  8. #define COLOR_GREENWIN 0x0F66FFF
  9.  
  10. #define MinWarPlayers 2
  11.  
  12. new WarOn;
  13. new InWar[MAX_PLAYERS];
  14. new WarPlayers;
  15. new playername[MAX_PLAYER_NAME];
  16. new Count;
  17. new knoob;
  18. new CountFuc;
  19. new Reward;
  20. new knob[256];
  21. new WarWinner;
  22. new CheckTime;
  23. new WS;
  24. new Weapon = 0;
  25. new PP[MAX_PLAYERS];
  26. new WarWeapons[] = {42,41,37,5,8,4,6,2,15,7,3,9};
  27.  
  28. forward Unfreeze();
  29. forward Check();
  30. forward WarEnd(status);
  31. forward TeleportPlayerToWar();
  32. forward Countdown();
  33. forward WarStart();
  34.  
  35. new Float:gRandomWarSpawns[][3] =
  36. {
  37.     {-1085.3271,1019.7804,1342.7926},
  38.     {-1132.9607,1028.6680,1345.7377},
  39.     {-1128.3600,1095.9415,1345.7709},
  40.     {-1098.6946,1098.4323,1341.1632},
  41.     {-1071.4646,1088.1956,1346.0206},
  42.     {-1039.4835,1100.4468,1343.1393},
  43.     {-1043.1943,1041.5938,1341.3516},
  44.     {-1020.2195,1051.2196,1345.9545},
  45.     {-973.8190,1060.5537,1345.6772},
  46.     {-973.6674,1027.6255,1345.0448},
  47.     {-974.3493,1089.1172,1344.9795},
  48.     {-1009.8291,1080.3978,1341.0828},
  49.     {-1019.2279,1071.8867,1347.4093},
  50.     {-1046.0696,1023.0779,1343.0669},
  51.     {-1072.4380,1031.8779,1342.9623},
  52.     {-1104.6825,1097.2749,1341.8513},
  53.     {-1129.6497,1019.8154,1345.6614},
  54.     {-1064.0248,1032.7473,1344.5297},
  55.     {-1054.4865,1058.6794,1341.3516},
  56.     {-1025.9915,1066.3752,1343.8276}
  57. };
  58.  
  59. public OnPlayerCommandText(playerid, cmdtext[])
  60. {
  61.     new cmd[256];
  62.     new idx;
  63.     new tmp[256];
  64.     cmd = strtok(cmdtext, idx);
  65.  
  66.     if(!strcmp(cmd, "/startweapons", true))
  67.     {
  68.         tmp = strtok(cmdtext, idx);
  69.         if(!IsPlayerAdmin(playerid)) return 0;
  70.         if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "Syntax Error: \"/STARTWEAPONS <MONEY>\".");
  71.         if(WarOn == 1) return SendClientMessage(playerid, COLOR_RED, ".יש כבר מלחמה פעילה");
  72.         Reward  = strval(tmp);
  73.         WarStart();
  74.         return 1;
  75.     }
  76.  
  77.     if(!strcmp(cmdtext, "/joinweapons", true))
  78.     {
  79.         if(WarOn == 0) return 0;
  80.         if(WS == 1) return SendClientMessage(playerid, COLOR_RED, ".המלחמה כבר התחילה!, נסה פעם הבאה");
  81.         if(WarPlayers == sizeof(gRandomWarSpawns)) return SendClientMessage(playerid, COLOR_RED, ".כל המקומות נתפסו!, נסה פעם באה");
  82.         if(InWar[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, ".הצטרפת כבר לנשקים, אנא המתן בסבלנות");
  83.         SendClientMessage(playerid, COLOR_LIGHTGREEN, ".!הצטרפת למלחמה בהצלחה");
  84.         WarPlayers ++; InWar[playerid] = 1;
  85.         return 1;
  86.     }
  87.  
  88.     if(!strcmp(cmd, "/endweapons", true))
  89.     {
  90.         if(!IsPlayerAdmin(playerid)) return 0;
  91.         if(WarOn == 0) return SendClientMessage(playerid, COLOR_RED, ".אין כרגע גאטר פעיל");
  92.         Count = 0;
  93.         WarEnd(0);
  94.         return 1;
  95.     }
  96.     return 0;
  97. }
  98.  
  99. public WarStart()
  100. {
  101.     SendClientMessageToAll(0x0F66AFF, "[------[ מערכת מלחמת נשקים ]------]");
  102.     SendClientMessageToAll(COLOR_WHITE, " !מלחמת הנשקים התחילה");
  103.     format(knob, sizeof(knob), " $%d :פרס ", Reward);
  104.     SendClientMessageToAll(COLOR_WHITE, knob);
  105.     SendClientMessageToAll(COLOR_WHITE, " /JoinWeapons :להצטרף למלחמה הקש/י");
  106.     SendClientMessageToAll(COLOR_WHITE, " יש לכם 40 שניות להצטרף");
  107.     format(knob, sizeof(knob), " יש רק %d מקומות ", sizeof(gRandomWarSpawns));
  108.     SendClientMessageToAll(COLOR_WHITE, knob);
  109.     SendClientMessageToAll(0x0F66AFF, "[-----------[ !בהצלחה ]-----------]");
  110.     WarOn = 1; WarPlayers = 0;
  111.     Count = 40; Countdown(); CountFuc = 1;
  112.     return 1;
  113. }
  114.  
  115. public Countdown()
  116. {
  117.     new String[256];
  118.     format(String, 256,"~w~%d",Count);
  119.     GameTextForAll(String,1000,6);
  120.     if(Count > 0)
  121.     {
  122.         --Count;
  123.         SetTimer("Countdown", 1000, 0);
  124.     }
  125.     else
  126.     {
  127.         if(CountFuc == 1)
  128.         {
  129.             TeleportPlayerToWar();
  130.             if(knoob == 1)
  131.             {
  132.                 Count = 10; Countdown(); CountFuc = 2;
  133.             }
  134.         }
  135.         if(CountFuc == 2 && Count <= 0)
  136.         {
  137.             Unfreeze();
  138.         }
  139.     }
  140. }
  141.  
  142. public Unfreeze()
  143. {
  144.     for(new i;i<MAX_PLAYERS;i++)
  145.     {
  146.         if(PP[i] == 1)
  147.         {
  148.             TogglePlayerControllable(i, 1);
  149.             SetCameraBehindPlayer(i);
  150.             GameTextForAll("~g~GIVEWEAPON STARTED!", 3000, 0);
  151.         }
  152.     }
  153. }
  154.  
  155. public TeleportPlayerToWar()
  156. {
  157.     new WeaponName[24];
  158.     new rands = random(sizeof(WarWeapons));
  159.     Weapon = rands;
  160.     GetWeaponName(Weapon,WeaponName,24);
  161.     SendClientMessageToAll(COLOR_WHITE, "-------------------------");
  162.     SendClientMessageToAll(0xFF66FFAA, ".קרב הנשקים יחל בעוד מס' שניות");
  163.     format(knob, sizeof(knob), ".%s :הנשק הניבחר הוא", WeaponName);
  164.     SendClientMessageToAll(0xFF66FFAA, knob);
  165.     SendClientMessageToAll(COLOR_WHITE, "-------------------------");
  166.     if(WarPlayers < MinWarPlayers)
  167.     {
  168.         SendClientMessageToAll(COLOR_WHITE, ".המלחמה בוטלה עקב חוסר משתתפים");
  169.         WarEnd(0);
  170.         return 1;
  171.     }
  172.     for(new i;i<MAX_PLAYERS;i++)
  173.     {
  174.         if(InWar[i] == 1)
  175.         {
  176.             new rand = random(sizeof(gRandomWarSpawns));
  177.             SetPlayerPos(i, gRandomWarSpawns[rand][0], gRandomWarSpawns[rand][1], gRandomWarSpawns[rand][2]);
  178.             SetPlayerInterior(i, 10);
  179.             ResetPlayerWeapons(i);
  180.             GivePlayerWeapon(i,Weapon,5000);
  181.             SetPlayerArmour(i, 100.0);
  182.             SetPlayerHealth(i, 100.0);
  183.             WS = 1; PP[i] = 1; knoob = 1;
  184.             TogglePlayerControllable(i, 0);
  185.             CheckTime = SetTimer("Check",1000, 1);
  186.         }
  187.     }
  188.     return 1;
  189. }
  190.  
  191. public OnPlayerDeath(playerid, killerid, reason)
  192. {
  193.     if(PP[playerid] == 1)
  194.     {
  195.         WarPlayers --; InWar[playerid] = 0; PP[playerid] = 0;
  196.     }
  197.     return 1;
  198. }
  199.  
  200. public WarEnd(status)
  201. {
  202.     if(status == 0)
  203.     {
  204.         WarOn = 0; WarPlayers = 0;
  205.         for(new i;i<MAX_PLAYERS;i++)
  206.         {
  207.             InWar[i] = 0;  PP[i] = 0; WS = 0; knoob = 0;
  208.             KillTimer(CheckTime);
  209.         }
  210.         return 1;
  211.     }
  212.     else if(status == 1)
  213.     {
  214.         WarOn = 0; WarPlayers = 0;
  215.         GivePlayerMoney(WarWinner, Reward);
  216.         GetPlayerName(WarWinner, playername, sizeof(playername));
  217.         format(knob, sizeof(knob), "~W~The Winner Is~n~~r~%s", playername);
  218.         GameTextForAll(knob, 4000, 1);
  219.         ResetPlayerWeapons(WarWinner);
  220.         SetPlayerInterior(WarWinner, 0);
  221.         SetPlayerPos(WarWinner, 2028.6577,1341.8792,10.8203);
  222.         SendClientMessageToAll(COLOR_WHITE, "[________The Winner - Weapons________]");
  223.         SendClientMessageToAll(COLOR_GREENWIN, ".! קרב הנשקים הסתיים");
  224.         format(knob, sizeof(knob), ".$%d :נישאר אחרון וקיבל פרס %s", Reward, playername);
  225.         SendClientMessageToAll(COLOR_GREENWIN, knob);
  226.         SendClientMessageToAll(COLOR_WHITE, "------------------------------");
  227.         SetPlayerArmour(WarWinner, 100.0);
  228.         SetPlayerHealth(WarWinner, 100.0);
  229.         GivePlayerWeapon(WarWinner,24,130);
  230.         GivePlayerWeapon(WarWinner,26,1400);
  231.         GivePlayerWeapon(WarWinner,28,2600);
  232.         for(new i;i<MAX_PLAYERS;i++)
  233.         {
  234.             InWar[i] = 0; WS = 0; PP[i] = 0; knoob = 0;
  235.         }
  236.         return 1;
  237.     }
  238.     return 1;
  239. }
  240.  
  241. stock strtok(const string[], &index)
  242. {
  243.     new length = strlen(string);
  244.     while ((index < length) && (string[index] <= ' '))
  245.     {
  246.         index++;
  247.     }
  248.     new offset = index;
  249.     new result[20];
  250.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  251.     {
  252.         result[index - offset] = string[index];
  253.         index++;
  254.     }
  255.     result[index - offset] = EOS;
  256.     return result;
  257. }
  258.  
  259. public Check()
  260. {
  261.     if(WS == 1)
  262.     {
  263.         if(WarPlayers == 1)
  264.         {
  265.             for(new i;i<MAX_PLAYERS;i++)
  266.             {
  267.                 if(InWar[i] == 1)
  268.                 {
  269.                     WarWinner = i; WarEnd(1);
  270.                 }
  271.             }
  272.         }
  273.     }
  274.     return 1;
  275. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement