Advertisement
demonneni

Sistema de veiculos avançado (BETA) {Em desenvolvimento}

Aug 15th, 2014
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 12.10 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3.  
  4. // messages
  5. #define OPTION_SCM      0   // SendClientMessage
  6. #define OPTION_GTP      1   // GameTextForPlayer
  7. #define OPTION_TXD      2   // TextDrawShowForPlayer
  8.  
  9. // positions
  10. #define POS_X           0
  11. #define POS_Y           1
  12. #define POS_Z           2
  13. #define POS_A           3
  14.  
  15.  
  16. stock iCreateVehicle(playerid, msgmode, msgstring[], modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_d);
  17. stock OptionMessageGameText(allplayers, time, style);
  18. stock OptionMessageClient(allplayers, color);
  19.  
  20. new VehicleColoursTableRGBA[256] = {
  21.     // The existing colours from San Andreas
  22.     0x000000FF, 0xF5F5F5FF, 0x2A77A1FF, 0x840410FF, 0x263739FF, 0x86446EFF, 0xD78E10FF, 0x4C75B7FF, 0xBDBEC6FF, 0x5E7072FF,
  23.     0x46597AFF, 0x656A79FF, 0x5D7E8DFF, 0x58595AFF, 0xD6DAD6FF, 0x9CA1A3FF, 0x335F3FFF, 0x730E1AFF, 0x7B0A2AFF, 0x9F9D94FF,
  24.     0x3B4E78FF, 0x732E3EFF, 0x691E3BFF, 0x96918CFF, 0x515459FF, 0x3F3E45FF, 0xA5A9A7FF, 0x635C5AFF, 0x3D4A68FF, 0x979592FF,
  25.     0x421F21FF, 0x5F272BFF, 0x8494ABFF, 0x767B7CFF, 0x646464FF, 0x5A5752FF, 0x252527FF, 0x2D3A35FF, 0x93A396FF, 0x6D7A88FF,
  26.     0x221918FF, 0x6F675FFF, 0x7C1C2AFF, 0x5F0A15FF, 0x193826FF, 0x5D1B20FF, 0x9D9872FF, 0x7A7560FF, 0x989586FF, 0xADB0B0FF,
  27.     0x848988FF, 0x304F45FF, 0x4D6268FF, 0x162248FF, 0x272F4BFF, 0x7D6256FF, 0x9EA4ABFF, 0x9C8D71FF, 0x6D1822FF, 0x4E6881FF,
  28.     0x9C9C98FF, 0x917347FF, 0x661C26FF, 0x949D9FFF, 0xA4A7A5FF, 0x8E8C46FF, 0x341A1EFF, 0x6A7A8CFF, 0xAAAD8EFF, 0xAB988FFF,
  29.     0x851F2EFF, 0x6F8297FF, 0x585853FF, 0x9AA790FF, 0x601A23FF, 0x20202CFF, 0xA4A096FF, 0xAA9D84FF, 0x78222BFF, 0x0E316DFF,
  30.     0x722A3FFF, 0x7B715EFF, 0x741D28FF, 0x1E2E32FF, 0x4D322FFF, 0x7C1B44FF, 0x2E5B20FF, 0x395A83FF, 0x6D2837FF, 0xA7A28FFF,
  31.     0xAFB1B1FF, 0x364155FF, 0x6D6C6EFF, 0x0F6A89FF, 0x204B6BFF, 0x2B3E57FF, 0x9B9F9DFF, 0x6C8495FF, 0x4D8495FF, 0xAE9B7FFF,
  32.     0x406C8FFF, 0x1F253BFF, 0xAB9276FF, 0x134573FF, 0x96816CFF, 0x64686AFF, 0x105082FF, 0xA19983FF, 0x385694FF, 0x525661FF,
  33.     0x7F6956FF, 0x8C929AFF, 0x596E87FF, 0x473532FF, 0x44624FFF, 0x730A27FF, 0x223457FF, 0x640D1BFF, 0xA3ADC6FF, 0x695853FF,
  34.     0x9B8B80FF, 0x620B1CFF, 0x5B5D5EFF, 0x624428FF, 0x731827FF, 0x1B376DFF, 0xEC6AAEFF, 0x000000FF,
  35.     // SA-MP extended colours (0.3x)
  36.     0x177517FF, 0x210606FF, 0x125478FF, 0x452A0DFF, 0x571E1EFF, 0x010701FF, 0x25225AFF, 0x2C89AAFF, 0x8A4DBDFF, 0x35963AFF,
  37.     0xB7B7B7FF, 0x464C8DFF, 0x84888CFF, 0x817867FF, 0x817A26FF, 0x6A506FFF, 0x583E6FFF, 0x8CB972FF, 0x824F78FF, 0x6D276AFF,
  38.     0x1E1D13FF, 0x1E1306FF, 0x1F2518FF, 0x2C4531FF, 0x1E4C99FF, 0x2E5F43FF, 0x1E9948FF, 0x1E9999FF, 0x999976FF, 0x7C8499FF,
  39.     0x992E1EFF, 0x2C1E08FF, 0x142407FF, 0x993E4DFF, 0x1E4C99FF, 0x198181FF, 0x1A292AFF, 0x16616FFF, 0x1B6687FF, 0x6C3F99FF,
  40.     0x481A0EFF, 0x7A7399FF, 0x746D99FF, 0x53387EFF, 0x222407FF, 0x3E190CFF, 0x46210EFF, 0x991E1EFF, 0x8D4C8DFF, 0x805B80FF,
  41.     0x7B3E7EFF, 0x3C1737FF, 0x733517FF, 0x781818FF, 0x83341AFF, 0x8E2F1CFF, 0x7E3E53FF, 0x7C6D7CFF, 0x020C02FF, 0x072407FF,
  42.     0x163012FF, 0x16301BFF, 0x642B4FFF, 0x368452FF, 0x999590FF, 0x818D96FF, 0x99991EFF, 0x7F994CFF, 0x839292FF, 0x788222FF,
  43.     0x2B3C99FF, 0x3A3A0BFF, 0x8A794EFF, 0x0E1F49FF, 0x15371CFF, 0x15273AFF, 0x375775FF, 0x060820FF, 0x071326FF, 0x20394BFF,
  44.     0x2C5089FF, 0x15426CFF, 0x103250FF, 0x241663FF, 0x692015FF, 0x8C8D94FF, 0x516013FF, 0x090F02FF, 0x8C573AFF, 0x52888EFF,
  45.     0x995C52FF, 0x99581EFF, 0x993A63FF, 0x998F4EFF, 0x99311EFF, 0x0D1842FF, 0x521E1EFF, 0x42420DFF, 0x4C991EFF, 0x082A1DFF,
  46.     0x96821DFF, 0x197F19FF, 0x3B141FFF, 0x745217FF, 0x893F8DFF, 0x7E1A6CFF, 0x0B370BFF, 0x27450DFF, 0x071F24FF, 0x784573FF,
  47.     0x8A653AFF, 0x732617FF, 0x319490FF, 0x56941DFF, 0x59163DFF, 0x1B8A2FFF, 0x38160BFF, 0x041804FF, 0x355D8EFF, 0x2E3F5BFF,
  48.     0x561A28FF, 0x4E0E27FF, 0x706C67FF, 0x3B3E42FF, 0x2E2D33FF, 0x7B7E7DFF, 0x4A4442FF, 0x28344EFF
  49. };
  50.  
  51. new VehicleNames[212][] = {
  52.     {"Landstalker"},{"Bravura"},{"Buffalo"},{"Linerunner"},{"Perrenial"},{"Sentinel"},{"Dumper"},
  53.     {"Firetruck"},{"Trashmaster"},{"Stretch"},{"Manana"},{"Infernus"},{"Voodoo"},{"Pony"},{"Mule"},
  54.     {"Cheetah"},{"Ambulance"},{"Leviathan"},{"Moonbeam"},{"Esperanto"},{"Taxi"},{"Washington"},
  55.     {"Bobcat"},{"Mr Whoopee"},{"BF Injection"},{"Hunter"},{"Premier"},{"Enforcer"},{"Securicar"},
  56.     {"Banshee"},{"Predator"},{"Bus"},{"Rhino"},{"Barracks"},{"Hotknife"},{"Trailer 1"},{"Previon"},
  57.     {"Coach"},{"Cabbie"},{"Stallion"},{"Rumpo"},{"RC Bandit"},{"Romero"},{"Packer"},{"Monster"},
  58.     {"Admiral"},{"Squalo"},{"Seasparrow"},{"Pizzaboy"},{"Tram"},{"Trailer 2"},{"Turismo"},
  59.     {"Speeder"},{"Reefer"},{"Tropic"},{"Flatbed"},{"Yankee"},{"Caddy"},{"Solair"},{"Berkley's RC Van"},
  60.     {"Skimmer"},{"PCJ-600"},{"Faggio"},{"Freeway"},{"RC Baron"},{"RC Raider"},{"Glendale"},{"Oceanic"},
  61.     {"Sanchez"},{"Sparrow"},{"Patriot"},{"Quad"},{"Coastguard"},{"Dinghy"},{"Hermes"},{"Sabre"},
  62.     {"Rustler"},{"ZR-350"},{"Walton"},{"Regina"},{"Comet"},{"BMX"},{"Burrito"},{"Camper"},{"Marquis"},
  63.     {"Baggage"},{"Dozer"},{"Maverick"},{"News Chopper"},{"Rancher"},{"FBI Rancher"},{"Virgo"},{"Greenwood"},
  64.     {"Jetmax"},{"Hotring"},{"Sandking"},{"Blista Compact"},{"Police Maverick"},{"Boxville"},{"Benson"},
  65.     {"Mesa"},{"RC Goblin"},{"Hotring Racer A"},{"Hotring Racer B"},{"Bloodring Banger"},{"Rancher"},
  66.     {"Super GT"},{"Elegant"},{"Journey"},{"Bike"},{"Mountain Bike"},{"Beagle"},{"Cropdust"},{"Stunt"},
  67.     {"Tanker"}, {"Roadtrain"},{"Nebula"},{"Majestic"},{"Buccaneer"},{"Shamal"},{"Hydra"},{"FCR-900"},
  68.     {"NRG-500"},{"HPV1000"},{"Cement Truck"},{"Tow Truck"},{"Fortune"},{"Cadrona"},{"FBI Truck"},
  69.     {"Willard"},{"Forklift"},{"Tractor"},{"Combine"},{"Feltzer"},{"Remington"},{"Slamvan"},
  70.     {"Blade"},{"Freight"},{"Streak"},{"Vortex"},{"Vincent"},{"Bullet"},{"Clover"},{"Sadler"},
  71.     {"Firetruck LA"},{"Hustler"},{"Intruder"},{"Primo"},{"Cargobob"},{"Tampa"},{"Sunrise"},{"Merit"},
  72.     {"Utility"},{"Nevada"},{"Yosemite"},{"Windsor"},{"Monster A"},{"Monster B"},{"Uranus"},{"Jester"},
  73.     {"Sultan"},{"Stratum"},{"Elegy"},{"Raindance"},{"RC Tiger"},{"Flash"},{"Tahoma"},{"Savanna"},
  74.     {"Bandito"},{"Freight Flat"},{"Streak Carriage"},{"Kart"},{"Mower"},{"Duneride"},{"Sweeper"},
  75.     {"Broadway"},{"Tornado"},{"AT-400"},{"DFT-30"},{"Huntley"},{"Stafford"},{"BF-400"},{"Newsvan"},
  76.     {"Tug"},{"Trailer 3"},{"Emperor"},{"Wayfarer"},{"Euros"},{"Hotdog"},{"Club"},{"Freight Carriage"},
  77.     {"Trailer 3"},{"Andromada"},{"Dodo"},{"RC Cam"},{"Launch"},{"Police Car (LSPD)"},{"Police Car (SFPD)"},
  78.     {"Police Car (LVPD)"},{"Police Ranger"},{"Picador"},{"S.W.A.T. Van"},{"Alpha"},{"Phoenix"},{"Glendale"},
  79.     {"Sadler"},{"Luggage Trailer A"},{"Luggage Trailer B"},{"Stair Trailer"},{"Boxville"},{"Farm Plow"},
  80.     {"Utility Trailer"}
  81. };
  82.  
  83. enum _:DialogIDs{
  84.     M_SPAWN = 888
  85.  
  86.  
  87. };
  88.  
  89. enum E_VEH_DATA{
  90.     v_id,
  91.     v_lastid,
  92.     v_modelid,
  93.     Float:v_pos[4],
  94.     v_color1,
  95.     v_color2,
  96.  
  97.     // Compra/Venda
  98.     v_owner[MAX_PLAYER_NAME],
  99.     v_price,
  100.     v_plate
  101. };
  102.  
  103. enum E_VEH_TUNING{
  104.     t_componentid,
  105.     t_nitro
  106. };
  107.  
  108. enum E_SCM_SYSTEM{
  109.     g_allPlayers,
  110.     _color
  111. };
  112.  
  113. enum E_GTP_SYSTEM{
  114.     g_allPlayers,
  115.     _time,
  116.     _style
  117. };
  118.  
  119. enum E_TXD_SYSTEM{
  120.     g_allPlayers
  121. };
  122.  
  123. new
  124.     // Text message
  125.     PlayerText:g_pMessage[MAX_PLAYERS],
  126.     Text:g_gMessage,
  127.     g_szString[128],
  128.  
  129.     // Vehicle data
  130.     VehicleInfo[MAX_PLAYERS][E_VEH_DATA],
  131.  
  132.     // Config system
  133.     g_optionTextDraw[E_TXD_SYSTEM],
  134.     g_optionGameText[E_GTP_SYSTEM],
  135.     g_optionClientMessage[E_SCM_SYSTEM],
  136.  
  137.     Float:g_velocityVeh[4]
  138. ;
  139.  
  140. public OnFilterScriptInit(){
  141.  
  142.     print("sys_vehicles by iShock");
  143.  
  144.  
  145.     OptionMessageGameText(false, 5000, 1);
  146.     OptionMessageClient(false, 0xFFFF00FF);
  147.     return 1;
  148. }
  149.  
  150. public OnFilterScriptExit(){
  151.  
  152.     printf("Sistema de veículos descarregado!");
  153.  
  154.     return 1;
  155. }
  156.  
  157. public OnPlayerConnect(playerid){
  158.     g_pMessage[playerid] = CreatePlayerTextDraw(playerid, 240.0, 580.0, "_");
  159.     g_gMessage = TextDrawCreate(100.0, 100.0, "_");
  160.     return 1;
  161. }
  162.  
  163. CMD:vmenu(playerid, params[]){
  164.    
  165.     ShowPlayerDialog(playerid, M_SPAWN, DIALOG_STYLE_LIST,
  166.                                                             "Vehicle menu",
  167.                                                             "Criar\n\
  168.                                                             Tunar\n\
  169.                                                             Garagem",
  170.                                                             "enter", "exit"
  171.     );
  172.     return 1;
  173. }
  174.  
  175. CMD:vid(playerid, params[]){
  176.     new
  177.         Float:px,
  178.         Float:py,
  179.         Float:pz,
  180.         Float:pa,
  181.         string[128]
  182.     ;
  183.    
  184.     iGetPos(playerid,  px, py, pz, pa);
  185.     format(string, sizeof(string), "Você criou um veículo - Modelo:%s", GetVehicleName(strval(params)));
  186.     iCreateVehicle(playerid, OPTION_GTP, string, strval(params), px, py, pz+2.0, pa, 0, 0, -1);
  187.     return 1;
  188. }
  189.  
  190.  
  191.  
  192. CMD:vlast(playerid, params[]){
  193.     GetLastVehicle_Pos(playerid);
  194.     return 1;
  195. }
  196.  
  197. CMD:getv(playerid, params[]){
  198.     new
  199.         Float:_xPos,
  200.         Float:_yPos,
  201.         Float:_zPos,
  202.         Float:_anglePos
  203.     ;
  204.  
  205.     iGetPos(playerid, _xPos, _yPos, _zPos, _anglePos);
  206.     return 1;
  207. }
  208.  
  209. iGetPos(playerid, &Float:x,&Float:y, &Float:z, &Float:angle){
  210.     if (GetPlayerState(playerid) == PLAYER_STATE_DRIVER){
  211.         GetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
  212.         GetVehicleVelocity(GetPlayerVehicleID(playerid), g_velocityVeh[0], g_velocityVeh[1], g_velocityVeh[2]);
  213.         GetVehicleZAngle(GetPlayerVehicleID(playerid), angle);
  214.     }
  215.     else {
  216.         GetPlayerPos(playerid, x, y, z);
  217.         GetPlayerFacingAngle(playerid, angle);
  218.     }
  219. }
  220.  
  221. GetLastVehicle_Pos(playerid){
  222.     new Float:f_tmp[4];
  223.  
  224.     if (!GetPlayerVehicleID(playerid)){
  225.         GetPlayerPos(playerid, f_tmp[POS_X], f_tmp[POS_Y], f_tmp[POS_Z]);
  226.         SetVehiclePos(VehicleInfo[playerid][v_lastid], f_tmp[POS_X], f_tmp[POS_Y], f_tmp[POS_Z]);
  227.         PutPlayerInVehicle(playerid, VehicleInfo[playerid][v_lastid], 0);
  228.     } else {
  229.         SendClientMessage(playerid, 0xFF0000FF, "Você precisa sair do veículo atual!");
  230.     }
  231.     return 0;
  232. }
  233.  
  234. iCreateVehicle(playerid, msgmode, msgstring[], modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_d){
  235.     if ( 400 <= modelid <= 611){
  236.         if (VehicleInfo[playerid][v_lastid]){
  237.             RemovePlayerFromVehicle(playerid);
  238.             new i;
  239.             while( i != 75){ i++;}
  240.             DestroyVehicle(VehicleInfo[playerid][v_lastid]);
  241.         }
  242.         VehicleInfo[playerid][v_id]         = CreateVehicle(modelid, x, y, z, angle, color1, color2, respawn_d);
  243.         VehicleInfo[playerid][v_lastid]     = VehicleInfo[playerid][v_id];
  244.         VehicleInfo[playerid][v_modelid]    = modelid;
  245.         VehicleInfo[playerid][v_pos][POS_X]     = x;
  246.         VehicleInfo[playerid][v_pos][POS_Y]     = y;
  247.         VehicleInfo[playerid][v_pos][POS_Z]     = z;
  248.         VehicleInfo[playerid][v_pos][POS_A]     = angle;
  249.  
  250.  
  251.         SetVehicleVirtualWorld(VehicleInfo[playerid][v_id], GetPlayerVirtualWorld(playerid));
  252.         LinkVehicleToInterior(VehicleInfo[playerid][v_id], GetPlayerInterior(playerid));
  253.         PutPlayerInVehicle(playerid, VehicleInfo[playerid][v_id], 0);
  254.         SetVehicleVelocity(VehicleInfo[playerid][v_id], g_velocityVeh[POS_X], g_velocityVeh[POS_Y], g_velocityVeh[POS_Z]);
  255.     } else {
  256.         VehicleInfo[playerid][v_id] = INVALID_VEHICLE_ID;
  257.         format(g_szString, sizeof(g_szString), "Internal error - ID:%d");  //Não finalizado
  258.         SendClientMessage(playerid,-1, g_szString);
  259.     }
  260.     SendMessage(playerid, msgstring, msgmode);
  261.     return VehicleInfo[playerid][v_id];
  262. }
  263.  
  264. SendMessage(playerid, const string[], msgmode){
  265.     if (string[0] || strlen(string) > 3){
  266.         switch (msgmode){
  267.             case OPTION_SCM:{
  268.                 if (!g_optionClientMessage[g_allPlayers]){
  269.                     SendClientMessage(playerid, g_optionClientMessage[_color], string);
  270.                 } else {
  271.                     SendClientMessageToAll(g_optionClientMessage[_color], string);
  272.                 }
  273.             }
  274.             case OPTION_GTP:{
  275.                 if (!g_optionGameText[g_allPlayers]){
  276.                     GameTextForPlayer(playerid, string, g_optionGameText[_time], g_optionGameText[_style]);
  277.                 } else{
  278.                     GameTextForAll(string, g_optionGameText[_time], g_optionGameText[_style]);
  279.                 }
  280.             }
  281.             case OPTION_TXD: {
  282.                 if (!g_optionTextDraw[g_allPlayers]){
  283.                     PlayerTextDrawShow(playerid, g_pMessage[playerid]);
  284.                 } else{
  285.                     TextDrawShowForAll( g_gMessage);
  286.                 }
  287.             }
  288.             default:{
  289.                 print(string);
  290.             }
  291.         }
  292.     }
  293.     return 1;
  294. }
  295.  
  296. GetVehicleName(model){
  297.     new L_szString[35];
  298.     L_szString = "model unknown";
  299.     if(400 <= model <= 611)
  300.         strcat((L_szString[0]= '\0', L_szString), VehicleNames[model - 400]);
  301.     return L_szString;
  302. }
  303.  
  304. OptionMessageGameText(allplayers, time, style){
  305.     g_optionGameText[g_allPlayers]  = allplayers;
  306.     g_optionGameText[_time]         = time;
  307.     g_optionGameText[_style]        = style;
  308. }
  309.  
  310. OptionMessageClient(allplayers, color){
  311.     g_optionClientMessage[g_allPlayers] = allplayers;
  312.     g_optionClientMessage[_color]       = color;
  313. }
  314.  
  315.    
  316.  
  317. //--------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement