Guest User

DropGunSystem

a guest
Dec 23rd, 2010
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.91 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define MAX_OBJ 50 // Limit
  4. // -----------------------------------------------------------------------------
  5. new Float:ObjCoords[MAX_OBJ][3];
  6. new object[MAX_OBJ];
  7. new ObjectID[MAX_OBJ][2];
  8. // -----------------------------------------------------------------------------
  9. new GunNames[48][] = {
  10.     "Nothink",
  11.     "Brass Knuckles",
  12.     "Golf Club",
  13.     "Nitestick",
  14.     "Knife",
  15.     "Baseball Bat",
  16.     "Showel",
  17.     "Pool Cue",
  18.     "Katana",
  19.     "Chainsaw",
  20.     "Purple Dildo",
  21.     "Small White Dildo",
  22.     "Long White Dildo",
  23.     "Vibrator",
  24.     "Flowers",
  25.     "Cane",
  26.     "Grenade",
  27.     "Tear Gas",
  28.     "Molotov",
  29.     "Vehicle Missile",
  30.     "Hydra Flare",
  31.     "Jetpack",
  32.     "Glock",
  33.     "Silenced Colt",
  34.     "Desert Eagle",
  35.     "Shotgun",
  36.     "Sawn Off",
  37.     "Combat Shotgun",
  38.     "Micro UZI",
  39.     "MP5",
  40.     "AK47",
  41.     "M4",
  42.     "Tec9",
  43.     "Rifle",
  44.     "Sniper Rifle",
  45.     "Rocket Launcher",
  46.     "HS Rocket Launcher",
  47.     "Flamethrower",
  48.     "Minigun",
  49.     "Satchel Charge",
  50.     "Detonator",
  51.     "Spraycan",
  52.     "Fire Extinguisher",
  53.     "Camera",
  54.     "Nightvision",
  55.     "Infrared Vision",
  56.     "Parachute",
  57.     "Fake Pistol"
  58. };
  59. // -----------------------------------------------------------------------------
  60. new GunObjects[47][0] = { // (c) gimini
  61.     {0},// Emty
  62.     {331},// Brass Knuckles
  63.     {333},// Golf Club
  64.     {334},// Nitestick
  65.     {335},// Knife
  66.     {336},// Baseball Bat
  67.     {337},// Showel
  68.     {338},// Pool Cue
  69.     {339},// Katana
  70.     {341},// Chainsaw
  71.     {321},// Purple Dildo
  72.     {322},// Small White Dildo
  73.     {323},// Long White Dildo
  74.     {324},// Vibrator
  75.     {325},// Flowers
  76.     {326},// Cane
  77.     {342},// Grenade
  78.     {343},// Tear Gas
  79.     {344},// Molotov
  80.     {0},
  81.     {0},
  82.     {0},
  83.     {346},// Glock
  84.     {347},// Silenced Colt
  85.     {348},// Desert Eagle
  86.     {349},// Shotgun
  87.     {350},// Sawn Off
  88.     {351},// Combat Shotgun
  89.     {352},// Micro UZI
  90.     {353},// MP5
  91.     {355},// AK47
  92.     {356},// M4
  93.     {372},// Tec9
  94.     {357},// Rifle
  95.     {358},// Sniper Rifle
  96.     {359},// Rocket Launcher
  97.     {360},// HS Rocket Launcher
  98.     {361},// Flamethrower
  99.     {362},// Minigun
  100.     {363},// Detonator
  101.     {364},// Detonator Button
  102.     {365},// Spraycan
  103.     {366},// Fire Extinguisher
  104.     {367},// Camera
  105.     {368},// Nightvision
  106.     {368},// Infrared Vision
  107.     {371}// Parachute
  108. };
  109. // -----------------------------------------------------------------------------
  110. public OnFilterScriptInit()
  111. {
  112.     print("\n--------------------------------------");
  113.     print("      Drop Gun [FS] By gimini (c)");
  114.     print("      Ne micite copyright!!!");
  115.     print("      Version 1.2");
  116.     print("--------------Edit:By Nxidza------------------------\n");
  117.     return 1;
  118. }
  119. // -----------------------------------------------------------------------------
  120. public OnFilterScriptExit()
  121. {
  122.     print("\n--------------------------------------");
  123.     print("  Drop Gun FS 1.2 successfully unloaded!");
  124.     print("\n--------------------------------------");
  125.     return 1;
  126. }
  127. // -----------------------------------------------------------------------------
  128. public OnPlayerCommandText(playerid, cmdtext[])
  129. {
  130.     new cmd[256];
  131.     new idx;
  132.     cmd = strtok(cmdtext, idx);
  133.     if(strcmp(cmd, "/bacigun", true) == 0 || strcmp(cmd, "/bgun", true) == 0)
  134.     {
  135.         new gunID = GetPlayerWeapon(playerid);
  136.         new gunAmmo = GetPlayerAmmo(playerid);
  137.         if(gunID != 0 && gunAmmo != 0)
  138.         {
  139.             new f = MAX_OBJ+1;
  140.             for(new a = 0; a < sizeof(ObjCoords); a++)
  141.             {
  142.                 if(ObjCoords[a][0] == 0.0)
  143.                 {
  144.                     f = a;
  145.                     break;
  146.                 }
  147.             }
  148.             if(f > MAX_OBJ) return SendClientMessage(playerid, 0x33AA3300, "Ne mozete baciti oruzje u ovom trenutku,pokusjte kasnije!!");
  149.             new gunname[25];
  150.             new buffer[100];
  151.             GetWeaponNameEx(gunID, gunname, sizeof(gunname));
  152.             format(buffer, sizeof(buffer), "Ti si bacio %s", gunname);
  153.             SendClientMessage(playerid, 0x33AA3300, buffer);
  154.             RemovePlayerWeapon(playerid, gunID);
  155.             ObjectID[f][0] = gunID;
  156.             ObjectID[f][1] = gunAmmo;
  157.             GetPlayerPos(playerid, ObjCoords[f][0], ObjCoords[f][1], ObjCoords[f][2]);
  158.             object[f] = CreateObject(GunObjects[gunID][0],ObjCoords[f][0],ObjCoords[f][1],ObjCoords[f][2]-1,93.7,120.0,120.0);
  159.             return 1;
  160.         }
  161.     }
  162.     if(strcmp(cmd, "/uzmigun", true) == 0 || strcmp(cmd, "/ugun", true) == 0)
  163.     {
  164.         new f = MAX_OBJ+1;
  165.         for(new a = 0; a < sizeof(ObjCoords); a++)
  166.         {
  167.             if(IsPlayerInRangeOfPoint(playerid, 5.0, ObjCoords[a][0], ObjCoords[a][1], ObjCoords[a][2]))
  168.             {
  169.                 f = a;
  170.                 break;
  171.             }
  172.         }
  173.         if(f > MAX_OBJ) return SendClientMessage(playerid, 0x33AA3300, "Vi niste blizu oruzja kog mozete pokupiti!");
  174.         else
  175.         {
  176.             new gunname[25];
  177.             new buffer[100];
  178.  
  179.             ObjCoords[f][0] = 0.0;
  180.             ObjCoords[f][1] = 0.0;
  181.             ObjCoords[f][2] = 0.0;
  182.  
  183.             DestroyObject(object[f]);
  184.             GivePlayerWeapon(playerid, ObjectID[f][0], ObjectID[f][1]);
  185.             GetWeaponNameEx(ObjectID[f][0], gunname, sizeof(gunname));
  186.             format(buffer, sizeof(buffer), "Vi ste uzeli %s", gunname);
  187.             SendClientMessage(playerid, 0x33AA3300, buffer);
  188.         }
  189.         return 1;
  190.     }
  191.     return 0;
  192. }
  193.  
  194.  
  195.  
  196.  
  197.  
  198. // -----------------------------------------------------------------------------
  199. stock GetWeaponNameEx(id, name[], len) return format(name,len, "%s", GunNames[id]);
  200.  
  201. stock RemovePlayerWeapon(playerid, weaponid);
  202. public RemovePlayerWeapon(playerid, weaponid)
  203. { // Not mine :3
  204.     new plyWeapons[12] = 0;
  205.     new plyAmmo[12] = 0;
  206.     for(new sslot = 0; sslot != 12; sslot++)
  207.     {
  208.         new wep, ammo;
  209.         GetPlayerWeaponData(playerid, sslot, wep, ammo);
  210.         if(wep != weaponid && ammo != 0) GetPlayerWeaponData(playerid, sslot, plyWeapons[sslot], plyAmmo[sslot]);
  211.     }
  212.     ResetPlayerWeapons(playerid);
  213.     for(new sslot = 0; sslot != 12; sslot++)
  214.     {
  215.         if(plyAmmo[sslot] != 0) GivePlayerWeapon(playerid, plyWeapons[sslot], plyAmmo[sslot]);
  216.     }
  217.     return 1;
  218. }
  219.  
  220. strtok(const string[], &index)
  221. {
  222.     new length = strlen(string);
  223.     while ((index < length) && (string[index] <= ' '))
  224.     {
  225.         index++;
  226.     }
  227.     new offset = index;
  228.     new result[20];
  229.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  230.     {
  231.         result[index - offset] = string[index];
  232.         index++;
  233.     }
  234.     result[index - offset] = EOS;
  235.     return result;
  236. }
Advertisement
Add Comment
Please, Sign In to add comment