Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #pragma tabsize 0
- #define COLOR_RED 0xFF0000AA
- #define COLOR_WHITE 0xFFFFFFAA
- #define COLOR_LIGHTGREEN 0x24FF0AB9
- #define COLOR_GREENWIN 0x0F66FFF
- #define MinWarPlayers 2
- new WarOn;
- new InWar[MAX_PLAYERS];
- new WarPlayers;
- new playername[MAX_PLAYER_NAME];
- new Count;
- new knoob;
- new CountFuc;
- new Reward;
- new knob[256];
- new WarWinner;
- new CheckTime;
- new WS;
- new Weapon = 0;
- new PP[MAX_PLAYERS];
- new WarWeapons[] = {42,41,37,5,8,4,6,2,15,7,3,9};
- forward Unfreeze();
- forward Check();
- forward WarEnd(status);
- forward TeleportPlayerToWar();
- forward Countdown();
- forward WarStart();
- new Float:gRandomWarSpawns[][3] =
- {
- {-1085.3271,1019.7804,1342.7926},
- {-1132.9607,1028.6680,1345.7377},
- {-1128.3600,1095.9415,1345.7709},
- {-1098.6946,1098.4323,1341.1632},
- {-1071.4646,1088.1956,1346.0206},
- {-1039.4835,1100.4468,1343.1393},
- {-1043.1943,1041.5938,1341.3516},
- {-1020.2195,1051.2196,1345.9545},
- {-973.8190,1060.5537,1345.6772},
- {-973.6674,1027.6255,1345.0448},
- {-974.3493,1089.1172,1344.9795},
- {-1009.8291,1080.3978,1341.0828},
- {-1019.2279,1071.8867,1347.4093},
- {-1046.0696,1023.0779,1343.0669},
- {-1072.4380,1031.8779,1342.9623},
- {-1104.6825,1097.2749,1341.8513},
- {-1129.6497,1019.8154,1345.6614},
- {-1064.0248,1032.7473,1344.5297},
- {-1054.4865,1058.6794,1341.3516},
- {-1025.9915,1066.3752,1343.8276}
- };
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new cmd[256];
- new idx;
- new tmp[256];
- cmd = strtok(cmdtext, idx);
- if(!strcmp(cmd, "/startweapons", true))
- {
- tmp = strtok(cmdtext, idx);
- if(!IsPlayerAdmin(playerid)) return 0;
- if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "Syntax Error: \"/STARTWEAPONS <MONEY>\".");
- if(WarOn == 1) return SendClientMessage(playerid, COLOR_RED, ".יש כבר מלחמה פעילה");
- Reward = strval(tmp);
- WarStart();
- return 1;
- }
- if(!strcmp(cmdtext, "/joinweapons", true))
- {
- if(WarOn == 0) return 0;
- if(WS == 1) return SendClientMessage(playerid, COLOR_RED, ".המלחמה כבר התחילה!, נסה פעם הבאה");
- if(WarPlayers == sizeof(gRandomWarSpawns)) return SendClientMessage(playerid, COLOR_RED, ".כל המקומות נתפסו!, נסה פעם באה");
- if(InWar[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, ".הצטרפת כבר לנשקים, אנא המתן בסבלנות");
- SendClientMessage(playerid, COLOR_LIGHTGREEN, ".!הצטרפת למלחמה בהצלחה");
- WarPlayers ++; InWar[playerid] = 1;
- return 1;
- }
- if(!strcmp(cmd, "/endweapons", true))
- {
- if(!IsPlayerAdmin(playerid)) return 0;
- if(WarOn == 0) return SendClientMessage(playerid, COLOR_RED, ".אין כרגע גאטר פעיל");
- Count = 0;
- WarEnd(0);
- return 1;
- }
- return 0;
- }
- public WarStart()
- {
- SendClientMessageToAll(0x0F66AFF, "[------[ מערכת מלחמת נשקים ]------]");
- SendClientMessageToAll(COLOR_WHITE, " !מלחמת הנשקים התחילה");
- format(knob, sizeof(knob), " $%d :פרס ", Reward);
- SendClientMessageToAll(COLOR_WHITE, knob);
- SendClientMessageToAll(COLOR_WHITE, " /JoinWeapons :להצטרף למלחמה הקש/י");
- SendClientMessageToAll(COLOR_WHITE, " יש לכם 40 שניות להצטרף");
- format(knob, sizeof(knob), " יש רק %d מקומות ", sizeof(gRandomWarSpawns));
- SendClientMessageToAll(COLOR_WHITE, knob);
- SendClientMessageToAll(0x0F66AFF, "[-----------[ !בהצלחה ]-----------]");
- WarOn = 1; WarPlayers = 0;
- Count = 40; Countdown(); CountFuc = 1;
- return 1;
- }
- public Countdown()
- {
- new String[256];
- format(String, 256,"~w~%d",Count);
- GameTextForAll(String,1000,6);
- if(Count > 0)
- {
- --Count;
- SetTimer("Countdown", 1000, 0);
- }
- else
- {
- if(CountFuc == 1)
- {
- TeleportPlayerToWar();
- if(knoob == 1)
- {
- Count = 10; Countdown(); CountFuc = 2;
- }
- }
- if(CountFuc == 2 && Count <= 0)
- {
- Unfreeze();
- }
- }
- }
- public Unfreeze()
- {
- for(new i;i<MAX_PLAYERS;i++)
- {
- if(PP[i] == 1)
- {
- TogglePlayerControllable(i, 1);
- SetCameraBehindPlayer(i);
- GameTextForAll("~g~GIVEWEAPON STARTED!", 3000, 0);
- }
- }
- }
- public TeleportPlayerToWar()
- {
- new WeaponName[24];
- new rands = random(sizeof(WarWeapons));
- Weapon = rands;
- GetWeaponName(Weapon,WeaponName,24);
- SendClientMessageToAll(COLOR_WHITE, "-------------------------");
- SendClientMessageToAll(0xFF66FFAA, ".קרב הנשקים יחל בעוד מס' שניות");
- format(knob, sizeof(knob), ".%s :הנשק הניבחר הוא", WeaponName);
- SendClientMessageToAll(0xFF66FFAA, knob);
- SendClientMessageToAll(COLOR_WHITE, "-------------------------");
- if(WarPlayers < MinWarPlayers)
- {
- SendClientMessageToAll(COLOR_WHITE, ".המלחמה בוטלה עקב חוסר משתתפים");
- WarEnd(0);
- return 1;
- }
- for(new i;i<MAX_PLAYERS;i++)
- {
- if(InWar[i] == 1)
- {
- new rand = random(sizeof(gRandomWarSpawns));
- SetPlayerPos(i, gRandomWarSpawns[rand][0], gRandomWarSpawns[rand][1], gRandomWarSpawns[rand][2]);
- SetPlayerInterior(i, 10);
- ResetPlayerWeapons(i);
- GivePlayerWeapon(i,Weapon,5000);
- SetPlayerArmour(i, 100.0);
- SetPlayerHealth(i, 100.0);
- WS = 1; PP[i] = 1; knoob = 1;
- TogglePlayerControllable(i, 0);
- CheckTime = SetTimer("Check",1000, 1);
- }
- }
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- if(PP[playerid] == 1)
- {
- WarPlayers --; InWar[playerid] = 0; PP[playerid] = 0;
- }
- return 1;
- }
- public WarEnd(status)
- {
- if(status == 0)
- {
- WarOn = 0; WarPlayers = 0;
- for(new i;i<MAX_PLAYERS;i++)
- {
- InWar[i] = 0; PP[i] = 0; WS = 0; knoob = 0;
- KillTimer(CheckTime);
- }
- return 1;
- }
- else if(status == 1)
- {
- WarOn = 0; WarPlayers = 0;
- GivePlayerMoney(WarWinner, Reward);
- GetPlayerName(WarWinner, playername, sizeof(playername));
- format(knob, sizeof(knob), "~W~The Winner Is~n~~r~%s", playername);
- GameTextForAll(knob, 4000, 1);
- ResetPlayerWeapons(WarWinner);
- SetPlayerInterior(WarWinner, 0);
- SetPlayerPos(WarWinner, 2028.6577,1341.8792,10.8203);
- SendClientMessageToAll(COLOR_WHITE, "[________The Winner - Weapons________]");
- SendClientMessageToAll(COLOR_GREENWIN, ".! קרב הנשקים הסתיים");
- format(knob, sizeof(knob), ".$%d :נישאר אחרון וקיבל פרס %s", Reward, playername);
- SendClientMessageToAll(COLOR_GREENWIN, knob);
- SendClientMessageToAll(COLOR_WHITE, "------------------------------");
- SetPlayerArmour(WarWinner, 100.0);
- SetPlayerHealth(WarWinner, 100.0);
- GivePlayerWeapon(WarWinner,24,130);
- GivePlayerWeapon(WarWinner,26,1400);
- GivePlayerWeapon(WarWinner,28,2600);
- for(new i;i<MAX_PLAYERS;i++)
- {
- InWar[i] = 0; WS = 0; PP[i] = 0; knoob = 0;
- }
- return 1;
- }
- return 1;
- }
- stock strtok(const string[], &index)
- {
- new length = strlen(string);
- while ((index < length) && (string[index] <= ' '))
- {
- index++;
- }
- new offset = index;
- new result[20];
- while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
- {
- result[index - offset] = string[index];
- index++;
- }
- result[index - offset] = EOS;
- return result;
- }
- public Check()
- {
- if(WS == 1)
- {
- if(WarPlayers == 1)
- {
- for(new i;i<MAX_PLAYERS;i++)
- {
- if(InWar[i] == 1)
- {
- WarWinner = i; WarEnd(1);
- }
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement