SpiralRock

Untitled

Aug 29th, 2010
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 20.57 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: GetDistance(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.     new Float:distance;
  232.     cmd = strtok(cmdtext, idx);
  233.     if (strcmp(cmd, "!goto", true) == 0)
  234.     {
  235.         tmp = strtok(cmdtext, idx);
  236.         new len = strlen(tmp);
  237.         if (!len) { format(szMsg,sizeof(szMsg),"Usage: !goto <name/id>",tmp);
  238.         SendClientMessage(playerid, COLOR_GREY, szMsg);return 1;}
  239.         newvar = FindPlayerIDFromString(tmp);
  240.         if (newvar != INACTIVE_PLAYER_ID) {
  241.             GetPlayerPos(newvar,x,y,z);
  242.             SetPlayerPos(playerid,x,y + 1.0,z,0,0);
  243.             format(szMsg,sizeof(szMsg),"Taking [%i] %s to [%i] %s.",playerid,gPlayers[playerid],newvar,gPlayers[newvar]);
  244.             SendClientMessageToAll(COLOR_GREEN, szMsg);
  245.         }
  246.         return 1;
  247.     }
  248.     else if (strcmp(cmd, "!hp", true) == 0)
  249.     {
  250.         tmp = strtok(cmdtext, idx);
  251.         if (!strlen(tmp)) {
  252.             GetPlayerHealth(playerid,x);
  253.             GetPlayerArmour(playerid,y);
  254.             if (IsPlayerInAnyVehicle(playerid))
  255.             {
  256.                 GetVehicleHealth(GetPlayerVehicleID(playerid),z);
  257.                 format(szMsg,sizeof(szMsg),"[%i] %s  - Health %.0f - Armour %.0 Vehicle Health %.0f",playerid,gPlayers[playerid],x,y,z);
  258.             } else {
  259.                 format(szMsg,sizeof(szMsg),"[%i] %s  - Health %.1f - Armour %.1f",playerid,gPlayers[playerid],x,y);
  260.             }
  261.             SendClientMessageToAll(COLOR_GREEN, szMsg);
  262.         } else {
  263.             newvar = FindPlayerIDFromString(tmp);
  264.             if (newvar != INACTIVE_PLAYER_ID) {
  265.                 GetPlayerHealth(newvar,x);
  266.                 GetPlayerArmour(newvar,y);
  267.                 if (IsPlayerInAnyVehicle(newvar))
  268.                 {
  269.                     GetVehicleHealth(GetPlayerVehicleID(newvar),z);
  270.                     format(szMsg,sizeof(szMsg),"[%i] %s  - Health %.0f - Armour %.0 Vehicle Health %.0f",newvar,gPlayers[newvar],x,y,z);
  271.                 } else {
  272.                     format(szMsg,sizeof(szMsg),"[%i] %s  - Health %.0f - Armour %.0f",newvar,gPlayers[newvar],x,y);             }
  273.  
  274.                 SendClientMessageToAll(COLOR_GREEN, szMsg);
  275.             }
  276.         }
  277.         return 1;
  278.     }
  279.     else if (strcmp(cmd, "!heal", true) == 0)
  280.     {
  281.         tmp = strtok(cmdtext, idx);
  282.         if (!strlen(tmp)) { newvar = playerid; }
  283.         else { newvar = FindPlayerIDFromString(tmp); }
  284.         if (newvar == INACTIVE_PLAYER_ID) { return 1; }
  285.         if (IsPlayerInAnyVehicle(newvar)) {
  286.             SetVehicleHealth(GetPlayerVehicleID(newvar),1000.0);
  287.             SetVehicleTyre(GetPlayerVehicleID(newvar),1);
  288.             format(szMsg,sizeof(szMsg),"You are now healed",tmp);
  289.             SendClientMessage(playerid,COLOR_GREEN, szMsg);
  290.         } else {
  291.             SetPlayerHealth(newvar,100.0);
  292.             format(szMsg,sizeof(szMsg),"You are now healed",tmp);
  293.             SendClientMessage(playerid,COLOR_GREEN, szMsg);
  294.         }
  295.         return 1;
  296.     }
  297.     else if (strcmp(cmd, "!buy", true) == 0) {
  298.         tmp = strtok(cmdtext, idx);
  299.         if (!strlen(tmp))
  300.             return SendClientMessage(playerid, COLOR_RED, "!buy <wep-name>");
  301.         else
  302.             newvar = GetPlayerTeam(playerid);
  303.             if (newvar==0) {//team green
  304.                 GetPlayerPos(playerid, x, y, z);
  305.                 distance=GetDistance(x, y, z,-488.4050, -421.6337, 11.4306);
  306.                 if (distance < 5.0) {
  307.                     getAmmunation(playerid,tmp);
  308.                     return 1;
  309.                 }
  310.                 else
  311.                     return SendClientMessage(playerid, COLOR_RED, "This is not your weapon dealing spot");
  312.             }
  313.             else if (newvar==1) {//blue team
  314.                 GetPlayerPos(playerid, x, y, z);
  315.                 distance=GetDistance(x, y, z, -392.9321, -279.0997, 10.6587);
  316.                 if (distance < 5.0) {
  317.                     getAmmunation(playerid,tmp);
  318.                     return 1;
  319.                 }
  320.                 else
  321.                     return SendClientMessage(playerid, COLOR_RED, "This is not your weapon dealing spot");
  322.             }
  323.     }
  324.     return 1;
  325. }
  326.  
  327. //------------------------------------------------------------------------------------------------------
  328.  
  329. public OnPlayerSpawn(playerid,classid,teamid)
  330. {
  331.     return 1;
  332. }
  333.  
  334. //------------------------------------------------------------------------------------------------------
  335.  
  336. public OnPlayerDeath(playerid, killerid, reason)
  337. {
  338.    
  339.     return 1;
  340. }
  341.  
  342. //------------------------------------------------------------------------------------------------------
  343.  
  344. public OnPlayerRequestClass(playerid, classid, skinid)
  345. {
  346.  
  347.     return 1;
  348. }
  349.  
  350. //------------------------------------------------------------------------------------------------------
  351.  
  352. public OnPickedUp(pickupid, playerid)
  353. {   if ((pickupid==1) || pickupid==2)
  354.         SendClientMessage(playerid,COLOR_YELLOW,"Hey, you can buy guns here");
  355.     return 1;
  356. }
  357.  
  358. //------------------------------------------------------------------------------------------------------
  359. public OnGameModeInit()
  360. {
  361.     SetGameModeText(szGameModeName);
  362.  
  363.     ShowPlayerMarkers(1);
  364.  
  365.     // Player Classes
  366.     AddPlayerClassEx(0, 149, -500.0569, -465.1577, 11.4867, 0.7182, 17, 500, 24, 500, 21, 500); // 149 green
  367.     AddPlayerClassEx(1, 141, -374.1536, -223.0066, 9.1213, 183.0354, 17, 500, 24, 500, 21, 500); //141 blue
  368.    
  369.     SetPlayerFriendlyFire(false);
  370.     Jumpswitch(1);
  371.  
  372.     // Vehicles
  373.  
  374.         //Police
  375.     AddStaticVehicle(156, -715.1685, -482.2235, 10.8822, 0.9519, 3, 1);
  376.     AddStaticVehicle(156, -714.9229, -497.0534, 10.8654, 0.9236, 3, 1);
  377.     AddStaticVehicle(156, -183.8194, -465.4719, 10.8446, 10.8470, 3, 1);
  378.     AddStaticVehicle(156, -181.0072, -480.6185, 10.8508, 9.8620, 3, 1);
  379.  
  380.         //Enforcers
  381.     AddStaticVehicle(157, -715.0520, -489.2520, 10.8733, 0.9514, 3, 1);
  382.     AddStaticVehicle(157, -182.3127, -473.3688, 10.8385, 10.8059, 3, 1);
  383.  
  384.         //Team green vehicles
  385.     AddStaticVehicle(133, -539.4441, -474.2635, 11.1189, 270.2599, 44, 1);
  386.     AddStaticVehicle(143, -520.8994, -474.1699, 11.1477, 272.4575, 44, 1);
  387.     AddStaticVehicle(149, -497.1541, -473.3339, 11.1770, 272.5067, 44, 1);
  388.     AddStaticVehicle(154, -470.2748, -472.9805, 11.0522, 273.4655, 44, 1);
  389.     AddStaticVehicle(152, -457.6939, -464.3488, 11.0436, 359.1348, 44, 1);
  390.     AddStaticVehicle(198, -475.5645, -434.3491, 11.4980, 180.2597, 44, 1);
  391.     AddStaticVehicle(198, -469.9465, -432.6784, 11.4211, 186.8397, 44, 1);
  392.  
  393.         //Team Blue vehicles
  394.     AddStaticVehicle(133, -467.0890, -244.5312, 10.3687, 268.6380, 2, 1);
  395.     AddStaticVehicle(143, -439.0008, -241.7432, 10.3688, 267.9733, 2, 1);
  396.     AddStaticVehicle(149, -430.7938, -253.1322, 10.5549, 182.3609, 2, 1);
  397.     AddStaticVehicle(154, -415.0505, -245.8516, 10.5152, 91.1488, 2, 1);
  398.     AddStaticVehicle(152, -414.5432, -259.7456, 10.9684, 90.4392, 2, 1);
  399.     AddStaticVehicle(198, -405.4318, -311.1410, 11.0946, 185.1944, 2, 1);
  400.     AddStaticVehicle(198, -411.9401, -312.0182, 11.2288, 185.1944, 2, 1);
  401.  
  402.  
  403. /*
  404.     AddStaticPickup(id, type, Float:x, Float:y, Float:z, ammo, respawnseconds);
  405.  
  406.     -for cash pickups use type 501
  407.     -use -1 for respawnseconds to select default respawn 4 minutes
  408.         *   may ditch the manual id arg and have it auto id instead   *
  409.  
  410. */
  411.     new sp=1;
  412.  
  413.         //Team Green pickups
  414.     AddStaticPickup(sp++, 405, -488.4050, -421.6337, 11.4306);  //gunbox
  415.    
  416.  
  417.         //Team Blue pickups
  418.     AddStaticPickup(sp++, 405, -392.9321,-279.0997,10.6587);  //gunbox
  419.  
  420.  
  421.     SetWorldBounds(5000.0,-5000.0,5000.0,-5000.0);
  422.     SetCameraPos(-231.4, -440.0, 32.1);
  423.     SetCameraLookAt(-232.0314, -442.6181, 33.1);
  424.  
  425.  
  426.     SetPlayerStartPos(-232.0314, -442.6181, 32.7944);
  427.     new q,c=0;
  428.     for (q=0;q < MAX_PLAYERS; q++) {
  429.         if (IsPlayerConnected(q)) {
  430.             new pname[MAX_PLAYER_NAME+1];
  431.             GetPlayerName(q,pname,MAX_PLAYER_NAME);
  432.             gPlayers[q] = pname;
  433.             c++;
  434.         } else { gPlayers[q] = ""; }
  435.     }
  436.     InitWepList();
  437.     printf("\n\n**\tscript init loaded\t**\n**\t%d players\t**\n",c);
  438.     new szMessage[256];
  439.     format(szMessage,256,"Game Mode %s loaded.",szGameModeName);
  440.     SendClientMessageToAll(COLOR_GREY, szMessage);
  441.     return 1;
  442. }
  443.  
  444.  
  445.  
  446. //------------------------------------------------------------------------------------------------------
  447. public Float: GetPlayerDist(plr1,plr2) // Daddy's func
  448. {
  449.     new Float:X,Float:Y,Float:Z,Float:X1,Float:Y1,Float:Z1;
  450.     GetPlayerPos(plr1,X,Y,Z);
  451.     GetPlayerPos(plr2,X1,Y1,Z1);
  452.     new Float:Dist=GetDistance(X,Y,Z,X1,Y1,Z1);
  453.     return Dist;
  454. }
  455.  
  456. public Float: GetDistance(Float:X1,Float:Y1,Float:Z1,Float:X2,Float:Y2,Float:Z2) // Daddy's function
  457. {
  458.     new Float:X = floatsub(X2,X1);
  459.     new Float:Y = floatsub(Y2,Y1);
  460.     new Float:Z = floatsub(Z2,Z1);
  461.     new Float:Dist = floatsqroot(floatadd(floatadd(floatpower(X,2),floatpower(Y,2)),floatpower(Z,2)));
  462.     return Dist;
  463. }
  464. public getAmmunation(playerid,tmp[]) {
  465.     //All shotguns
  466.     if (strcmp(tmp, "shotgun", true) ==0) {
  467.         SendClientMessage(playerid, COLOR_GREEN, "You purchased a Shotgun | ammo : 500");
  468.         SetPlayerWeapon(playerid,19,500);
  469.     }
  470.     else if (strcmp(tmp, "stubby", true) ==0) {
  471.         SendClientMessage(playerid, COLOR_GREEN, "You purchased a Shotgun | ammo : 500");
  472.                     SetPlayerWeapon(playerid,21,500);
  473.     }
  474.     else if (strcmp(tmp, "spaz", true) ==0) {
  475.         SendClientMessage(playerid, COLOR_GREEN, "You purchased a Spaz | ammo : 500");
  476.         SetPlayerWeapon(playerid,20,500);
  477.     }
  478.     //All machine-guns class
  479.     else if (strcmp(tmp, "tec9", true) ==0) {
  480.         SendClientMessage(playerid, COLOR_GREEN, "You purchased a tec9 | ammo : 1000");
  481.         SetPlayerWeapon(playerid,22,1000);
  482.     }
  483.     else if (strcmp(tmp, "uzi", true) ==0) {
  484.         SendClientMessage(playerid, COLOR_GREEN, "You purchased a UZI | ammo : 1000");
  485.         SetPlayerWeapon(playerid,23,1000);
  486.     }
  487.     else if (strcmp(tmp, "ingram", true) ==0) {
  488.         SendClientMessage(playerid, COLOR_GREEN, "You purchased a Ingram | ammo : 1000");
  489.         SetPlayerWeapon(playerid,24,1000);
  490.     }
  491.     else if (strcmp(tmp, "mp5", true) ==0) {
  492.         SendClientMessage(playerid, COLOR_GREEN, "You purchased a Mp5 | ammo : 1000");
  493.         SetPlayerWeapon(playerid,25,1000);
  494.     }
  495.     //All rong-range machine guns class
  496.     else if (strcmp(tmp, "m4", true) ==0) {
  497.         SendClientMessage(playerid, COLOR_GREEN, "You purchased a M4 | ammo : 1000");
  498.         SetPlayerWeapon(playerid,26,1000);
  499.     }
  500.     else if (strcmp(tmp, "Ruger", true) ==0) {
  501.         SendClientMessage(playerid, COLOR_GREEN, "You purchased a Ruger | ammo : 1000");
  502.         SetPlayerWeapon(playerid,27,1000);
  503.     }
  504.     //All snipers class
  505.     else if (strcmp(tmp, "sniper", true) ==0) {
  506.         SendClientMessage(playerid, COLOR_GREEN, "You purchased a sniper | ammo : 500");
  507.         SetPlayerWeapon(playerid,28,500);
  508.     }
  509.     else if (strcmp(tmp, "laser", true) ==0) {
  510.         SendClientMessage(playerid, COLOR_GREEN, "You purchased a laser sniper | ammo : 500");
  511.         SetPlayerWeapon(playerid,29,500);
  512.     }
  513.     else if (strcmp(tmp, "m60", true) ==0) {
  514.         SendClientMessage(playerid, COLOR_GREEN, "You purchased a M60 | ammo : 1000");
  515.         SetPlayerWeapon(playerid,32,1000);
  516.     }
  517.     else
  518.         return SendClientMessage(playerid, COLOR_RED, "We dont sell shit here" );
  519.     return 1;
  520. }
  521.  
  522. public FindPlayerIDFromString(string[])
  523. {// for determining player id from a string  -bakasan
  524.     new szMsg[256];
  525.     new player = INACTIVE_PLAYER_ID;
  526.     new p = 0;
  527.     while (p < MAX_PLAYERS) { if (strfind(gPlayers[p],string,true) != -1) { player=p;break; } p++; }
  528.     if (player == INACTIVE_PLAYER_ID) {// string didnt match so check if it can be an id
  529.         if ((strlen(string) > 2) || (isnumeric(string) == 0)) {
  530.             format(szMsg,sizeof(szMsg),"Unable to find %s.",string);
  531.             SendClientMessageToAll(COLOR_GREY, szMsg);
  532.             return INACTIVE_PLAYER_ID;
  533.         }
  534.         player = strval(string);// string is numeric and not more than 2 digits
  535.     }
  536.     if (!IsPlayerConnected(player)) {
  537.         format(szMsg,sizeof(szMsg),"Invalid ID %d.",player);
  538.         SendClientMessageToAll(COLOR_GREY, szMsg);
  539.         return INACTIVE_PLAYER_ID;
  540.     }
  541.     return player;// valid id found
  542. }
  543.  
  544. //------------------------------------------------------------------------------------------------------
  545. public InitWepList()
  546. {
  547.     if (wep_init == 1) { return 1; }
  548.     gWeapons[0] = "Fist";
  549.     gWeapons[1] = "BrassKnuckle";
  550.     gWeapons[2] = "ScrewDriver";
  551.     gWeapons[3] = "GolfClub";
  552.     gWeapons[4] = "NightStick";
  553.     gWeapons[5] = "Knife";
  554.     gWeapons[6] = "BaseballBat";
  555.     gWeapons[7] = "Hammer";
  556.     gWeapons[8] = "Cleaver";
  557.     gWeapons[9] = "Machete";
  558.     gWeapons[10] = "Katana";
  559.     gWeapons[11] = "Chainsaw";
  560.     gWeapons[12] = "Grenade";
  561.     gWeapons[13] = "RemoteGrenade";
  562.     gWeapons[14] = "TearGas";
  563.     gWeapons[15] = "Molotov";
  564.     gWeapons[16] = "Missile";//called "Rocket" in weapon.dat
  565.     gWeapons[17] = "Colt45";
  566.     gWeapons[18] = "Python";
  567.     gWeapons[19] = "Shotgun";
  568.     gWeapons[20] = "Spaz";//Spas12Shotgun
  569.     gWeapons[21] = "Stubby";//StubbyShotgun
  570.     gWeapons[22] = "Tec9";
  571.     gWeapons[23] = "Uzi";
  572.     gWeapons[24] = "Ingrams";
  573.     gWeapons[25] = "MP5";
  574.     gWeapons[26] = "M4";
  575.     gWeapons[27] = "Ruger";
  576.     gWeapons[28] = "SniperRifle";
  577.     gWeapons[29] = "LaserScope";
  578.     gWeapons[30] = "RocketLauncher";
  579.     gWeapons[31] = "FlameThrower";
  580.     gWeapons[32] = "M60";
  581.     gWeapons[33] = "Minigun";
  582.     gWeapons[34] = "none34";
  583.     gWeapons[35] = "Heli-Cannon";
  584.     gWeapons[36] = "none36";
  585.     gWeapons[37] = "none37";
  586.     gWeapons[38] = "none38";
  587.     gWeapons[39] = "Vehicle";
  588.     gWeapons[40] = "none40";
  589.     gWeapons[41] = "41";
  590.     gWeapons[42] = "none42";
  591.     gWeapons[43] = "Drowned";
  592.     gWeapons[44] = "Impact";
  593.     gWeapons[45] = "none45";
  594.     gWeapons[46] = "none46";
  595.     gWeapons[47] = "none47";
  596.     gWeapons[48] = "none48";
  597.     gWeapons[49] = "none49";
  598.     gWeapons[50] = "none50";
  599.     gWeapons[51] = "none51";
  600.     gWeapons[52] = "none52";
  601.     gWeapons[53] = "none53";
  602.     gWeapons[54] = "none54";
  603.     gWeapons[55] = "none55";
  604.     gWeapons[56] = "none56";
  605.     gWeapons[57] = "none57";
  606.     gWeapons[58] = "none58";
  607.     gWeapons[59] = "none59";
  608.     gWeapons[60] = "Heli-Blades";
  609.     wep_init = 1;
  610.     return 1;
  611. }
  612.  
  613. public FindWepIDFromString(string[])
  614. {// for determining weapon id from a string  -bakasan
  615.     if (wep_init == 0) { InitWepList(); }
  616.     new szMsg[256];
  617.     new match = 0;
  618.     new p = 0;
  619.     while (p < MAX_WEAPONS) { if (strfind(gWeapons[p],string,true) != -1) { match=p;break; } p++; }
  620.     if (match == 0) {// string didnt match so check if it can be an id
  621.         if ((strlen(string) > 2) || (isnumeric(string) == 0)) {
  622.             format(szMsg,sizeof(szMsg),"Unable to find weapon %s.",string);
  623.             SendClientMessageToAll(COLOR_GREY, szMsg);
  624.             return 0;
  625.         }
  626.         match = strval(string);// string is numeric and not more than 2 digits
  627.     }
  628.     if ((match < 1) || (match > 33)) {
  629.         format(szMsg,sizeof(szMsg),"Invalid Weapon ID %d.",match);
  630.         SendClientMessageToAll(COLOR_GREY, szMsg);
  631.         return 0;
  632.     }
  633.     return match;// valid id found
  634. }
  635. strtok(const string[], &index)
  636. {
  637.     new length = strlen(string);
  638.     while ((index < length) && (string[index] <= ' ')){ index++; }
  639.     new offset = index;
  640.     new result[20];
  641.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  642.     {
  643.         result[index - offset] = string[index];
  644.         index++;
  645.     }
  646.     result[index - offset] = EOS;
  647.     return result;
  648. }
  649. isnumeric(const string[])
  650. {// mike's function
  651.     for (new i = 0, j = strlen(string); i < j; i++) { if (string[i] > '9' || string[i] < '0') return 0; }
  652.     return 1;
  653. }
Add Comment
Please, Sign In to add comment