Guest User

Untitled

a guest
Oct 23rd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.30 KB | None | 0 0
  1.  
  2. #include <a_samp>
  3.  
  4.  
  5. new
  6. vModel,
  7. Float:ppos[3],
  8. Text3D:TextVeH,
  9. VeiculoID[MAX_PLAYERS],
  10. gstring[256]
  11. ;
  12.  
  13. new Veiculos[212][] =
  14. {
  15. {"Landstalker"},{"Bravura"},{"Buffalo"},{"Linerunner"},{"Perrenial"},{"Sentinel"},{"Dumper"},{"Firetruck"},{"Trashmaster"},
  16. {"Stretch"},{"Manana"},{"Infernus"},{"Voodoo"},{"Pony"},{"Mule"},{"Cheetah"},{"Ambulance"},{"Leviathan"},{"Moonbeam"},
  17. {"Esperanto"},{"Taxi"},{"Washington"},{"Bobcat"},{"Mr Whoopee"},{"BF Injection"},{"Hunter"},{"Premier"},{"Enforcer"},
  18. {"Securicar"},{"Banshee"},{"Predator"},{"Bus"},{"Rhino"},{"Barracks"},{"Hotknife"},{"Trailer 1"},{"Previon"},{"Coach"},
  19. {"Cabbie"},{"Stallion"},{"Rumpo"},{"RC Bandit"},{"Romero"},{"Packer"},{"Monster"},{"Admiral"},{"Squalo"},{"Seasparrow"},
  20. {"Pizzaboy"},{"Tram"},{"Trailer 2"},{"Turismo"},{"Speeder"},{"Reefer"},{"Tropic"},{"Flatbed"},{"Yankee"},{"Caddy"},{"Solair"},
  21. {"Berkley's RC Van"},{"Skimmer"},{"PCJ-600"},{"Faggio"},{"Freeway"},{"RC Baron"},{"RC Raider"},{"Glendale"},{"Oceanic"},
  22. {"Sanchez"},{"Sparrow"},{"Patriot"},{"Quad"},{"Coastguard"},{"Dinghy"},{"Hermes"},{"Sabre"},{"Rustler"},{"ZR-350"},{"Walton"},
  23. {"Regina"},{"Comet"},{"BMX"},{"Burrito"},{"Camper"},{"Marquis"},{"Baggage"},{"Dozer"},{"Maverick"},{"News Chopper"},{"Rancher"},
  24. {"FBI Rancher"},{"Virgo"},{"Greenwood"},{"Jetmax"},{"Hotring"},{"Sandking"},{"Blista Compact"},{"Police Maverick"},{"Boxville"},
  25. {"Benson"},{"Mesa"},{"RC Goblin"},{"Hotring Racer A"},{"Hotring Racer B"},{"Bloodring Banger"},{"Rancher"},{"Super GT"},
  26. {"Elegant"},{"Journey"},{"Bike"},{"Mountain Bike"},{"Beagle"},{"Cropdust"},{"Stunt"},{"Tanker"},{"Roadtrain"},{"Nebula"},
  27. {"Majestic"},{"Buccaneer"},{"Shamal"},{"Hydra"},{"FCR-900"},{"NRG-500"},{"HPV1000"},{"Cement Truck"},{"Tow Truck"},{"Fortune"},
  28. {"Cadrona"},{"FBI Truck"},{"Willard"},{"Forklift"},{"Tractor"},{"Combine"},{"Feltzer"},{"Remington"},{"Slamvan"},{"Blade"},
  29. {"Freight"},{"Streak"},{"Vortex"},{"Vincent"},{"Bullet"},{"Clover"},{"Sadler"},{"Firetruck LA"},{"Hustler"},{"Intruder"},
  30. {"Primo"},{"Cargobob"},{"Tampa"},{"Sunrise"},{"Merit"},{"Utility"},{"Nevada"},{"Yosemite"},{"Windsor"},{"Monster A"},{"Monster B"},
  31. {"Uranus"},{"Jester"},{"Sultan"},{"Stratum"},{"Elegy"},{"Raindance"},{"RC Tiger"},{"Flash"},{"Tahoma"},{"Savanna"},{"Bandito"},
  32. {"Freight Flat"},{"Streak Carriage"},{"Kart"},{"Mower"},{"Duneride"},{"Sweeper"},{"Broadway"},{"Tornado"},{"AT-400"},{"DFT-30"},
  33. {"Huntley"},{"Stafford"},{"BF-400"},{"Newsvan"},{"Tug"},{"Trailer 3"},{"Emperor"},{"Wayfarer"},{"Euros"},{"Hotdog"},{"Club"},
  34. {"Freight Carriage"},{"Trailer 3"},{"Andromada"},{"Dodo"},{"RC Cam"},{"Launch"},{"Police Car (LSPD)"},{"Police Car (SFPD)"},
  35. {"Police Car (LVPD)"},{"Police Ranger"},{"Picador"},{"S.W.A.T. Van"},{"Alpha"},{"Phoenix"},{"Glendale"},{"Sadler"},
  36. {"Luggage Trailer A"},{"Luggage Trailer B"},{"Stair Trailer"},{"Boxville"},{"Farm Plow"},{"Utility Trailer"}
  37. };
  38.  
  39. public OnPlayerConnect(playerid)
  40. {
  41. VeiculoID[playerid] = -1;
  42. return 1;
  43. }
  44.  
  45. public OnPlayerDisconnect(playerid, reason)
  46. {
  47. DestroyVehicle(VeiculoID[playerid]);
  48. VeiculoID[playerid] = -1;
  49. return 1;
  50. }
  51.  
  52. public OnPlayerCommandText(playerid, cmdtext[])
  53. {
  54. new
  55. cmd[128], idx, tmp[128];
  56.  
  57. cmd = strtok(cmdtext, idx);
  58.  
  59. GetPlayerPos(playerid, ppos[0], ppos[1], ppos[2]);
  60.  
  61. if(strcmp(cmd, "/comprarmeucarro", true) == 0 || strcmp(cmd, "/ccarro", true) == 0)
  62. {
  63. tmp = strtok(cmdtext, idx);
  64. if(!strlen(tmp))
  65. {
  66. SendClientMessage(playerid, 0xFF3300AA, "[ERRO] Uso correto: /comprarcarro [id veículo] [cor1] [cor2]");
  67. return 1;
  68. }
  69. new
  70. veiculo = strval(tmp);
  71. if(veiculo < 400 || veiculo > 611)
  72. {
  73. SendClientMessage(playerid, 0xFF3300AA, "[ERRO] Somente veículos entre os ID: 400 á 611");
  74. return 1;
  75. }
  76. tmp = strtok(cmdtext, idx);
  77. if(!strlen(tmp))
  78. {
  79. SendClientMessage(playerid, 0xFF3300AA, "[ERRO] Uso correto: /comprarcarro [id veículo] [cor1] [cor2]");
  80. return 1;
  81. }
  82. new
  83. color1 = strval(tmp);
  84. tmp = strtok(cmdtext, idx);
  85. new
  86. color2 = strval(tmp);
  87. if(!strlen(tmp))
  88. {
  89. SendClientMessage(playerid, 0xFF3300AA, "[ERRO] Uso correto: /comprarcarro [id veículo] [cor1] [cor2]");
  90. return 1;
  91. }
  92. DestroyVehicle(VeiculoID[playerid]);
  93. vModel = CreateVehicle(veiculo, ppos[0], ppos[1], ppos[2], 360, color1, color2, -1);
  94. PutPlayerInVehicle(playerid, vModel, 0);
  95. VeiculoID[playerid] = GetPlayerVehicleID(playerid);
  96. format(gstring, sizeof(gstring), "[INFO] %s id: %d cor1 %d e cor2 %d comprado com sucesso! custo: 300000", Veiculos[GetVehicleModel(vModel)-400], veiculo, color1, color2);
  97. SendClientMessage(playerid, 0xFFFF33AA, gstring);
  98. format(gstring, 256, "{FFFF33}Veículo de {FFFFCC}%s {FFFF33}", PlayerName(playerid));
  99. GivePlayerMoney(playerid,300000);
  100. TextVeH = Create3DTextLabel(gstring, -1, 0.0, 0.0, 0.0, 50.0, 0, 1);
  101. Attach3DTextLabelToVehicle(TextVeH, vModel, 0.0, 0.0, 0.0+1);
  102. return 1;
  103. }
  104. return 0;
  105. }
  106.  
  107. public OnPlayerStateChange(playerid, newstate, oldstate)
  108. {
  109. if(IsPlayerInAnyVehicle(playerid))
  110. {
  111. if(GetPlayerVehicleID(playerid) == VeiculoID[playerid])
  112. {
  113. format(gstring, sizeof(gstring),"[INFO] %s seja bem vindo ao seu veículo.", PlayerName(playerid));
  114. SendClientMessage(playerid, 0x9966FFAA, gstring);
  115. return 1;
  116. }
  117. else if(GetPlayerVehicleID(playerid) != VeiculoID[playerid])
  118. {
  119. format(gstring, sizeof(gstring),"[INFO] Esse veículo pertence à %s e você não pode dirigi-lo! {99FF66}( Compre o seu usando: /comprarcarro )", PlayerName(VeiculoID[playerid]));
  120. SendClientMessage(playerid, 0xFF6633AA, gstring);
  121. PlayerPlaySound(playerid, 1147, 0.0, 0.0, 0.0);
  122. RemovePlayerFromVehicle(playerid);
  123. return 1;
  124. }
  125. }
  126. return 1;
  127. }
  128.  
  129. stock strtok(const string[], &index)
  130. {
  131. new length = strlen(string);
  132. while ((index < length) && (string[index] <= ' '))
  133. {
  134. index++;
  135. }
  136.  
  137. new offset = index;
  138. new result[20];
  139. while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  140. {
  141. result[index - offset] = string[index];
  142. index++;
  143. }
  144. result[index - offset] = EOS;
  145. return result;
  146. }
  147.  
  148. stock GetVehicleModelID(nome[])
  149. {
  150. for(new i = 0; i < 211; ++i)
  151. {
  152. if(strfind(Veiculos[i], nome, true) != -1) return i + 400;
  153. }
  154. return -1;
  155. }
  156.  
  157. stock PlayerName(playerid)
  158. {
  159. new
  160. PvName[MAX_PLAYER_NAME+1]
  161. ;
  162. GetPlayerName(playerid, PvName, sizeof(PvName));
  163. return PvName;
  164. }
Add Comment
Please, Sign In to add comment