Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <acuf> //Credits to AirKite (http://forum.sa-mp.com/showthread.php?t=281906)
- #include <zcmd> //Credits to Zeex (http://forum.sa-mp.com/showthread.php?t=91354)
- #define DIALOGID 19000 //change if needed
- #define MAX_COMP 40 //maximum number of available components for a vehicle model; I think 40 is enough
- #define COLOR_RED 0xAA3333AA
- #define COLOR_YELLOW 0xFFFF00AA
- #undef MAX_PLAYERS
- #define MAX_PLAYERS 100 //number of server slots
- new ccount[MAX_PLAYERS];
- new componentsid[MAX_PLAYERS][MAX_COMP];
- public OnFilterScriptInit()
- return print(":: Easy Vehicle Tuning Menu by Riccor Loaded!");
- public OnFilterScriptExit()
- return print(":: Easy Vehicle Tuning Menu Unloaded!");
- CMD:tuneit(playerid, params[])
- {
- if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_RED, "[ERROR:] You must be driving to use this command.");
- new vehiclemodel = GetVehicleModel(GetPlayerVehicleID(playerid));
- if(vehiclemodel < 400 || vehiclemodel > 611) return SendClientMessage(playerid, COLOR_RED, "[ERROR:] You can't tune your current vehicle!");
- new string[2048]; //enough?
- new component;
- ccount[playerid] = 1;
- while(GetVehicleCompatibleUpgrades(vehiclemodel, ccount[playerid], component))
- {
- if(ccount[playerid] <= MAX_COMP)
- {
- if(ccount[playerid] == 1) format(string, sizeof(string), "%s", GetComponentName(component));
- else format(string, sizeof(string), "%s\n%s", string, GetComponentName(component));
- componentsid[playerid][ccount[playerid]-1] = component;
- ccount[playerid]++;
- }
- else break; //in case that MAX_COMP gets passed
- }
- new title[80];
- format(title, sizeof(title), ":: Available Tuning Components for Vehicle Model {FF6400}%d", vehiclemodel);
- ShowPlayerDialog(playerid, DIALOGID, DIALOG_STYLE_LIST, title, string, "Tune it!", "Cancel");
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == DIALOGID) if(response)
- {
- for(new i=0;i<=ccount[playerid];i++)
- {
- if(listitem == i)
- {
- if(IsVehicleUpgradeCompatible(GetVehicleModel(GetPlayerVehicleID(playerid)),componentsid[playerid][i])) //just a verification
- {
- AddVehicleComponent(GetPlayerVehicleID(playerid), componentsid[playerid][i]);
- new string[128];
- format(string, sizeof(string),":: Vehicle successfully tuned with component {FF6400}%s", GetComponentName(componentsid[playerid][i]));
- SendClientMessage(playerid,COLOR_YELLOW,string);
- return cmd_tuneit(playerid, " ");
- }
- else SendClientMessage(playerid,COLOR_RED,"[ERROR:] Component is not compatible with your current vehicle model!");
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment