Advertisement
CharC

bLibrary.inc - v1.1

Mar 1st, 2012
528
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 12.14 KB | None | 0 0
  1. ///////////////////////////////////////////////////////////////////////////////////////////////////////////
  2. //bLibrary v0.1a
  3. //Author : Ballu Miaa aka Char.C
  4. //Facebook : MCeeCharC
  5. // Twitter: IndianGz
  6. // Youtube Channel: IndianGz
  7. // SAMP Forums : Ballu Miaa
  8. // Site: www.excaliburgaming.net
  9. // CREDITS:
  10. //Ballu Miaa for developing this include.
  11. //Y_Less for telling me how to make params optional of a stock.
  12. //SA:MP Team for SA:MP
  13. //CHANGELOGS:
  14. // Updated include to v1.1 adding minor indentation and optimization!
  15. // NOTE:
  16. // 1. You are not allowed to remove/edit the credits.
  17. // 2. You are not allowed to make any changes to this include and re-release it.
  18. // 3. You are not allowed to sell this include.
  19. // 4. You are not allowed to call this include of you own.
  20. /*
  21. native SetPlayerCash(playerid, cash);
  22. native RemovePlayerCash(playerid, cash);
  23. native GivePlayerScore(playerid, score);
  24. native RemovePlayerScore(playerid, score);
  25. native GetVehicleIDByName(name[]);
  26. native getWeaponIDByName(name[]);
  27. native GetVehicleNameByModel(model);
  28. native GetWeaponNameByID(id);
  29. native GetPlayerNameEx(playerid);
  30. native TeleportPlayerToPlayer(playerid, targetid);
  31. native SetPlayerPosEx(playerid, Float:x ,Float:y,Float:z,Angle,interior,VirtualWorld);
  32. native KickAll();
  33. native BanAll();
  34. native FreezeAll();
  35. native UnfreezeAll();
  36. native Freeze(playerid);
  37. native Unfreeze(playerid);
  38. native GetPlayerIPEx(playerid);
  39. native TransferScoreFromPlayerToPlayer(playerid, targetid, ammount);
  40. native ExplodePlayer(playerid);
  41. native ExplodeAll();
  42. native Kill(playerid);
  43. native KillAll();
  44. native ShowMessage(playerid, caption[], info[]);
  45. */
  46. #include <a_samp>
  47. #include <a_players>
  48. #define COLOR_RED 0xFF1400FF
  49. #define COLOR_GREEN 0x00FF00FF
  50. #define COLOR_BLUE 0x00AFFFFF
  51. #define COLOR_YELLOW 0xFFFF00FF
  52. #define MSG_DLG 3232
  53. forward WaterChecking();
  54. static max_players;
  55. new bool:AlreadyInWater[MAX_PLAYERS];
  56. new WeaponNames[][32] = {
  57.         {"Unarmed (Fist)"},
  58.         {"Brass Knuckles"},
  59.         {"Golf Club"},
  60.         {"Night Stick"},
  61.         {"Knife"},
  62.         {"Baseball Bat"},
  63.         {"Shovel"},
  64.         {"Pool Cue"},
  65.         {"Katana"},
  66.         {"Chainsaw"},
  67.         {"Purple Dildo"},
  68.         {"Big White Vibrator"},
  69.         {"Medium White Vibrator"},
  70.         {"Small White Vibrator"},
  71.         {"Flowers"},
  72.         {"Cane"},
  73.         {"Grenade"},
  74.         {"Teargas"},
  75.         {"Molotov"},
  76.         {" "},
  77.         {" "},
  78.         {" "},
  79.         {"Colt 45"},
  80.         {"Colt 45 (Silenced)"},
  81.         {"Desert Eagle"},
  82.         {"Normal Shotgun"},
  83.         {"Sawnoff Shotgun"},
  84.         {"Combat Shotgun"},
  85.         {"Micro Uzi (Mac 10)"},
  86.         {"MP5"},
  87.         {"AK47"},
  88.         {"M4"},
  89.         {"Tec9"},
  90.         {"CountryRifle"},
  91.         {"Sniper"},
  92.         {"RocketLauncher"},
  93.         {"Heat-Seeking Rocket Launcher"},
  94.         {"Flamethrower"},
  95.         {"Minigun"},
  96.         {"Satchel Charge"},
  97.         {"Detonator"},
  98.         {"Spray Can"},
  99.         {"Fire Extinguisher"},
  100.         {"Camera"},
  101.         {"Night Vision Goggles"},
  102.         {"Infrared Vision Goggles"},
  103.         {"Parachute"},
  104.         {"Fake Pistol"}
  105. };
  106.  
  107.  
  108. new VehicleNames[212][] = {
  109.         {"Landstalker"},
  110.         {"Bravura"},
  111.         {"Buffalo"},
  112.         {"Linerunner"},
  113.         {"Perrenial"},
  114.         {"Sentinel"},
  115.         {"Dumper"},
  116.         {"Firetruck"},
  117.         {"Trashmaster"},
  118.         {"Stretch"},
  119.         {"Manana"},
  120.         {"Infernus"},
  121.         {"Voodoo"},
  122.         {"Pony"},
  123.         {"Mule"},
  124.         {"Cheetah"},
  125.         {"Ambulance"},
  126.         {"Leviathan"},
  127.         {"Moonbeam"},
  128.         {"Esperanto"},
  129.         {"Taxi"},
  130.         {"Washington"},
  131.         {"Bobcat"},
  132.         {"Mr Whoopee"},
  133.         {"BF Injection"},
  134.         {"Hunter"},
  135.         {"Premier"},
  136.         {"Enforcer"},
  137.         {"Securicar"},
  138.         {"Banshee"},
  139.         {"Predator"},
  140.         {"Bus"},
  141.         {"Rhino"},
  142.         {"Barracks"},
  143.         {"Hotknife"},
  144.         {"Trailer 1"},
  145.         {"Previon"},
  146.         {"Coach"},
  147.         {"Cabbie"},
  148.         {"Stallion"},
  149.         {"Rumpo"},
  150.         {"RC Bandit"},
  151.         {"Romero"},
  152.         {"Packer"},
  153.         {"Monster"},
  154.         {"Admiral"},
  155.         {"Squalo"},
  156.         {"Seasparrow"},
  157.         {"Pizzaboy"},
  158.         {"Tram"},
  159.         {"Trailer 2"},
  160.         {"Turismo"},
  161.         {"Speeder"},
  162.         {"Reefer"},
  163.         {"Tropic"},
  164.         {"Flatbed"},
  165.         {"Yankee"},
  166.         {"Caddy"},
  167.         {"Solair"},
  168.         {"Berkley's RC Van"},
  169.         {"Skimmer"},
  170.         {"PCJ-600"},
  171.         {"Faggio"},
  172.         {"Freeway"},
  173.         {"RC Baron"},
  174.         {"RC Raider"},
  175.         {"Glendale"},
  176.         {"Oceanic"},
  177.         {"Sanchez"},
  178.         {"Sparrow"},
  179.         {"Patriot"},
  180.         {"Quad"},
  181.         {"Coastguard"},
  182.         {"Dinghy"},
  183.         {"Hermes"},
  184.         {"Sabre"},
  185.         {"Rustler"},
  186.         {"ZR-350"},
  187.         {"Walton"},
  188.         {"Regina"},
  189.         {"Comet"},
  190.         {"BMX"},
  191.         {"Burrito"},
  192.         {"Camper"},
  193.         {"Marquis"},
  194.         {"Baggage"},
  195.         {"Dozer"},
  196.         {"Maverick"},
  197.         {"News Chopper"},
  198.         {"Rancher"},
  199.         {"FBI Rancher"},
  200.         {"Virgo"},
  201.         {"Greenwood"},
  202.         {"Jetmax"},
  203.         {"Hotring"},
  204.         {"Sandking"},
  205.         {"Blista Compact"},
  206.         {"Police Maverick"},
  207.         {"Boxville"},
  208.         {"Benson"},
  209.         {"Mesa"},
  210.         {"RC Goblin"},
  211.         {"Hotring Racer A"},
  212.         {"Hotring Racer B"},
  213.         {"Bloodring Banger"},
  214.         {"Rancher"},
  215.         {"Super GT"},
  216.         {"Elegant"},
  217.         {"Journey"},
  218.         {"Bike"},
  219.         {"Mountain Bike"},
  220.         {"Beagle"},
  221.         {"Cropdust"},
  222.         {"Stunt"},
  223.         {"Tanker"},
  224.         {"Roadtrain"},
  225.         {"Nebula"},
  226.         {"Majestic"},
  227.         {"Buccaneer"},
  228.         {"Shamal"},
  229.         {"Hydra"},
  230.         {"FCR-900"},
  231.         {"NRG-500"},
  232.         {"HPV1000"},
  233.         {"Cement Truck"},
  234.         {"Tow Truck"},
  235.         {"Fortune"},
  236.         {"Cadrona"},
  237.         {"FBI Truck"},
  238.         {"Willard"},
  239.         {"Forklift"},
  240.         {"Tractor"},
  241.         {"Combine"},
  242.         {"Feltzer"},
  243.         {"Remington"},
  244.         {"Slamvan"},
  245.         {"Blade"},
  246.         {"Freight"},
  247.         {"Streak"},
  248.         {"Vortex"},
  249.         {"Vincent"},
  250.         {"Bullet"},
  251.         {"Clover"},
  252.         {"Sadler"},
  253.         {"Firetruck LA"},
  254.         {"Hustler"},
  255.         {"Intruder"},
  256.         {"Primo"},
  257.         {"Cargobob"},
  258.         {"Tampa"},
  259.         {"Sunrise"},
  260.         {"Merit"},
  261.         {"Utility"},
  262.         {"Nevada"},
  263.         {"Yosemite"},
  264.         {"Windsor"},
  265.         {"Monster A"},
  266.         {"Monster B"},
  267.         {"Uranus"},
  268.         {"Jester"},
  269.         {"Sultan"},
  270.         {"Stratum"},
  271.         {"Elegy"},
  272.         {"Raindance"},
  273.         {"RC Tiger"},
  274.         {"Flash"},
  275.         {"Tahoma"},
  276.         {"Savanna"},
  277.         {"Bandito"},
  278.         {"Freight Flat"},
  279.         {"Streak Carriage"},
  280.         {"Kart"},
  281.         {"Mower"},
  282.         {"Duneride"},
  283.         {"Sweeper"},
  284.         {"Broadway"},
  285.         {"Tornado"},
  286.         {"AT-400"},
  287.         {"DFT-30"},
  288.         {"Huntley"},
  289.         {"Stafford"},
  290.         {"BF-400"},
  291.         {"Newsvan"},
  292.         {"Tug"},
  293.         {"Trailer 3"},
  294.         {"Emperor"},
  295.         {"Wayfarer"},
  296.         {"Euros"},
  297.         {"Hotdog"},
  298.         {"Club"},
  299.         {"Freight Carriage"},
  300.         {"Trailer 3"},
  301.         {"Andromada"},
  302.         {"Dodo"},
  303.         {"RC Cam"},
  304.         {"Launch"},
  305.         {"Police Car (LSPD)"},
  306.         {"Police Car (SFPD)"},
  307.         {"Police Car (LVPD)"},
  308.         {"Police Ranger"},
  309.         {"Picador"},
  310.         {"S.W.A.T. Van"},
  311.         {"Alpha"},
  312.         {"Phoenix"},
  313.         {"Glendale"},
  314.         {"Sadler"},
  315.         {"Luggage Trailer A"},
  316.         {"Luggage Trailer B"},
  317.         {"Stair Trailer"},
  318.         {"Boxville"},
  319.         {"Farm Plow"},
  320.         {"Utility Trailer"}
  321. };
  322. stock SetPlayerCash(playerid, cash)
  323. {
  324.     ResetPlayerMoney(playerid);
  325.     GivePlayerMoney(playerid, cash);
  326. }
  327. stock RemovePlayerCash(playerid, cash)
  328. {
  329.     GivePlayerMoney(playerid, -cash);
  330. }
  331. stock GivePlayerScore(playerid, score)
  332. {
  333.     SetplayerScore(playerid, GetPlayerScore(playerid) + score);
  334. }
  335. stock RemovePlayerScore(playerid, score)
  336. {
  337.     SetPlayerScore(playerid, GetPlayerScore(playerid) - score);
  338. }
  339. stock GetVehicleIDByName(name[])
  340. {
  341.     for(new i = 0;i<sizeof(VehicleNames);i++)
  342.     {
  343.         if(!strcmp(VehicleNames[i],name,true))
  344.         {
  345.             return i +400;
  346.         }
  347.     }
  348.     return -1;
  349. }
  350.  
  351. stock GetWeaponIDByName(name[])
  352. {
  353.     for(new i = 0;i<sizeof(WeaponNames);i++)
  354.     {
  355.         if(!strcmp(WeaponNames[i],name,true))
  356.         {
  357.             return i;
  358.         }
  359.     }
  360.     return -1;
  361. }
  362. stock GetVehicleNameByModel(model)
  363. {
  364.         new string[32];
  365.         format(string,sizeof string,"%s",VehicleNames[model -400]);
  366.         return string;
  367. }
  368.  
  369. stock GetWeaponNameByID(id)
  370. {
  371.         new string[32];
  372.         format(string,sizeof string,"%s",WeaponNames[id]);
  373.         return string;
  374. }
  375. stock GetPlayerNameEx(playerid)
  376. {
  377.     new pName[MAX_PLAYER_NAME];
  378.     GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
  379.     return pName;
  380. }
  381. stock SetPlayerPosEx(playerid, Float:x ,Float:y,Float:z,Float:a,interior = 0,vw = 0)
  382. {
  383.     SetPlayerPos(playerid , x , y ,z);
  384.     SetPlayerFacingAngle(playerid, a);
  385.     SetPlayerInterior(playerid, interior);
  386.     SetPlayerVirtualWorld(playerid, vw);
  387.     return 1;
  388. }
  389. stock KickAll()
  390. {
  391.     for(new i = 0; i < MAX_PLAYERS; i++)
  392.     {
  393.         if(!IsPlayerConnected(i)) continue;
  394.         if(admins == 0 && !IsPlayerAdmin(i)) continue;
  395.         Kick(i);
  396.     }
  397. }
  398.  
  399. stock BanAll()
  400. {
  401.     for(new i = 0; i < MAX_PLAYERS; i++)
  402.     {
  403.         if(!IsPlayerConnected(i)) continue;
  404.         if(admins == 0 && !IsPlayerAdmin(i)) continue;
  405.         Ban(i);
  406.     }
  407. }
  408.  
  409. stock FreezeAll()
  410. {
  411.     for(new i = 0; i < MAX_PLAYERS; i++)
  412.     {
  413.         if(!IsPlayerConnected(i)) continue;
  414.         if(admins == 0 && !IsPlayerAdmin(i)) continue;
  415.         TogglePlayerControllable(i, 0);
  416.     }
  417. }
  418.  
  419. stock UnfreezeAll()
  420. {
  421.     for(new i = 0; i < MAX_PLAYERS; i++)
  422.     {
  423.         if(!IsPlayerConnected(i)) continue;
  424.         if(admins == 0 && !IsPlayerAdmin(i)) continue;
  425.         TogglePlayerControllable(i, 1);
  426.     }
  427. }
  428.  
  429. stock Freeze(playerid)
  430. {
  431.     TogglePlayerControllable(playerid, 0);
  432. }
  433.  
  434. stock Unfreeze(playerid)
  435. {
  436.     TogglePlayerControllable(playerid, 1);
  437. }
  438. stock GetPlayerIPEx(playerid)
  439. {
  440.     new pIP[32];
  441.     GetPlayerIp(playerid,ip,sizeof ip);
  442.     return pIP;
  443. }
  444. stock Explode(playerid)
  445. {
  446.     new Float:X, Float:Y, Float:Z;
  447.     GetPlayerPos(playerid, X, Y, Z);
  448.     CreateExplosion(X, Y, Z, 7, 100.0);
  449. }
  450. stock ExplodeAll()
  451. {
  452.     new Float:X, Float:Y, Float:Z;
  453.     for(new i = 0; i < MAX_PLAYERS; i++)
  454.     {
  455.         GetPlayerPos(i, X, Y, Z);
  456.         CreateExplosion(X, Y, Z, 7, 100.0);
  457.     }
  458. }
  459. stock Kill(playerid)
  460. {
  461.     SetPlayerHealth(playerid, 0);
  462. }
  463. stock KillAll()
  464. {
  465.     for(new i = 0; i < MAX_PLAYERS; i++)
  466.     {
  467.         SetPlayerHealth(i, 0);
  468.     }
  469. }
  470. stock ShowMessage(playerid, caption[], info[])
  471. {
  472.     ShowPlayerDialog(playerid, MSG_DLG, DIALOG_STYLE_MSGBOX, caption, info, "OK", "OK");
  473. }
  474.  
  475. public OnGameModeInit()
  476. {
  477.     max_players = GetMaxPlayers();
  478.     SetTimer("WaterChecking", 1000, true);
  479.     return CallLocalFunction("H_OnGameModeInit","");
  480. }
  481.  
  482.  
  483. public WaterChecking()
  484. {
  485.     for(new i = 0; i < max_players; i++)
  486.     {
  487.         if(IsPlayerConnected(i) && !IsPlayerNPC(i))
  488.         {
  489.              if(PlayerInWater(i))
  490.              {
  491.                  if(!AlreadyInWater[i])
  492.                  {
  493.                      CallLocalFunction("OnPlayerEnterWater", "d", "playerid");
  494.                      AlreadyInWater[i] = true;
  495.                  }
  496.              }
  497.              else
  498.              {
  499.                  AlreadyInWater[i] = false;
  500.              }
  501.         }
  502.     }
  503.     return 1;
  504. }
  505.  
  506. PlayerInWater(playerid)
  507. {
  508.     new animlib[32],tmp[32];
  509.     GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,tmp,32);
  510.     if(!strcmp(animlib, "SWIM") && !IsPlayerInAnyVehicle(playerid)) return true;
  511.     return false;
  512. }
  513.  
  514. #if defined _ALS_OnGameModeInit
  515.     #undef OnGameModeInit
  516. #else
  517.     #define _ALS_OnGameModeInit
  518. #endif
  519. #define OnGameModeInit H_OnGameModeInit
  520. forward H_OnGameModeInit();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement