gamer931215

gLibrary 2.1

Mar 23rd, 2011
1,066
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 24.88 KB | None | 0 0
  1. /*
  2.                                                         gLibrary 2.1    ©2011 Gamer931215
  3.                                                         Released 27-03-2011
  4.    
  5.     Credits:
  6.    
  7.     Changelog:
  8.         V1.0 - First release
  9.         V1.2 - gCOLOR_ORANGE added, and fixed all warnings
  10.         V2.0 - New functions:
  11.                 TransportVehicleToPlayerByAir(playerid,vehicleid)           Transports the vehicle to the player by air! (Andromada)
  12.                 GetVehicleType(vehicleid)                                   Returns 0 when its a car, 1 when its a boat and 2 when its a plane
  13.                 GetVehicleSpeed(playerid,UseMPH = 0)                        Returns playerspeed (i took it from hiddos's stalkercows, i just tought this was a must-have)
  14.                 GetClosestVehicleForPlayer(playerid)                        Returns closest vehicleid
  15.                 GetClosestVehicleFromPoint(x,y,tx,ty)                       Returns closest vehicleid
  16.                 PutPlayerInObject(playerid,objectid)                        Allows player to DRIVE/FLY a object! (Credits to hiddos for his turtle script)
  17.                 RemovePlayerFromObject(playerid)                            Removes player from object
  18.                 IsPlayerInObject(playerid)                                  Returns 1 when player is flying an object
  19.                 GetPlayerObjectID(playerid)                                 Returns objectid
  20.                 GetVehicleNameByModelId(modelid)                            Returns vehicle name
  21.                 GetWeaponNameById(weaponid)                                 Returns weaponname
  22.                 ToggleVehicleLights(vehicleid,toggle)                       Toggle light on/off
  23.                 AreVehicleLightsOn(vehicleid)                               Returns 1 when the lights are on
  24.                 ToggleVehicleAlarm(vehicleid,toggle)                        Toggle alarm on/off
  25.                 IsVehicleAlarmOn(vehicleid)                                 Returns 1 when the alarm is going off
  26.                 SetVehicleToAlarm(vehicleid,time)                           Start the vehicle's alarm and turn it off after the ammount of milisecconds you entered
  27.                 GetDistanceBetweenPoints(Float:x,Float:y,Float:tx,Float:ty) Returns distance between pts
  28.                
  29.         V2.1 - New functions:
  30.                 CenterString(string[],size)                                 Centers the string !
  31.                 AngleToPoint(x1,y1,x2,y2)                                   Gets angle to point
  32.                
  33.     Defines (to show the functions with arguments in pawno):
  34.         native AngleToPoint(x1,y1,x2,y2)
  35.         native PutPlayerInObject(playerid,objectid)
  36.         native RemovePlayerFromObject(playerid)
  37.         native IsPlayerInObject(playerid)
  38.         native GetPlayerObjectID(playerid)
  39.         native GetWeaponIdByName(weaponname[])
  40.         native GetVehicleModelIdByName(model[])
  41.         native GetVehicleNameByModelId(modelid)
  42.         native GetWeaponNameById(weaponid)
  43.         native TransportVehicleToPlayerByAir(playerid,vehicleid)
  44.         native GetVehicleSpeed(vehicleid,UseMPH = 0)
  45.         native GetVehicleType(vehicleid)
  46.         native GetDistanceBetweenPoints(Float:x,Float:y,Float:tx,Float:ty)
  47.         native GetClosestVehicleForPlayer(playerid)
  48.         native GetClosestVehicleFromPoint(x,y,tx,ty)
  49.         native SetVehicleNumberPlateEx(vehicleid,numberplate[])
  50.         native ToggleVehicleLights(vehicleid,toggle)
  51.         native AreVehicleLightsOn(vehicleid)
  52.         native ToggleVehicleAlarm(vehicleid,toggle)
  53.         native IsVehicleAlarmOn(vehicleid)
  54.         native SetVehicleToAlarm(vehicleid,time)
  55.         native MutePlayer(playerid)
  56.         native UnMutePlayer(playerid)
  57.         native JailPlayer(playerid)
  58.         native UnJailPlayer(playerid
  59.         native SetPlayerToReconnect(playerid)
  60.         native SetPlayerMoney(playerid,ammount)
  61.         native GivePlayerScore(playerid,ammount)
  62.         native GetPlayerNameEx(playerid)
  63.         native GetPlayerIpEx(playerid)
  64.         native SetPlayerPosEx(playerid,Float:x,Float:y,Float:z)
  65.         native KickEx(playerid,reason[])
  66.         native SendRconCommandEx(type[],{float,_}:...)
  67.         native SendClientMessageEx(playerid,color,type[],{float,_}:...)
  68.         native SendClientMessageToAllEx(color,type[],{float,_}:...)
  69.         native GameTextForPlayerEx(playerid,time,style,type[],{Float,_}:...)
  70.         native GameTextForAllEx(time,style,type[],{Float,_}:...)
  71.         native CenterString(string[],size)
  72. */
  73.  
  74. #include <a_samp>
  75. #define gCOLOR_RED 0xFF1400FF
  76. #define gCOLOR_GREEN 0x00FF00FF
  77. #define gCOLOR_BLUE 0x00AFFFFF
  78. #define gCOLOR_YELLOW 0xFFFF00FF
  79. #define gCOLOR_ORANGE 0xFFAA00FF
  80. #define gCOLOR_GRAY 0x8C8C8CFF
  81. #define gCOLOR_BLACK 0x000000FF
  82. #define gCOLOR_MAGENTA 0xFF00EBFF
  83. #define gCOLOR_DARKRED 0xC30000FF
  84. #define gCOLOR_DARKGREEN 0x0A6F0AFF
  85. #define gCOLOR_DARKBLUE 0x0000C5FF
  86.  
  87.  
  88. public OnPlayerDisconnect(playerid,reason)
  89. {
  90.     if(GetPVarInt(playerid,"reconnecting") == 1)
  91.     {
  92.         SendRconCommandEx("ss","unbanip ",GetPlayerIpEx(playerid));
  93.         DeletePVar(playerid,"reconnecting");
  94.         DeletePVar(playerid,"muted");
  95.     }
  96.     if(IsPlayerInObject(playerid))
  97.     {
  98.         RemovePlayerFromObject(playerid);
  99.     }
  100.     SetPVarInt(playerid,"muted",0);
  101.     return CallLocalFunction("gOnPlayerDisconnect","ii",playerid,reason);
  102. }
  103. #if defined _ALS_OnPlayerDisconnect
  104.     #undef OnPlayerDisconnect
  105. #else
  106.     #define _ALS_OnPlayerDisconnect
  107. #endif
  108. #define OnPlayerDisconnect gOnPlayerDisconnect
  109. forward gOnPlayerDisconnect(playerid,reason);
  110.  
  111. public OnPlayerText(playerid, text[])
  112. {
  113.     if(GetPVarInt(playerid,"muted") == 1)
  114.     {
  115.         SendClientMessage(playerid,0xFF0A00FF,"You cannot speak when muted.");
  116.         return 0;
  117.     }
  118.     return CallLocalFunction("gOnPlayerText","is",playerid,text);
  119. }
  120. #if defined _ALS_OnPlayerText
  121.     #undef OnPlayerText
  122. #else
  123.     #define _ALS_OnPlayerText
  124. #endif
  125. #define OnPlayerText gOnPlayerText
  126. forward gOnPlayerText(playerid,text[]);
  127.  
  128. new gWeaponNames[][32] = { //from fsdebug
  129.     {"Unarmed (Fist)"},
  130.     {"Brass Knuckles"},
  131.     {"Golf Club"},
  132.     {"Night Stick"},
  133.     {"Knife"},
  134.     {"Baseball Bat"},
  135.     {"Shovel"},
  136.     {"Pool Cue"},
  137.     {"Katana"},
  138.     {"Chainsaw"},
  139.     {"Purple Dildo"},
  140.     {"Big White Vibrator"},
  141.     {"Medium White Vibrator"},
  142.     {"Small White Vibrator"},
  143.     {"Flowers"},
  144.     {"Cane"},
  145.     {"Grenade"},
  146.     {"Teargas"},
  147.     {"Molotov"},
  148.     {" "},
  149.     {" "},
  150.     {" "},
  151.     {"Colt 45"},
  152.     {"Colt 45 (Silenced)"},
  153.     {"Desert Eagle"},
  154.     {"Normal Shotgun"},
  155.     {"Sawnoff Shotgun"},
  156.     {"Combat Shotgun"},
  157.     {"Micro Uzi (Mac 10)"},
  158.     {"MP5"},
  159.     {"AK47"},
  160.     {"M4"},
  161.     {"Tec9"},
  162.     {"CountryRifle"},
  163.     {"Sniper"},
  164.     {"RocketLauncher"},
  165.     {"Heat-Seeking Rocket Launcher"},
  166.     {"Flamethrower"},
  167.     {"Minigun"},
  168.     {"Satchel Charge"},
  169.     {"Detonator"},
  170.     {"Spray Can"},
  171.     {"Fire Extinguisher"},
  172.     {"Camera"},
  173.     {"Night Vision Goggles"},
  174.     {"Infrared Vision Goggles"},
  175.     {"Parachute"},
  176.     {"Fake Pistol"}
  177. };
  178.  
  179.  
  180. new gVehicleNames[212][] = {// from fsdebug, Vehicle Names - Betamaster
  181.     {"Landstalker"},
  182.     {"Bravura"},
  183.     {"Buffalo"},
  184.     {"Linerunner"},
  185.     {"Perrenial"},
  186.     {"Sentinel"},
  187.     {"Dumper"},
  188.     {"Firetruck"},
  189.     {"Trashmaster"},
  190.     {"Stretch"},
  191.     {"Manana"},
  192.     {"Infernus"},
  193.     {"Voodoo"},
  194.     {"Pony"},
  195.     {"Mule"},
  196.     {"Cheetah"},
  197.     {"Ambulance"},
  198.     {"Leviathan"},
  199.     {"Moonbeam"},
  200.     {"Esperanto"},
  201.     {"Taxi"},
  202.     {"Washington"},
  203.     {"Bobcat"},
  204.     {"Mr Whoopee"},
  205.     {"BF Injection"},
  206.     {"Hunter"},
  207.     {"Premier"},
  208.     {"Enforcer"},
  209.     {"Securicar"},
  210.     {"Banshee"},
  211.     {"Predator"},
  212.     {"Bus"},
  213.     {"Rhino"},
  214.     {"Barracks"},
  215.     {"Hotknife"},
  216.     {"Trailer 1"}, //artict1
  217.     {"Previon"},
  218.     {"Coach"},
  219.     {"Cabbie"},
  220.     {"Stallion"},
  221.     {"Rumpo"},
  222.     {"RC Bandit"},
  223.     {"Romero"},
  224.     {"Packer"},
  225.     {"Monster"},
  226.     {"Admiral"},
  227.     {"Squalo"},
  228.     {"Seasparrow"},
  229.     {"Pizzaboy"},
  230.     {"Tram"},
  231.     {"Trailer 2"}, //artict2
  232.     {"Turismo"},
  233.     {"Speeder"},
  234.     {"Reefer"},
  235.     {"Tropic"},
  236.     {"Flatbed"},
  237.     {"Yankee"},
  238.     {"Caddy"},
  239.     {"Solair"},
  240.     {"Berkley's RC Van"},
  241.     {"Skimmer"},
  242.     {"PCJ-600"},
  243.     {"Faggio"},
  244.     {"Freeway"},
  245.     {"RC Baron"},
  246.     {"RC Raider"},
  247.     {"Glendale"},
  248.     {"Oceanic"},
  249.     {"Sanchez"},
  250.     {"Sparrow"},
  251.     {"Patriot"},
  252.     {"Quad"},
  253.     {"Coastguard"},
  254.     {"Dinghy"},
  255.     {"Hermes"},
  256.     {"Sabre"},
  257.     {"Rustler"},
  258.     {"ZR-350"},
  259.     {"Walton"},
  260.     {"Regina"},
  261.     {"Comet"},
  262.     {"BMX"},
  263.     {"Burrito"},
  264.     {"Camper"},
  265.     {"Marquis"},
  266.     {"Baggage"},
  267.     {"Dozer"},
  268.     {"Maverick"},
  269.     {"News Chopper"},
  270.     {"Rancher"},
  271.     {"FBI Rancher"},
  272.     {"Virgo"},
  273.     {"Greenwood"},
  274.     {"Jetmax"},
  275.     {"Hotring"},
  276.     {"Sandking"},
  277.     {"Blista Compact"},
  278.     {"Police Maverick"},
  279.     {"Boxville"},
  280.     {"Benson"},
  281.     {"Mesa"},
  282.     {"RC Goblin"},
  283.     {"Hotring Racer A"}, //hotrina
  284.     {"Hotring Racer B"}, //hotrinb
  285.     {"Bloodring Banger"},
  286.     {"Rancher"},
  287.     {"Super GT"},
  288.     {"Elegant"},
  289.     {"Journey"},
  290.     {"Bike"},
  291.     {"Mountain Bike"},
  292.     {"Beagle"},
  293.     {"Cropdust"},
  294.     {"Stunt"},
  295.     {"Tanker"}, //petro
  296.     {"Roadtrain"},
  297.     {"Nebula"},
  298.     {"Majestic"},
  299.     {"Buccaneer"},
  300.     {"Shamal"},
  301.     {"Hydra"},
  302.     {"FCR-900"},
  303.     {"NRG-500"},
  304.     {"HPV1000"},
  305.     {"Cement Truck"},
  306.     {"Tow Truck"},
  307.     {"Fortune"},
  308.     {"Cadrona"},
  309.     {"FBI Truck"},
  310.     {"Willard"},
  311.     {"Forklift"},
  312.     {"Tractor"},
  313.     {"Combine"},
  314.     {"Feltzer"},
  315.     {"Remington"},
  316.     {"Slamvan"},
  317.     {"Blade"},
  318.     {"Freight"},
  319.     {"Streak"},
  320.     {"Vortex"},
  321.     {"Vincent"},
  322.     {"Bullet"},
  323.     {"Clover"},
  324.     {"Sadler"},
  325.     {"Firetruck LA"}, //firela
  326.     {"Hustler"},
  327.     {"Intruder"},
  328.     {"Primo"},
  329.     {"Cargobob"},
  330.     {"Tampa"},
  331.     {"Sunrise"},
  332.     {"Merit"},
  333.     {"Utility"},
  334.     {"Nevada"},
  335.     {"Yosemite"},
  336.     {"Windsor"},
  337.     {"Monster A"}, //monstera
  338.     {"Monster B"}, //monsterb
  339.     {"Uranus"},
  340.     {"Jester"},
  341.     {"Sultan"},
  342.     {"Stratum"},
  343.     {"Elegy"},
  344.     {"Raindance"},
  345.     {"RC Tiger"},
  346.     {"Flash"},
  347.     {"Tahoma"},
  348.     {"Savanna"},
  349.     {"Bandito"},
  350.     {"Freight Flat"}, //freiflat
  351.     {"Streak Carriage"}, //streakc
  352.     {"Kart"},
  353.     {"Mower"},
  354.     {"Duneride"},
  355.     {"Sweeper"},
  356.     {"Broadway"},
  357.     {"Tornado"},
  358.     {"AT-400"},
  359.     {"DFT-30"},
  360.     {"Huntley"},
  361.     {"Stafford"},
  362.     {"BF-400"},
  363.     {"Newsvan"},
  364.     {"Tug"},
  365.     {"Trailer 3"}, //petrotr
  366.     {"Emperor"},
  367.     {"Wayfarer"},
  368.     {"Euros"},
  369.     {"Hotdog"},
  370.     {"Club"},
  371.     {"Freight Carriage"}, //freibox
  372.     {"Trailer 3"}, //artict3
  373.     {"Andromada"},
  374.     {"Dodo"},
  375.     {"RC Cam"},
  376.     {"Launch"},
  377.     {"Police Car (LSPD)"},
  378.     {"Police Car (SFPD)"},
  379.     {"Police Car (LVPD)"},
  380.     {"Police Ranger"},
  381.     {"Picador"},
  382.     {"S.W.A.T. Van"},
  383.     {"Alpha"},
  384.     {"Phoenix"},
  385.     {"Glendale"},
  386.     {"Sadler"},
  387.     {"Luggage Trailer A"}, //bagboxa
  388.     {"Luggage Trailer B"}, //bagboxb
  389.     {"Stair Trailer"}, //tugstair
  390.     {"Boxville"},
  391.     {"Farm Plow"}, //farmtr1
  392.     {"Utility Trailer"} //utiltr1
  393. };
  394.  
  395. stock Float:AngleToPoint(x1,y1,x2,y2)
  396. {
  397.     return atan2( (y2 - y1) , (x2 - x1) ) + 270;
  398. }
  399.  
  400. stock GetVehicleModelIdByName(vehiclename[])
  401. {
  402.     for(new i = 0;i<sizeof(gVehicleNames);i++)
  403.     {
  404.         if(!strcmp(gVehicleNames[i],vehiclename,true))
  405.         {
  406.             return i +400;
  407.         }
  408.     }
  409.     return -1;
  410. }
  411.  
  412. stock GetWeaponIdByName(weaponname[])
  413. {
  414.     for(new i = 0;i<sizeof(gWeaponNames);i++)
  415.     {
  416.         if(!strcmp(gWeaponNames[i],weaponname,true))
  417.         {
  418.             return i;
  419.         }
  420.     }
  421.     return -1;
  422. }
  423.  
  424. stock GetVehicleNameByModelId(vehiclemodel)
  425. {
  426.     new str[32];format(str,sizeof str,"%s",gVehicleNames[vehiclemodel -400]);return str;
  427. }
  428.  
  429. stock GetWeaponNameById(weaponid)
  430. {
  431.     new str[32];format(str,sizeof str,"%s",gWeaponNames[weaponid]);return str;
  432. }
  433.  
  434. stock SetVehicleNumberPlateEx(vehicleid,numberplate[])
  435. {
  436.     new Float:pos[6];GetVehiclePos(vehicleid,pos[0],pos[1],pos[2]);
  437.     SetVehicleNumberPlate(vehicleid,numberplate);SetVehicleToRespawn(vehicleid);
  438.     GetVehiclePos(vehicleid,pos[3],pos[4],pos[5]);
  439.     if(pos[3] != pos[0] || pos[4] != pos[1])
  440.     {
  441.         SetVehiclePos(vehicleid,pos[0],pos[1],pos[2]);
  442.     }
  443.     return 1;
  444. }
  445.  
  446. stock ToggleVehicleLights(vehicleid,toggle)
  447. {
  448.     new engine,lights,alarm,doors,bonnet,boot,objective;
  449.     GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  450.     SetVehicleParamsEx(vehicleid,engine,toggle,alarm,doors,bonnet,boot,objective);
  451.     return 1;
  452. }
  453.  
  454. stock AreVehicleLightsOn(vehicleid)
  455. {
  456.     new engine,lights,alarm,doors,bonnet,boot,objective;
  457.     GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  458.     return lights
  459. }
  460.  
  461. stock ToggleVehicleAlarm(vehicleid,toggle)
  462. {
  463.     new engine,lights,alarm,doors,bonnet,boot,objective;
  464.     GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  465.     SetVehicleParamsEx(vehicleid,engine,lights,toggle,doors,bonnet,boot,objective);
  466.     return 1;
  467. }
  468.  
  469. stock IsVehicleAlarmOn(vehicleid)
  470. {
  471.     new engine,lights,alarm,doors,bonnet,boot,objective;
  472.     GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  473.     return alarm
  474. }
  475.  
  476. stock SetVehicleToAlarm(vehicleid,time)
  477. {
  478.     new engine,lights,alarm,doors,bonnet,boot,objective;
  479.     GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  480.     SetVehicleParamsEx(vehicleid,engine,lights,1,doors,bonnet,boot,objective);
  481.     SetTimerEx("gStopAlarm",time,false,"i",vehicleid);
  482.     return 1;
  483. }
  484. forward gStopAlarm(vehicleid);
  485. public gStopAlarm(vehicleid)
  486. {
  487.     new engine,lights,alarm,doors,bonnet,boot,objective;
  488.     GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  489.     SetVehicleParamsEx(vehicleid,engine,lights,0,doors,bonnet,boot,objective);
  490. }
  491.  
  492. stock GetVehicleType(vehicleid)
  493. {
  494.     new model = GetVehicleModel(vehicleid);
  495.     switch(model)
  496.     {
  497.         case 520 , 577 , 511 , 592 , 512 , 513 , 519 , 593 , 553 , 476, 425, 447, 469, 548, 417:
  498.         {
  499.             return 2; //planes
  500.         }
  501.         case 430, 446, 452, 453, 454, 472, 473, 484, 493, 495:
  502.         {
  503.             return 1; //boat
  504.         }
  505.         default:
  506.         {
  507.             return 0; //car/trains
  508.         }
  509.     }
  510.     return -1;
  511. }
  512.  
  513. stock Float:GetVehicleSpeed(vehicleid,UseMPH = 0)
  514. {
  515.     new Float:speed_x,Float:speed_y,Float:speed_z,Float:temp_speed;
  516.     GetVehicleVelocity(vehicleid,speed_x,speed_y,speed_z);
  517.     if(UseMPH == 0)
  518.     {
  519.         temp_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*136.666667;
  520.     } else {
  521.         temp_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*85.4166672;
  522.     }
  523.     floatround(temp_speed,floatround_round);return temp_speed;
  524. }
  525.  
  526. stock SetPlayerPosEx(playerid,Float:x,Float:y,Float:z)
  527. {
  528.     if(IsPlayerInAnyVehicle(playerid))
  529.     {
  530.         return SetVehiclePos(GetPlayerVehicleID(playerid),x,y,z);
  531.     } else return SetPlayerPos(playerid,x,y,z);
  532. }
  533.  
  534. stock Float:GetDistanceBetweenPoints(Float:x,Float:y,Float:tx,Float:ty)
  535. {
  536.   new Float:temp1, Float:temp2;
  537.   temp1 = x-tx;temp2 = y-ty;
  538.   return floatsqroot(temp1*temp1+temp2*temp2);
  539. }
  540.  
  541. stock GetClosestVehicleForPlayer(playerid)
  542. {
  543.     new Float:x,Float:y,Float:z;GetPlayerPos(playerid,x,y,z);
  544.     return GetClosestVehicleFromPoint(x,y);
  545. }
  546.  
  547. stock GetClosestVehicleFromPoint(Float:x,Float:y)
  548. {
  549.     new Float:distance = 2222,Float:tx,Float:ty,Float:z,vehicleid = -1;
  550.     for(new i = 0;i<MAX_VEHICLES;i++)
  551.     {
  552.         GetVehiclePos(i,tx,ty,z);
  553.         new Float:temp = GetDistanceBetweenPoints(x,y,tx,ty);
  554.         if(temp < distance)
  555.         {
  556.             vehicleid = i;
  557.             distance = temp;
  558.         }
  559.     }
  560.     return vehicleid;
  561. }
  562.  
  563. new androID[MAX_PLAYERS];
  564. new paraID[MAX_PLAYERS] = -1;
  565. new shipping[MAX_PLAYERS];
  566. forward create_andro(playerid);
  567. forward remove_andro(vehicleid,playerid);
  568. forward create_vehicle(playerid,ID,Float:x,Float:y,Float:z);
  569. forward update_pos(vehicleid);
  570.  
  571. stock TransportVehicleToPlayerByAir(playerid,vehicleid)
  572. {
  573.     new Float:x,Float:y,Float:z;
  574.     GetPlayerPos(playerid,x,y,z);
  575.     SetVehiclePos(vehicleid,0,0,-30);
  576.     androID[playerid] = CreateObject(14553,x,y+200,z+60,12.25,0,0);
  577.     MoveObject(androID[playerid],x,y-250,z+180,15);
  578.     shipping[playerid] = 1;
  579.     SetTimerEx("create_vehicle",12500,false,"iifff",playerid,vehicleid,x,y+13,z+60);
  580.     SetTimerEx("remove_andro",16000,false,"ii",androID[playerid],playerid);
  581.     return 1;
  582. }
  583.  
  584. public create_vehicle(playerid,ID,Float:x,Float:y,Float:z)
  585. {
  586.     SetVehiclePos(ID,x,y,z);
  587.     if(paraID[playerid] != -1){ DestroyObject(paraID[playerid]); }
  588.     paraID[playerid] = CreateObject(2903,x,y,z,0,0,0);
  589.     AttachObjectToVehicle(paraID[playerid],ID,0,0,7.3,0,0,90);
  590.     return 1;
  591. }
  592.  
  593.  
  594. public remove_andro(vehicleid,playerid)
  595. {
  596.     DestroyObject(vehicleid);
  597.     DestroyObject(paraID[playerid]);
  598.     paraID[playerid] = -1;
  599.     shipping[playerid] = 0;
  600.     return 1;
  601. }
  602.  
  603. new FlyingObj[MAX_PLAYERS] = {-1, -1, ...};
  604. new speed[MAX_PLAYERS];
  605. new UpdateTimer[MAX_PLAYERS];
  606. stock PutPlayerInObject(playerid,objectid) //modified version of Hiddos's turtle script
  607. {
  608.     new Float:Pos[4];
  609.     GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
  610.     GetPlayerFacingAngle(playerid, Pos[3]);
  611.     FlyingObj[playerid] = objectid;
  612.     TogglePlayerSpectating(playerid, 1);
  613.     OnPlayerDriveObject(playerid);
  614.     speed[playerid] = 0;
  615.     UpdateTimer[playerid] = SetTimerEx("OnPlayerDriveObject", 30, 1, "i", playerid);
  616.     return 1;
  617. }
  618.  
  619. stock GetPlayerObjectID(playerid)
  620. {
  621.     return FlyingObj[playerid];
  622. }
  623.  
  624. stock IsPlayerInObject(playerid)
  625. {
  626.     if(FlyingObj[playerid] != -1) return 1;
  627.     return 1;
  628. }
  629.  
  630. stock RemovePlayerFromObject(playerid)
  631. {
  632.     if(!IsPlayerInObject(playerid)) return 1;
  633.     KillTimer(UpdateTimer[playerid]);
  634.     new Float:x,Float:y,Float:z;
  635.     GetObjectPos(FlyingObj[playerid],x,y,z);
  636.     FlyingObj[playerid] = -1;
  637.     TogglePlayerSpectating(playerid, 0);
  638.     SetTimerEx("backtopos",500,false,"ifff",playerid,x,y,z);
  639.     return 1;
  640. }
  641. forward backtopos(playerid,Float:x,Float:y,Float:z);
  642. public backtopos(playerid,Float:x,Float:y,Float:z)
  643. {
  644.     SetPlayerPos(playerid,x+2,-2,z+1);
  645. }
  646. forward OnPlayerDriveObject(playerid);
  647. public OnPlayerDriveObject(playerid)
  648. {
  649.     new Keys[3];
  650.     GetPlayerKeys(playerid, Keys[0], Keys[1], Keys[2]);
  651.     new Float:Pos[9]; //X - Y - Z - rX - rY - rZ - nZ
  652.     GetObjectRot(FlyingObj[playerid], Pos[3], Pos[4], Pos[5]);
  653.  
  654.     if(Keys[0] & KEY_JUMP && !(Keys[0] & KEY_SPRINT)) speed[playerid]--;
  655.     if(Keys[0] & KEY_SPRINT && !(Keys[0] & KEY_JUMP)) speed[playerid]++;
  656.  
  657. //Rotation part
  658.     Pos[4] = ((Keys[2] < 0) ? (-33.3) : (Keys[2] > 0) ? (33.3) : (0.0));
  659.     Pos[5] += (((Keys[2] < 0 && speed[playerid] >= 0) || (Keys[2] > 0 && speed[playerid] < 0)) ? (3.5) : ((Keys[2] > 0 && speed[playerid] >= 0) || (Keys[2] < 0 && speed[playerid] < 0) ? (-3.5) : (0.0)));
  660.     //That's quite a line
  661.     //Don't mention this text. I like giving feedback on my own scripting lol.
  662.     Pos[3] = ((Keys[1] < 0) ? (-33.3) : (Keys[1] > 0) ? (33.3) : (0.0));
  663.  
  664.     SetObjectRot(FlyingObj[playerid], Pos[3], Pos[4], Pos[5]);
  665.  
  666. //Location part - Sarcasm(YAY, YAY, YAY, YAY, YAY, YAY);
  667.     GetObjectPos(FlyingObj[playerid], Pos[0], Pos[1], Pos[2]);
  668.     Pos[7] = Pos[0] + (floatdiv(speed[playerid], 145) * floatsin(-Pos[5], degrees) * ((Keys[1] == 0) ? (1.0) : (floatdiv(2, 3))));
  669.     Pos[8] = Pos[1] + (floatdiv(speed[playerid], 145) * floatcos(-Pos[5], degrees) * ((Keys[1] == 0) ? (1.0) : (floatdiv(2, 3))));
  670.  
  671.     Pos[2] += ((Keys[1] < 0) ? (-0.333) : (Keys[1] > 0) ? (0.333) : (0.0)) * floatdiv(speed[playerid], 145);
  672.     SetObjectPos(FlyingObj[playerid], Pos[7], Pos[8], Pos[2]);
  673.  
  674. //Camera part. This pisses me off all the time...
  675.     SetPlayerCameraLookAt(playerid, Pos[0] + (4 * floatsin(-Pos[5], degrees)), Pos[1] + (4 * floatcos(-Pos[5], degrees)), Pos[ ((Pos[6] > Pos[1]+1) ? (6) : (2)) ] + 1);
  676.     Pos[0] -= (8 * floatsin(-Pos[5], degrees));
  677.     Pos[1] -= (8 * floatcos(-Pos[5], degrees));
  678.     SetPlayerCameraPos(playerid, Pos[0], Pos[1], Pos[ ((Pos[6] > Pos[1]+1) ? (6) : (2)) ] + 6.8);
  679. }
  680.  
  681. stock MutePlayer(playerid)
  682. {
  683.     return SetPVarInt(playerid,"muted",1);
  684. }
  685.  
  686. stock UnMutePlayer(playerid)
  687. {
  688.     return SetPVarInt(playerid,"muted",0);
  689. }
  690.  
  691. stock JailPlayer(playerid)
  692. {
  693.     SetPlayerInterior(playerid,6);SetPlayerPos(playerid, 265.6881,76.6573,1001.0391);TogglePlayerControllable(playerid,0);
  694.     SetPlayerCameraPos(playerid,269.5,77.5,1002);return SetPlayerCameraLookAt(playerid,264.6288,77.5742,1001.0391);
  695. }
  696.  
  697. stock UnJailPlayer(playerid)
  698. {
  699.     SetPlayerPos(playerid, 267.6288,77.5742,1001.0391);TogglePlayerControllable(playerid,1);return SetCameraBehindPlayer(playerid);
  700. }
  701.  
  702. stock SetPlayerToReconnect(playerid)
  703. {
  704.     SetPVarInt(playerid,"reconnecting",1);TogglePlayerSpectating(playerid,1);return SendRconCommandEx("ss","banip ",GetPlayerIpEx(playerid));
  705. }
  706.  
  707. stock SetPlayerMoney(playerid,ammount)
  708. {
  709.     ResetPlayerMoney(playerid);return GivePlayerMoney(playerid,ammount);
  710. }
  711.  
  712. stock GivePlayerScore(playerid,ammount)
  713. {
  714.     new score = GetPlayerScore(playerid);score=score+ammount;return SetPlayerScore(playerid,score);
  715. }
  716.  
  717. stock GetPlayerNameEx(playerid)
  718. {
  719.     new pName[MAX_PLAYER_NAME];GetPlayerName(playerid,pName,sizeof pName);return pName;
  720. }
  721.  
  722. stock GetPlayerIpEx(playerid)
  723. {
  724.     new ip[32];GetPlayerIp(playerid,ip,sizeof ip);return ip;
  725. }
  726.  
  727. stock KickEx(playerid,reason[])
  728. {
  729.     SendClientMessageEx(playerid,0xA8C3E0FF,"ss","You have been kicked from this server, reason: ",reason);printf("%s has been kicked by the server. (Reason: %s)",GetPlayerNameEx(playerid),reason);return Kick(playerid);
  730. }
  731.  
  732. stock SendRconCommandEx(type[],{Float,_}:...)
  733. {
  734.     new string[128];
  735.     for(new i = 0;i<numargs();i++)
  736.     {
  737.         switch(type[i])
  738.         {
  739.             case 's':
  740.             {
  741.                 new result[128];
  742.                 for(new a= 0;getarg(i +1,a) != 0;a++)
  743.                 {
  744.                     result[a] = getarg(i +1,a);
  745.                 }
  746.                 if(!strlen(string))
  747.                 {
  748.                     format(string,sizeof string,"%s",result);
  749.                 } else format(string,sizeof string,"%s%s",string,result);
  750.             }
  751.  
  752.             case 'i':
  753.             {
  754.                 new result = getarg(i +1);
  755.                 if(!strlen(string))
  756.                 {
  757.                     format(string,sizeof string,"%i",result);
  758.                 } else format(string,sizeof string,"%s%i",string,result);
  759.             }
  760.  
  761.             case 'f':
  762.             {
  763.                 new Float:result = Float:getarg(i +1);
  764.                 if(!strlen(string))
  765.                 {
  766.                     format(string,sizeof string,"%f",result);
  767.                 } else format(string,sizeof string,"%s%f",string,result);
  768.             }
  769.         }
  770.     }
  771.     SendRconCommand(string);
  772.     return 1;
  773. }
  774.  
  775. stock SendClientMessageEx(playerid,color,type[],{Float,_}:...)
  776. {
  777.     new string[128];
  778.     for(new i = 0;i<numargs() -2;i++)
  779.     {
  780.         switch(type[i])
  781.         {
  782.             case 's':
  783.             {
  784.                 new result[128];
  785.                 for(new a= 0;getarg(i +3,a) != 0;a++)
  786.                 {
  787.                     result[a] = getarg(i +3,a);
  788.                 }
  789.                 if(!strlen(string))
  790.                 {
  791.                     format(string,sizeof string,"%s",result);
  792.                 } else format(string,sizeof string,"%s%s",string,result);
  793.             }
  794.  
  795.             case 'i':
  796.             {
  797.                 new result = getarg(i +3);
  798.                 if(!strlen(string))
  799.                 {
  800.                     format(string,sizeof string,"%i",result);
  801.                 } else format(string,sizeof string,"%s%i",string,result);
  802.             }
  803.  
  804.             case 'f':
  805.             {
  806.                 new Float:result = Float:getarg(i +3);
  807.                 if(!strlen(string))
  808.                 {
  809.                     format(string,sizeof string,"%f",result);
  810.                 } else format(string,sizeof string,"%s%f",string,result);
  811.             }
  812.         }
  813.     }
  814.     SendClientMessage(playerid,color,string);
  815.     return 1;
  816. }
  817.  
  818. stock SendClientMessageToAllEx(color,type[],{Float,_}:...)
  819. {
  820.     new string[128];
  821.     for(new i = 0;i<numargs() -1;i++)
  822.     {
  823.         switch(type[i])
  824.         {
  825.             case 's':
  826.             {
  827.                 new result[128];
  828.                 for(new a= 0;getarg(i +2,a) != 0;a++)
  829.                 {
  830.                     result[a] = getarg(i +2,a);
  831.                 }
  832.                 if(!strlen(string))
  833.                 {
  834.                     format(string,sizeof string,"%s",result);
  835.                 } else format(string,sizeof string,"%s%s",string,result);
  836.             }
  837.  
  838.             case 'i':
  839.             {
  840.                 new result = getarg(i +2);
  841.                 if(!strlen(string))
  842.                 {
  843.                     format(string,sizeof string,"%i",result);
  844.                 } else format(string,sizeof string,"%s%i",string,result);
  845.             }
  846.  
  847.             case 'f':
  848.             {
  849.                 new Float:result = Float:getarg(i +2);
  850.                 if(!strlen(string))
  851.                 {
  852.                     format(string,sizeof string,"%f",result);
  853.                 } else format(string,sizeof string,"%s%f",string,result);
  854.             }
  855.         }
  856.     }
  857.     SendClientMessageToAll(color,string);
  858.     return 1;
  859. }
  860.  
  861. stock GameTextForPlayerEx(playerid,time,style,type[],{Float,_}:...)
  862. {
  863.     new string[128];
  864.     for(new i = 0;i<numargs() -3;i++)
  865.     {
  866.         switch(type[i])
  867.         {
  868.             case 's':
  869.             {
  870.                 new result[128];
  871.                 for(new a= 0;getarg(i +4,a) != 0;a++)
  872.                 {
  873.                     result[a] = getarg(i +4,a);
  874.                 }
  875.                 if(!strlen(string))
  876.                 {
  877.                     format(string,sizeof string,"%s",result);
  878.                 } else format(string,sizeof string,"%s%s",string,result);
  879.             }
  880.  
  881.             case 'i':
  882.             {
  883.                 new result = getarg(i +4);
  884.                 if(!strlen(string))
  885.                 {
  886.                     format(string,sizeof string,"%i",result);
  887.                 } else format(string,sizeof string,"%s%i",string,result);
  888.             }
  889.  
  890.             case 'f':
  891.             {
  892.                 new Float:result = Float:getarg(i +4);
  893.                 if(!strlen(string))
  894.                 {
  895.                     format(string,sizeof string,"%f",result);
  896.                 } else format(string,sizeof string,"%s%f",string,result);
  897.             }
  898.         }
  899.     }
  900.     GameTextForPlayer(playerid,string,time,style);
  901.     return 1;
  902. }
  903.  
  904. stock GameTextForAllEx(time,style,type[],{Float,_}:...)
  905. {
  906.     new string[128];
  907.     for(new i = 0;i<numargs() -2;i++)
  908.     {
  909.         switch(type[i])
  910.         {
  911.             case 's':
  912.             {
  913.                 new result[128];
  914.                 for(new a= 0;getarg(i +3,a) != 0;a++)
  915.                 {
  916.                     result[a] = getarg(i +3,a);
  917.                 }
  918.                 if(!strlen(string))
  919.                 {
  920.                     format(string,sizeof string,"%s",result);
  921.                 } else format(string,sizeof string,"%s%s",string,result);
  922.             }
  923.  
  924.             case 'i':
  925.             {
  926.                 new result = getarg(i +3);
  927.                 if(!strlen(string))
  928.                 {
  929.                     format(string,sizeof string,"%i",result);
  930.                 } else format(string,sizeof string,"%s%i",string,result);
  931.             }
  932.  
  933.             case 'f':
  934.             {
  935.                 new Float:result = Float:getarg(i +3);
  936.                 if(!strlen(string))
  937.                 {
  938.                     format(string,sizeof string,"%f",result);
  939.                 } else format(string,sizeof string,"%s%f",string,result);
  940.             }
  941.         }
  942.     }
  943.     GameTextForAll(string,time,style);
  944.     return 1;
  945. }
  946.  
  947. stock CenterString(string[],leng)
  948. {
  949.     new temp[128],tmp;
  950.     format(temp,sizeof temp,"%s",string);
  951.     tmp = (leng - strlen(temp)) / 2;
  952.     for(new a = 0;a<tmp;a++)
  953.     {
  954.         format(temp,sizeof temp," %s",temp);
  955.     }
  956.     return temp;
  957. }
Advertisement
Add Comment
Please, Sign In to add comment