SpiralRock

Tushar

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