Guest User

Easy Vehicle Tuning Menu

a guest
Nov 17th, 2011
1,715
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. #include <a_samp>
  2. #include <acuf> //Credits to AirKite (http://forum.sa-mp.com/showthread.php?t=281906)
  3. #include <zcmd> //Credits to Zeex (http://forum.sa-mp.com/showthread.php?t=91354)
  4. #define DIALOGID 19000 //change if needed
  5. #define MAX_COMP 40 //maximum number of available components for a vehicle model; I think 40 is enough
  6. #define COLOR_RED 0xAA3333AA
  7. #define COLOR_YELLOW 0xFFFF00AA
  8. #undef MAX_PLAYERS
  9. #define MAX_PLAYERS 100 //number of server slots
  10.  
  11. new ccount[MAX_PLAYERS];
  12. new componentsid[MAX_PLAYERS][MAX_COMP];
  13.  
  14. public OnFilterScriptInit()
  15. return print(":: Easy Vehicle Tuning Menu by Riccor Loaded!");
  16.  
  17. public OnFilterScriptExit()
  18. return print(":: Easy Vehicle Tuning Menu Unloaded!");
  19.  
  20. CMD:tuneit(playerid, params[])
  21. {
  22. if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_RED, "[ERROR:] You must be driving to use this command.");
  23. new vehiclemodel = GetVehicleModel(GetPlayerVehicleID(playerid));
  24. if(vehiclemodel < 400 || vehiclemodel > 611) return SendClientMessage(playerid, COLOR_RED, "[ERROR:] You can't tune your current vehicle!");
  25. new string[2048]; //enough?
  26. new component;
  27. ccount[playerid] = 1;
  28. while(GetVehicleCompatibleUpgrades(vehiclemodel, ccount[playerid], component))
  29. {
  30. if(ccount[playerid] <= MAX_COMP)
  31. {
  32. if(ccount[playerid] == 1) format(string, sizeof(string), "%s", GetComponentName(component));
  33. else format(string, sizeof(string), "%s\n%s", string, GetComponentName(component));
  34. componentsid[playerid][ccount[playerid]-1] = component;
  35. ccount[playerid]++;
  36. }
  37. else break; //in case that MAX_COMP gets passed
  38. }
  39. new title[80];
  40. format(title, sizeof(title), ":: Available Tuning Components for Vehicle Model {FF6400}%d", vehiclemodel);
  41. ShowPlayerDialog(playerid, DIALOGID, DIALOG_STYLE_LIST, title, string, "Tune it!", "Cancel");
  42. return 1;
  43. }
  44.  
  45. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  46. {
  47. if(dialogid == DIALOGID) if(response)
  48. {
  49. for(new i=0;i<=ccount[playerid];i++)
  50. {
  51. if(listitem == i)
  52. {
  53. if(IsVehicleUpgradeCompatible(GetVehicleModel(GetPlayerVehicleID(playerid)),componentsid[playerid][i])) //just a verification
  54. {
  55. AddVehicleComponent(GetPlayerVehicleID(playerid), componentsid[playerid][i]);
  56. new string[128];
  57. format(string, sizeof(string),":: Vehicle successfully tuned with component {FF6400}%s", GetComponentName(componentsid[playerid][i]));
  58. SendClientMessage(playerid,COLOR_YELLOW,string);
  59. return cmd_tuneit(playerid, " ");
  60. }
  61. else SendClientMessage(playerid,COLOR_RED,"[ERROR:] Component is not compatible with your current vehicle model!");
  62. }
  63. }
  64. }
  65. return 0;
  66. }
  67.  
Advertisement
Add Comment
Please, Sign In to add comment