SpiralRock

Tushar

Aug 29th, 2010
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 17.15 KB | None | 0 0
  1. #include <a_vcmp>
  2. #include <core>
  3. #include <float>
  4.  
  5. static szGameModeName[128] = "fs 1.0"; //fag script
  6. static szGameModeAuthorName[128] = "[EAF]SpiralRock";
  7.  
  8. #define COLOR_GREY 0xAFAFAFAA
  9. #define COLOR_GREEN 0x33AA33AA
  10. #define COLOR_RED 0xAA3333AA
  11. #define COLOR_YELLOW 0xFFFF00AA
  12. #define COLOR_WHITE 0xFFFFFFAA
  13. #define INACTIVE_PLAYER_ID 255
  14.  
  15.  
  16.  
  17. #define MAX_WEAPONS 61
  18. new wep_init = 0;
  19. new gWeapons[MAX_WEAPONS][64];
  20. new gPlayers[MAX_PLAYERS][MAX_PLAYER_NAME+1];
  21.  
  22. #define PI  3.1415926535897932384626433832795
  23.  
  24. //------------------------------------------------------------------------------------------------------
  25.  
  26. main()
  27. {
  28.     print("\n  ----------------------------------\n");
  29.     printf("    %s\n",szGameModeName);
  30.     printf("    \tby %s\n",szGameModeAuthorName);
  31.     print("  ----------------------------------\n");
  32. }
  33.  
  34. //------------------------------------------------------------------------------------------------------
  35.  
  36. public OnPlayerConnect(playerid)
  37. {
  38.     SetWaterLevel(6.0);
  39.     SetGamespeed(100);
  40.     SetGravity(100);
  41.     GetPlayerName(playerid,gPlayers[playerid],MAX_PLAYER_NAME);
  42.     return 1;
  43. }
  44.  
  45. //------------------------------------------------------------------------------------------------------
  46.  
  47. public OnPlayerDisconnect(playerid, reason)
  48. {
  49.  
  50.     return 1;
  51. }
  52.  
  53. //------------------------------------------------------------------------------------------------------
  54.  
  55. public OnPlayerEnterVehicle(playerid,vehicleid,ispassenger)
  56. {
  57.     return 1;
  58. }
  59.  
  60. //------------------------------------------------------------------------------------------------------
  61.  
  62. public OnPlayerCommandText(playerid, cmdtext[])
  63. {
  64.     new cmd[256];
  65.     new tmp[256];
  66.     new szMsg[256];
  67.     new idx, newvar;
  68.     new Float:x, Float:y, Float:z;
  69.     cmd = strtok(cmdtext, idx);
  70.     if (strcmp(cmd, "hp", true) == 0)
  71.     {
  72.         tmp = strtok(cmdtext, idx);
  73.         if (!strlen(tmp)) {
  74.             GetPlayerHealth(playerid,x);
  75.             GetPlayerArmour(playerid,y);
  76.             if (IsPlayerInAnyVehicle(playerid))
  77.             {
  78.                 GetVehicleHealth(GetPlayerVehicleID(playerid),z);
  79.                 format(szMsg,sizeof(szMsg),"[%i] %s  - Health %.0f - Armour %.0 Vehicle Health %.0f",playerid,gPlayers[playerid],x,y,z);
  80.             } else {
  81.                 format(szMsg,sizeof(szMsg),"[%i] %s  - Health %.1f - Armour %.1f",playerid,gPlayers[playerid],x,y);
  82.             }
  83.             SendClientMessageToAll(COLOR_GREEN, szMsg);
  84.         } else {
  85.             newvar = FindPlayerIDFromString(tmp);
  86.             if (newvar != INACTIVE_PLAYER_ID) {
  87.                 GetPlayerHealth(newvar,x);
  88.                 GetPlayerArmour(newvar,y);
  89.                 if (IsPlayerInAnyVehicle(newvar))
  90.                 {
  91.                     GetVehicleHealth(GetPlayerVehicleID(newvar),z);
  92.                     format(szMsg,sizeof(szMsg),"[%i] %s  - Health %.0f - Armour %.0 Vehicle Health %.0f",newvar,gPlayers[newvar],x,y,z);
  93.                 } else {
  94.                     format(szMsg,sizeof(szMsg),"[%i] %s  - Health %.0f - Armour %.0f",newvar,gPlayers[newvar],x,y);             }
  95.  
  96.                 SendClientMessageToAll(COLOR_GREEN, szMsg);
  97.             }
  98.         }
  99.         return 1;
  100.     }
  101.     if (strcmp(cmd, "driveonwater", true) == 0)
  102.         {
  103.             tmp = strtok(cmdtext, idx);
  104.             if(!strlen(tmp)) {
  105.                 SetPlayerDriveOnWater(1);
  106.                 format(szMsg,sizeof(szMsg),"Drive On Water SET ON");
  107.             } else {
  108.                 format(szMsg,sizeof(szMsg),"Drive On Water SET OFF");
  109.                 SetPlayerDriveOnWater(0);
  110.             }
  111.             SendClientMessage(playerid, COLOR_GREEN, szMsg);
  112.             return 1;
  113.         }
  114.         else if (strcmp(cmd, "shootinair", true) == 0)
  115.         {
  116.             tmp = strtok(cmdtext, idx);
  117.             if(!strlen(tmp)) {
  118.                 EnableShootInAir(255,1);
  119.                 format(szMsg,sizeof(szMsg),"Shoot In Air Enabled");
  120.             } else {
  121.                 format(szMsg,sizeof(szMsg),"Shoot In Air Disabled");
  122.                 EnableShootInAir(255,0);
  123.             }
  124.             SendClientMessage(playerid, COLOR_GREEN, szMsg);
  125.             return 1;
  126.         }
  127.         else if (strcmp(cmd, "stuntbike", true) == 0)
  128.         {
  129.             tmp = strtok(cmdtext, idx);
  130.             if(!strlen(tmp)) {
  131.                 EnableStuntBike(255,1);
  132.                 format(szMsg,sizeof(szMsg),"Stuntbike Enabled");
  133.             } else {
  134.                 format(szMsg,sizeof(szMsg),"Stuntbike Disabled");
  135.                 EnableStuntBike(255,0);
  136.             }
  137.             SendClientMessage(playerid, COLOR_GREEN, szMsg);
  138.             return 1;
  139.         }
  140.         else if (strcmp(cmd, "flycar", true) == 0)
  141.         {
  142.             tmp = strtok(cmdtext, idx);
  143.             if(!strlen(tmp)) {
  144.                 Flyingcars(1);
  145.             } else {
  146.                 Flyingcars(0);
  147.             }
  148.             return 1;
  149.         }
  150.         else if (strcmp(cmd, "taxi", true) == 0)
  151.         {
  152.             tmp = strtok(cmdtext, idx);
  153.             if(!strlen(tmp)) {
  154.                 format(szMsg,sizeof(szMsg),"TaxiBoost Enabled");
  155.                 Taxiboostjump(1);
  156.             } else {
  157.                 format(szMsg,sizeof(szMsg),"TaxiBoost Disabled");
  158.                 Taxiboostjump(0);
  159.             }
  160.             SendClientMessage(playerid, COLOR_GREEN, szMsg);
  161.             return 1;
  162.         }
  163.         else if (strcmp(cmd, "fastswitch", true) == 0)
  164.         {
  165.             tmp = strtok(cmdtext, idx);
  166.             if(!strlen(tmp)) {
  167.                 FastSwitch(1);
  168.             } else {
  169.                 FastSwitch(0);
  170.             }
  171.             return 1;
  172.         }
  173.         else if (strcmp(cmd, "jumpswitch", true) == 0)
  174.         {
  175.             tmp = strtok(cmdtext, idx);
  176.             if(!strlen(tmp)) {
  177.                 Jumpswitch(1);
  178.             } else {
  179.                 Jumpswitch(0);
  180.             }
  181.             return 1;
  182.         }
  183.         else if (strcmp(cmd, "heal", true) == 0)
  184.         {
  185.             tmp = strtok(cmdtext, idx);
  186.             if (!strlen(tmp)) { newvar = playerid; }
  187.             else { newvar = FindPlayerIDFromString(tmp); }
  188.             if (newvar == INACTIVE_PLAYER_ID) { return 1; }
  189.             if (IsPlayerInAnyVehicle(newvar)) {
  190.                 SetVehicleHealth(GetPlayerVehicleID(newvar),1000.0);
  191.                 SetVehicleTyre(GetPlayerVehicleID(newvar),1);
  192.                 SetPlayerHealth(newvar,100.0);
  193.             } else {
  194.                 SetPlayerHealth(newvar,100.0);
  195.             }
  196.             return 1;
  197.         }
  198.     else if (strcmp(cmd, "armour", true) == 0)
  199.         {
  200.             tmp = strtok(cmdtext, idx);
  201.             if (!strlen(tmp)) { newvar = playerid; }
  202.             else { newvar = FindPlayerIDFromString(tmp); }
  203.             if (newvar == INACTIVE_PLAYER_ID) { return 1; }
  204.             SetPlayerArmour(newvar,100.0);
  205.             return 1;
  206.         }
  207.         else if (strcmp(cmd, "wep", true) == 0)
  208.         {
  209.             tmp = strtok(cmdtext, idx);
  210.             new len = strlen(tmp);
  211.             if (!len) { format(szMsg,sizeof(szMsg),"Usage: !wep <name/id>",tmp);SendClientMessage(playerid, COLOR_GREY, szMsg);return 1;}
  212.             newvar = FindWepIDFromString(tmp);
  213.             if (newvar != 0) { SetPlayerWeapon(playerid,newvar,10000); }
  214.             return 1;
  215.         }
  216.     return 0;
  217. }
  218.  
  219.  
  220. //------------------------------------------------------------------------------------------------------
  221.  
  222. public OnPlayerText(playerid, cmdtext[])
  223. {
  224.     new cmd[256];
  225.     new tmp[256];
  226.     new szMsg[256];
  227.     new idx, newvar;
  228.     new Float:x, Float:y, Float:z;
  229.     cmd = strtok(cmdtext, idx);
  230.     if (strcmp(cmd, "!goto", true) == 0)
  231.     {
  232.         tmp = strtok(cmdtext, idx);
  233.         new len = strlen(tmp);
  234.         if (!len) { format(szMsg,sizeof(szMsg),"Usage: !goto <name/id>",tmp);
  235.         SendClientMessage(playerid, COLOR_GREY, szMsg);return 1;}
  236.         newvar = FindPlayerIDFromString(tmp);
  237.         if (newvar != INACTIVE_PLAYER_ID) {
  238.             GetPlayerPos(newvar,x,y,z);
  239.             SetPlayerPos(playerid,x,y + 1.0,z,0,0);
  240.             format(szMsg,sizeof(szMsg),"Taking [%i] %s to [%i] %s.",playerid,gPlayers[playerid],newvar,gPlayers[newvar]);
  241.             SendClientMessageToAll(COLOR_GREEN, szMsg);
  242.         }
  243.         return 1;
  244.     }
  245.     else if (strcmp(cmd, "!hp", true) == 0)
  246.     {
  247.         tmp = strtok(cmdtext, idx);
  248.         if (!strlen(tmp)) {
  249.             GetPlayerHealth(playerid,x);
  250.             GetPlayerArmour(playerid,y);
  251.             if (IsPlayerInAnyVehicle(playerid))
  252.             {
  253.                 GetVehicleHealth(GetPlayerVehicleID(playerid),z);
  254.                 format(szMsg,sizeof(szMsg),"[%i] %s  - Health %.0f - Armour %.0 Vehicle Health %.0f",playerid,gPlayers[playerid],x,y,z);
  255.             } else {
  256.                 format(szMsg,sizeof(szMsg),"[%i] %s  - Health %.1f - Armour %.1f",playerid,gPlayers[playerid],x,y);
  257.             }
  258.             SendClientMessageToAll(COLOR_GREEN, szMsg);
  259.         } else {
  260.             newvar = FindPlayerIDFromString(tmp);
  261.             if (newvar != INACTIVE_PLAYER_ID) {
  262.                 GetPlayerHealth(newvar,x);
  263.                 GetPlayerArmour(newvar,y);
  264.                 if (IsPlayerInAnyVehicle(newvar))
  265.                 {
  266.                     GetVehicleHealth(GetPlayerVehicleID(newvar),z);
  267.                     format(szMsg,sizeof(szMsg),"[%i] %s  - Health %.0f - Armour %.0 Vehicle Health %.0f",newvar,gPlayers[newvar],x,y,z);
  268.                 } else {
  269.                     format(szMsg,sizeof(szMsg),"[%i] %s  - Health %.0f - Armour %.0f",newvar,gPlayers[newvar],x,y);             }
  270.  
  271.                 SendClientMessageToAll(COLOR_GREEN, szMsg);
  272.             }
  273.         }
  274.         return 1;
  275.     }
  276.     else if (strcmp(cmd, "!heal", true) == 0)
  277.     {
  278.         tmp = strtok(cmdtext, idx);
  279.         if (!strlen(tmp)) { newvar = playerid; }
  280.         else { newvar = FindPlayerIDFromString(tmp); }
  281.         if (newvar == INACTIVE_PLAYER_ID) { return 1; }
  282.         if (IsPlayerInAnyVehicle(newvar)) {
  283.             SetVehicleHealth(GetPlayerVehicleID(newvar),1000.0);
  284.             SetVehicleTyre(GetPlayerVehicleID(newvar),1);
  285.             format(szMsg,sizeof(szMsg),"You are now healed",tmp);
  286.             SendClientMessage(playerid,COLOR_GREEN, szMsg);
  287.         } else {
  288.             SetPlayerHealth(newvar,100.0);
  289.             format(szMsg,sizeof(szMsg),"You are now healed",tmp);
  290.             SendClientMessage(playerid,COLOR_GREEN, szMsg);
  291.         }
  292.         return 1;
  293.     }
  294.     else if (strcmp(cmd, "!buy", true) == 0) {
  295.         tmp = strtok(cmdtext, idx);
  296.         if (!strlen(tmp))
  297.             return SendClientMessage(playerid, COLOR_RED, "!buy <wep-name>");
  298.         else
  299.             if (strcmp(tmp, "m60", true) == 0) {
  300.  
  301.             }
  302.            
  303.     }
  304.     return 1;
  305. }
  306.  
  307. //------------------------------------------------------------------------------------------------------
  308.  
  309. public OnPlayerSpawn(playerid,classid,teamid)
  310. {
  311.     return 1;
  312. }
  313.  
  314. //------------------------------------------------------------------------------------------------------
  315.  
  316. public OnPlayerDeath(playerid, killerid, reason)
  317. {
  318.    
  319.     return 1;
  320. }
  321.  
  322. //------------------------------------------------------------------------------------------------------
  323.  
  324. public OnPlayerRequestClass(playerid, classid, skinid)
  325. {
  326.  
  327.     return 1;
  328. }
  329.  
  330. //------------------------------------------------------------------------------------------------------
  331.  
  332. public OnPickedUp(pickupid, playerid)
  333. {   if ((pickupid==1) || pickupid==2)
  334.         SendClientMessage(playerid,COLOR_YELLOW,"Hey, you can buy guns here");
  335.     return 1;
  336. }
  337.  
  338. //------------------------------------------------------------------------------------------------------
  339. public OnGameModeInit()
  340. {
  341.     SetGameModeText(szGameModeName);
  342.  
  343.     ShowPlayerMarkers(1);
  344.  
  345.     // Player Classes
  346.     AddPlayerClassEx(1, 149, -500.0569, -465.1577, 11.4867, 0.7182, 17, 500, 24, 500, 21, 500); // 149 green
  347.     AddPlayerClassEx(0, 141, -374.1536, -223.0066, 9.1213, 183.0354, 17, 500, 24, 500, 21, 500); //141 blue
  348.    
  349.     SetPlayerFriendlyFire(false);
  350.     Jumpswitch(1);
  351.  
  352.     // Vehicles
  353.  
  354.         //Police
  355.     AddStaticVehicle(156, -715.1685, -482.2235, 10.8822, 0.9519, 3, 1);
  356.     AddStaticVehicle(156, -714.9229, -497.0534, 10.8654, 0.9236, 3, 1);
  357.     AddStaticVehicle(156, -183.8194, -465.4719, 10.8446, 10.8470, 3, 1);
  358.     AddStaticVehicle(156, -181.0072, -480.6185, 10.8508, 9.8620, 3, 1);
  359.  
  360.         //Enforcers
  361.     AddStaticVehicle(157, -715.0520, -489.2520, 10.8733, 0.9514, 3, 1);
  362.     AddStaticVehicle(157, -182.3127, -473.3688, 10.8385, 10.8059, 3, 1);
  363.  
  364.         //Team green vehicles
  365.     AddStaticVehicle(133, -539.4441, -474.2635, 11.1189, 270.2599, 44, 1);
  366.     AddStaticVehicle(143, -520.8994, -474.1699, 11.1477, 272.4575, 44, 1);
  367.     AddStaticVehicle(149, -497.1541, -473.3339, 11.1770, 272.5067, 44, 1);
  368.     AddStaticVehicle(154, -470.2748, -472.9805, 11.0522, 273.4655, 44, 1);
  369.     AddStaticVehicle(152, -457.6939, -464.3488, 11.0436, 359.1348, 44, 1);
  370.     AddStaticVehicle(198, -475.5645, -434.3491, 11.4980, 180.2597, 44, 1);
  371.     AddStaticVehicle(198, -469.9465, -432.6784, 11.4211, 186.8397, 44, 1);
  372.  
  373.         //Team Blue vehicles
  374.     AddStaticVehicle(133, -467.0890, -244.5312, 10.3687, 268.6380, 2, 1);
  375.     AddStaticVehicle(143, -439.0008, -241.7432, 10.3688, 267.9733, 2, 1);
  376.     AddStaticVehicle(149, -430.7938, -253.1322, 10.5549, 182.3609, 2, 1);
  377.     AddStaticVehicle(154, -415.0505, -245.8516, 10.5152, 91.1488, 2, 1);
  378.     AddStaticVehicle(152, -414.5432, -259.7456, 10.9684, 90.4392, 2, 1);
  379.     AddStaticVehicle(198, -405.4318, -311.1410, 11.0946, 185.1944, 2, 1);
  380.     AddStaticVehicle(198, -411.9401, -312.0182, 11.2288, 185.1944, 2, 1);
  381.  
  382.  
  383. /*
  384.     AddStaticPickup(id, type, Float:x, Float:y, Float:z, ammo, respawnseconds);
  385.  
  386.     -for cash pickups use type 501
  387.     -use -1 for respawnseconds to select default respawn 4 minutes
  388.         *   may ditch the manual id arg and have it auto id instead   *
  389.  
  390. */
  391.     new sp=1;
  392.  
  393.         //Team Green pickups
  394.     AddStaticPickup(sp++, 405, -488.4050, -421.6337, 11.4306);  //gunbox
  395.    
  396.  
  397.         //Team Blue pickups
  398.     AddStaticPickup(sp++, 405, -392.9321,-279.0997,10.6587);  //gunbox
  399.  
  400.  
  401.     SetWorldBounds(5000.0,-5000.0,5000.0,-5000.0);
  402.  
  403.     SetCameraPos(-231.4, -440.0, 32.1);
  404.  
  405.     SetCameraLookAt(-232.0314, -442.6181, 33.1);
  406.  
  407.     SetPlayerStartPos(-232.0314, -442.6181, 32.7944);
  408.     new q,c=0;
  409.     for (q=0;q < MAX_PLAYERS; q++) {
  410.         if (IsPlayerConnected(q)) {
  411.             new pname[MAX_PLAYER_NAME+1];
  412.             GetPlayerName(q,pname,MAX_PLAYER_NAME);
  413.             gPlayers[q] = pname;
  414.             c++;
  415.         } else { gPlayers[q] = ""; }
  416.     }
  417.     InitWepList();
  418.  
  419.     printf("\n\n**\tscript init loaded\t**\n**\t%d players\t**\n",c);
  420.  
  421.     new szMessage[256];
  422.     format(szMessage,256,"Game Mode %s loaded.",szGameModeName);
  423.     SendClientMessageToAll(COLOR_GREY, szMessage);
  424.  
  425.     return 1;
  426. }
  427.  
  428.  
  429.  
  430. //------------------------------------------------------------------------------------------------------
  431. public findDistance (x1,y1,z1,x2,y2,z2) {
  432.     new Float:distance;
  433.     distance = floatsqroot(floatpower(x1-x2, 2) + floatpower(y1-y2, 2) + floatpower(z1-z2, 2));
  434.     return distance;
  435. }
  436.  
  437. public FindPlayerIDFromString(string[])
  438. {// for determining player id from a string  -bakasan
  439.     new szMsg[256];
  440.     new player = INACTIVE_PLAYER_ID;
  441.     new p = 0;
  442.     while (p < MAX_PLAYERS) { if (strfind(gPlayers[p],string,true) != -1) { player=p;break; } p++; }
  443.     if (player == INACTIVE_PLAYER_ID) {// string didnt match so check if it can be an id
  444.         if ((strlen(string) > 2) || (isnumeric(string) == 0)) {
  445.             format(szMsg,sizeof(szMsg),"Unable to find %s.",string);
  446.             SendClientMessageToAll(COLOR_GREY, szMsg);
  447.             return INACTIVE_PLAYER_ID;
  448.         }
  449.         player = strval(string);// string is numeric and not more than 2 digits
  450.     }
  451.     if (!IsPlayerConnected(player)) {
  452.         format(szMsg,sizeof(szMsg),"Invalid ID %d.",player);
  453.         SendClientMessageToAll(COLOR_GREY, szMsg);
  454.         return INACTIVE_PLAYER_ID;
  455.     }
  456.     return player;// valid id found
  457. }
  458.  
  459. //------------------------------------------------------------------------------------------------------
  460. public InitWepList()
  461. {
  462.     if (wep_init == 1) { return 1; }
  463.     gWeapons[0] = "Fist";
  464.     gWeapons[1] = "BrassKnuckle";
  465.     gWeapons[2] = "ScrewDriver";
  466.     gWeapons[3] = "GolfClub";
  467.     gWeapons[4] = "NightStick";
  468.     gWeapons[5] = "Knife";
  469.     gWeapons[6] = "BaseballBat";
  470.     gWeapons[7] = "Hammer";
  471.     gWeapons[8] = "Cleaver";
  472.     gWeapons[9] = "Machete";
  473.     gWeapons[10] = "Katana";
  474.     gWeapons[11] = "Chainsaw";
  475.     gWeapons[12] = "Grenade";
  476.     gWeapons[13] = "RemoteGrenade";
  477.     gWeapons[14] = "TearGas";
  478.     gWeapons[15] = "Molotov";
  479.     gWeapons[16] = "Missile";//called "Rocket" in weapon.dat
  480.     gWeapons[17] = "Colt45";
  481.     gWeapons[18] = "Python";
  482.     gWeapons[19] = "Shotgun";
  483.     gWeapons[20] = "Spaz";//Spas12Shotgun
  484.     gWeapons[21] = "Stubby";//StubbyShotgun
  485.     gWeapons[22] = "Tec9";
  486.     gWeapons[23] = "Uzi";
  487.     gWeapons[24] = "Ingrams";
  488.     gWeapons[25] = "MP5";
  489.     gWeapons[26] = "M4";
  490.     gWeapons[27] = "Ruger";
  491.     gWeapons[28] = "SniperRifle";
  492.     gWeapons[29] = "LaserScope";
  493.     gWeapons[30] = "RocketLauncher";
  494.     gWeapons[31] = "FlameThrower";
  495.     gWeapons[32] = "M60";
  496.     gWeapons[33] = "Minigun";
  497.     gWeapons[34] = "none34";
  498.     gWeapons[35] = "Heli-Cannon";
  499.     gWeapons[36] = "none36";
  500.     gWeapons[37] = "none37";
  501.     gWeapons[38] = "none38";
  502.     gWeapons[39] = "Vehicle";
  503.     gWeapons[40] = "none40";
  504.     gWeapons[41] = "41";
  505.     gWeapons[42] = "none42";
  506.     gWeapons[43] = "Drowned";
  507.     gWeapons[44] = "Impact";
  508.     gWeapons[45] = "none45";
  509.     gWeapons[46] = "none46";
  510.     gWeapons[47] = "none47";
  511.     gWeapons[48] = "none48";
  512.     gWeapons[49] = "none49";
  513.     gWeapons[50] = "none50";
  514.     gWeapons[51] = "none51";
  515.     gWeapons[52] = "none52";
  516.     gWeapons[53] = "none53";
  517.     gWeapons[54] = "none54";
  518.     gWeapons[55] = "none55";
  519.     gWeapons[56] = "none56";
  520.     gWeapons[57] = "none57";
  521.     gWeapons[58] = "none58";
  522.     gWeapons[59] = "none59";
  523.     gWeapons[60] = "Heli-Blades";
  524.     wep_init = 1;
  525.     return 1;
  526. }
  527.  
  528. public FindWepIDFromString(string[])
  529. {// for determining weapon id from a string  -bakasan
  530.     if (wep_init == 0) { InitWepList(); }
  531.     new szMsg[256];
  532.     new match = 0;
  533.     new p = 0;
  534.     while (p < MAX_WEAPONS) { if (strfind(gWeapons[p],string,true) != -1) { match=p;break; } p++; }
  535.     if (match == 0) {// string didnt match so check if it can be an id
  536.         if ((strlen(string) > 2) || (isnumeric(string) == 0)) {
  537.             format(szMsg,sizeof(szMsg),"Unable to find weapon %s.",string);
  538.             SendClientMessageToAll(COLOR_GREY, szMsg);
  539.             return 0;
  540.         }
  541.         match = strval(string);// string is numeric and not more than 2 digits
  542.     }
  543.     if ((match < 1) || (match > 33)) {
  544.         format(szMsg,sizeof(szMsg),"Invalid Weapon ID %d.",match);
  545.         SendClientMessageToAll(COLOR_GREY, szMsg);
  546.         return 0;
  547.     }
  548.     return match;// valid id found
  549. }
  550. strtok(const string[], &index)
  551. {
  552.     new length = strlen(string);
  553.     while ((index < length) && (string[index] <= ' ')){ index++; }
  554.     new offset = index;
  555.     new result[20];
  556.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  557.     {
  558.         result[index - offset] = string[index];
  559.         index++;
  560.     }
  561.     result[index - offset] = EOS;
  562.     return result;
  563. }
  564. isnumeric(const string[])
  565. {// mike's function
  566.     for (new i = 0, j = strlen(string); i < j; i++) { if (string[i] > '9' || string[i] < '0') return 0; }
  567.     return 1;
  568. }
Add Comment
Please, Sign In to add comment