makino

Untitled

Dec 24th, 2012
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 8.29 KB | None | 0 0
  1. #define FILTERSCRIPT
  2. #include <a_samp>
  3.  
  4. // Configs:
  5. #define MAX_OBJ 50 // Limit
  6. #define SAVING // Uncomment this line if you want to save dropped guns to restore them after FS restarts
  7. // -----------------------------------------------------------------------------
  8.  
  9.  
  10. new Float:loot[][] =
  11. {
  12. {1301.0890,253.5772,19.5547}
  13. };
  14. enum dGunEnum
  15. {
  16.     Float:ObjPos[3],
  17.     ObjID,
  18.     ObjData[2]
  19. };
  20. new dGunData[MAX_OBJ][dGunEnum];
  21. // -----------------------------------------------------------------------------
  22. new GunNames[48][] = {
  23.     "Nothink", "Brass Knuckles", "Golf Club", "Nitestick", "Knife", "Baseball Bat",
  24.     "Showel", "Pool Cue", "Katana", "Chainsaw", "Purple Dildo", "Small White Dildo",
  25.     "Long White Dildo", "Vibrator", "Flowers", "Cane", "Grenade", "Tear Gas", "Molotov",
  26.     "Vehicle Missile", "Hydra Flare", "Jetpack", "Glock", "Silenced Colt", "Desert Eagle",
  27.     "Shotgun", "Sawn Off", "Combat Shotgun", "Micro UZI", "MP5", "AK47", "M4", "Tec9",
  28.     "Rifle", "Sniper Rifle", "Rocket Launcher", "HS Rocket Launcher", "Flamethrower", "Minigun",
  29.     "Satchel Charge", "Detonator", "Spraycan", "Fire Extinguisher", "Camera", "Nightvision",
  30.     "Infrared Vision", "Parachute", "Fake Pistol"
  31. };
  32. // -----------------------------------------------------------------------------
  33. new GunObjects[47] = {
  34.     0,331,333,334,335,336,337,338,339,341,321,322,323,324,325,326,342,343,344,
  35.     0,0,0,346,347,348,349,350,351,352,353,355,356,372,357,358,359,360,361,362,
  36.     363,364,365,366,367,368,368,371
  37. };
  38. // -----------------------------------------------------------------------------
  39. public OnFilterScriptInit()
  40. {
  41.     for(new n = 0; n < MAX_OBJ; n++) dGunData[n][ObjID] = -1;
  42.     print("\n");
  43.     print(" Drop Gun [FS] By gimini (c)");
  44.     print(" Do not remove copyright!!!");
  45.     print(" Version 1.3\n");
  46.     #if defined SAVING
  47.     new File:file = fopen("DroppedGuns.ini", io_read);
  48.     if(file)
  49.     {
  50.         new buffer[256], FileCoords[5][20];
  51.         for(new g = 0; g < MAX_OBJ; g++)
  52.         {
  53.             fread(file, buffer);
  54.             split(buffer, FileCoords, ',');
  55.             dGunData[g][ObjPos][0] = floatstr(FileCoords[0]);
  56.             dGunData[g][ObjPos][1] = floatstr(FileCoords[1]);
  57.             dGunData[g][ObjPos][2] = floatstr(FileCoords[2]);
  58.             dGunData[g][ObjData][0] = strval(FileCoords[3]);
  59.             dGunData[g][ObjData][1] = strval(FileCoords[4]);
  60.             if(dGunData[g][ObjData][0] > 0 && dGunData[g][ObjData][1] != 0 && dGunData[g][ObjPos][0] != 0)
  61.             {
  62.                 dGunData[g][ObjID] = CreateObject(GunObjects[dGunData[g][ObjData][0]], dGunData[g][ObjPos][0], dGunData[g][ObjPos][1], dGunData[g][ObjPos][2]-1, 93.7, 120.0, 120.0);
  63.                 printf("* %s loaded: %f,%f,%f", GunNames[dGunData[g][ObjData][0]], dGunData[g][ObjPos][0], dGunData[g][ObjPos][1], dGunData[g][ObjPos][2]-1);
  64.             }
  65.         }
  66.     }
  67.     else print("ERROR: Failed to open \"DroppedGuns.ini\"");
  68.     #endif
  69.     return 1;
  70. }
  71. // -----------------------------------------------------------------------------
  72. public OnFilterScriptExit()
  73. {
  74.     #if defined SAVING // Çàêëàäêà
  75.     new File:file = fopen("DroppedGuns.ini", io_append);
  76.     if(file)
  77.     {
  78.         fclose(file);
  79.         for(new g = 0, buffer[50]; g < MAX_OBJ; g++)
  80.         {
  81.             format(buffer, sizeof(buffer), "%f,%f,%f,%d,%d\n",
  82.             dGunData[g][ObjPos][0],
  83.             dGunData[g][ObjPos][1],
  84.             dGunData[g][ObjPos][2],
  85.             dGunData[g][ObjData][0],
  86.             dGunData[g][ObjData][1]);
  87.             if(g == 0) file = fopen("DroppedGuns.ini", io_write);
  88.             else file = fopen("DroppedGuns.ini", io_append);
  89.             fwrite(file, buffer);
  90.             fclose(file);
  91.             if(dGunData[g][ObjData][0] > 0 && dGunData[g][ObjPos][1] != 0)
  92.             {
  93.                 DestroyObject(dGunData[g][ObjID]);
  94.                 printf("* %s saved: %f,%f,%f", GunNames[dGunData[g][ObjData][0]], dGunData[g][ObjPos][0], dGunData[g][ObjPos][1], dGunData[g][ObjPos][2]-1);
  95.             }
  96.         }
  97.     }
  98.     else print("ERROR: Failed to open \"DroppedGuns.ini\"");
  99.     #endif
  100.     return 1;
  101. }
  102. // -----------------------------------------------------------------------------
  103. public OnPlayerCommandText(playerid, cmdtext[])
  104. {
  105.     if(strcmp(cmdtext, "/dropgun", true) == 0
  106.     || strcmp(cmdtext, "/dgun", true) == 0)
  107.     {
  108.         if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return 1;
  109.         new GunID = GetPlayerWeapon(playerid);
  110.         new GunAmmo = GetPlayerAmmo(playerid);
  111.         if(GunID > 0 && GunAmmo != 0)
  112.         {
  113.             new f = MAX_OBJ+1;
  114.             for(new a = 0; a < MAX_OBJ; a++)
  115.             {
  116.                 if(dGunData[a][ObjPos][0] == 0.0)
  117.                 {
  118.                     f = a;
  119.                     break;
  120.                 }
  121.             }
  122.             if(f > MAX_OBJ) return SendClientMessage(playerid, 0x33AA3300, "You can not throw weapons at the moment, try back later!");
  123.             RemovePlayerWeapon(playerid, GunID);
  124.             dGunData[f][ObjData][0] = GunID;
  125.             dGunData[f][ObjData][1] = GunAmmo;
  126.             GetPlayerPos(playerid, dGunData[f][ObjPos][0], dGunData[f][ObjPos][1], dGunData[f][ObjPos][2]);
  127.             dGunData[f][ObjID] = CreateObject(GunObjects[GunID], dGunData[f][ObjPos][0], dGunData[f][ObjPos][1], dGunData[f][ObjPos][2]-1, 93.7, 120.0, 120.0);
  128.             new buffer[50];
  129.             format(buffer, sizeof(buffer), "You threw %s", GunNames[dGunData[f][ObjData][0]]);
  130.             SendClientMessage(playerid, 0x33AA3300, buffer);
  131.         }
  132.         return 1;
  133.     }
  134.     if(strcmp(cmdtext, "/pickupgun", true) == 0
  135.     || strcmp(cmdtext, "/pgun", true) == 0)
  136.     {
  137.         if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return 1;
  138.         new f = MAX_OBJ+1;
  139.         for(new a = 0; a < MAX_OBJ; a++)
  140.         {
  141.             if(IsPlayerInRangeOfPoint(playerid, 5.0, dGunData[a][ObjPos][0], dGunData[a][ObjPos][1], dGunData[a][ObjPos][2]))
  142.             {
  143.                 f = a;
  144.                 break;
  145.             }
  146.         }
  147.         if(f > MAX_OBJ) return SendClientMessage(playerid, 0x33AA3300, "You are not near the weapon which you can pick up!");
  148.         DestroyObject(dGunData[f][ObjID]);
  149.         GivePlayerWeapon(playerid, dGunData[f][ObjData][0], dGunData[f][ObjData][1]);
  150.         dGunData[f][ObjPos][0] = 0.0;
  151.         dGunData[f][ObjPos][1] = 0.0;
  152.         dGunData[f][ObjPos][2] = 0.0;
  153.         dGunData[f][ObjID] = -1;
  154.         //dGunData[f][ObjData][0] = 0;
  155.         dGunData[f][ObjData][1] = 0;
  156.         new buffer[50];
  157.         format(buffer, sizeof(buffer), "You picked up %s", GunNames[dGunData[f][ObjData][0]]);
  158.         SendClientMessage(playerid, 0x33AA3300, buffer);
  159.         return 1;
  160.     }
  161.     return 0;
  162. }
  163. // -----------------------------------------------------------------------------
  164. public OnPlayerDeath(playerid, killerid, reason)
  165. {
  166.     new Float:pPosX, Float:pPosY, Float:pPosZ;
  167.     GetPlayerPos(playerid, pPosX, pPosY, pPosZ);
  168.     for(new i_slot = 0, gun, ammo; i_slot != 12; i_slot++)
  169.     {
  170.         GetPlayerWeaponData(playerid, i_slot, gun, ammo);
  171.         if(gun != 0 && ammo != 0) CreateDroppedGun(gun, ammo, pPosX+random(2)-random(2), pPosY+random(2)-random(2), pPosZ);
  172.     }
  173.     return 1;
  174. }
  175. stock CreateDroppedGun(GunID, GunAmmo, Float:gPosX, Float:gPosY, Float:gPosZ)
  176. {
  177.     new f = MAX_OBJ+1;
  178.     for(new a = 0; a < MAX_OBJ; a++)
  179.     {
  180.         if(dGunData[a][ObjPos][0] == 0.0)
  181.         {
  182.             f = a;
  183.             break;
  184.         }
  185.     }
  186.     if(f > MAX_OBJ) return;
  187.     dGunData[f][ObjData][0] = GunID;
  188.     dGunData[f][ObjData][1] = GunAmmo;
  189.     dGunData[f][ObjPos][0] = gPosX;
  190.     dGunData[f][ObjPos][1] = gPosY;
  191.     dGunData[f][ObjPos][2] = gPosZ;
  192.     dGunData[f][ObjID] = CreateObject(GunObjects[GunID], dGunData[f][ObjPos][0], dGunData[f][ObjPos][1], dGunData[f][ObjPos][2]-1, 93.7, 120.0, random(360));
  193.     return;
  194. }
  195. // -----------------------------------------------------------------------------
  196. stock RemovePlayerWeapon(playerid, weaponid)
  197. { // Not mine :3
  198.     new plyWeapons[12] = 0;
  199.     new plyAmmo[12] = 0;
  200.     for(new sslot = 0; sslot != 12; sslot++)
  201.     {
  202.         new wep, ammo;
  203.         GetPlayerWeaponData(playerid, sslot, wep, ammo);
  204.         if(wep != weaponid && ammo != 0) GetPlayerWeaponData(playerid, sslot, plyWeapons[sslot], plyAmmo[sslot]);
  205.     }
  206.     ResetPlayerWeapons(playerid);
  207.     for(new sslot = 0; sslot != 12; sslot++) if(plyAmmo[sslot] != 0) GivePlayerWeapon(playerid, plyWeapons[sslot], plyAmmo[sslot]);
  208.     return 1;
  209. }
  210. stock split(const strsrc[], strdest[][], delimiter)
  211. { // Not mine :3
  212.     new i, li;
  213.     new aNum;
  214.     new len;
  215.     while(i <= strlen(strsrc))
  216.     {
  217.         if(strsrc[i]==delimiter || i==strlen(strsrc))
  218.         {
  219.             len = strmid(strdest[aNum], strsrc, li, i, 128);
  220.             strdest[aNum][len] = 0;
  221.             li = i+1;
  222.             aNum++;
  223.         }
  224.         i++;
  225.     }
  226.     return 1;
  227. }
Advertisement
Add Comment
Please, Sign In to add comment