Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- NOS Gauge v0.1
- Scripted by RIDE2DAY
- Official thread: http://forum.sa-mp.com/showthread.php?t=624827
- */
- #include <a_samp>
- /* =============================== | [MACROS] | ================================ */
- #define BASE_X 620.0
- #define BASE_Y 407.0
- #define GAUGE_MIN_ANG 180.0
- #define GAUGE_MAX_ANG 270.0
- #define GAUGE_RADIO 50.0
- #define MAGIC_NUMBER 0.9
- #define DECREASE_UNITS 1
- #define HOLDING(%0) ((newkeys & (%0)) == (%0))
- #define RELEASED(%0) (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
- /* =============================== | [VARIABLES] | ================================ */
- new Vehicle_NOS[MAX_VEHICLES char];
- new NOS_timer[MAX_PLAYERS] = {-1, ...};
- new Text:NOS_TD[5];
- new Text:NOS_Clock_TD[5];
- new PlayerText:NOS_gauge[MAX_PLAYERS] = {PlayerText:INVALID_TEXT_DRAW, ...};
- new Invalid_NOS_Vehicles[] = {
- /* Air Vehicles */
- 417, 425, 447, 460, 469, 476, 487, 488, 497, 511, 512, 513, 519, 520, 548, 553, 563, 577, 592, 593
- };
- /* =============================== | [CALLBACKS] | ================================ */
- public OnFilterScriptInit()
- {
- for(new v = 0; v < MAX_VEHICLES; v++)
- {
- Vehicle_NOS{v} = 100;
- }
- NOS_TD[0] = TextDrawCreate(BASE_X - 28.0, BASE_Y - 13.0, "N");
- TextDrawBackgroundColor(NOS_TD[0], 255);
- TextDrawFont(NOS_TD[0], 1);
- TextDrawLetterSize(NOS_TD[0], 0.280000, 1.599999);
- TextDrawColor(NOS_TD[0], 8454143);
- TextDrawSetOutline(NOS_TD[0], 1);
- TextDrawSetProportional(NOS_TD[0], 1);
- TextDrawSetSelectable(NOS_TD[0], 0);
- NOS_TD[1] = TextDrawCreate(BASE_X - 18.0, BASE_Y - 10.0, "2");
- TextDrawBackgroundColor(NOS_TD[1], 255);
- TextDrawFont(NOS_TD[1], 1);
- TextDrawLetterSize(NOS_TD[1], 0.210000, 1.199999);
- TextDrawColor(NOS_TD[1], 8454143);
- TextDrawSetOutline(NOS_TD[1], 1);
- TextDrawSetProportional(NOS_TD[1], 1);
- TextDrawSetSelectable(NOS_TD[1], 0);
- NOS_TD[2] = TextDrawCreate(BASE_X - 11.0, BASE_Y - 13.0, "O");
- TextDrawBackgroundColor(NOS_TD[2], 255);
- TextDrawFont(NOS_TD[2], 1);
- TextDrawLetterSize(NOS_TD[2], 0.280000, 1.599999);
- TextDrawColor(NOS_TD[2], 8454143);
- TextDrawSetOutline(NOS_TD[2], 1);
- TextDrawSetProportional(NOS_TD[2], 1);
- TextDrawSetSelectable(NOS_TD[2], 0);
- NOS_Clock_TD[0] = TextDrawCreate(BASE_X - 58.0, BASE_Y + 8.0, "E");
- TextDrawBackgroundColor(NOS_Clock_TD[0], 255);
- TextDrawFont(NOS_Clock_TD[0], 1);
- TextDrawLetterSize(NOS_Clock_TD[0], 0.310000, 0.999999);
- TextDrawColor(NOS_Clock_TD[0], -83928577);
- TextDrawSetOutline(NOS_Clock_TD[0], 1);
- TextDrawSetProportional(NOS_Clock_TD[0], 1);
- TextDrawSetSelectable(NOS_Clock_TD[0], 0);
- NOS_Clock_TD[1] = TextDrawCreate(BASE_X - 46.0, BASE_Y - 33.0, "1/2");
- TextDrawBackgroundColor(NOS_Clock_TD[1], 255);
- TextDrawFont(NOS_Clock_TD[1], 1);
- TextDrawLetterSize(NOS_Clock_TD[1], 0.180000, 0.899999);
- TextDrawColor(NOS_Clock_TD[1], -1);
- TextDrawSetOutline(NOS_Clock_TD[1], 1);
- TextDrawSetProportional(NOS_Clock_TD[1], 1);
- TextDrawSetSelectable(NOS_Clock_TD[1], 0);
- NOS_Clock_TD[2] = TextDrawCreate(BASE_X - 1.0, BASE_Y - 50.0, "F");
- TextDrawBackgroundColor(NOS_Clock_TD[2], 255);
- TextDrawFont(NOS_Clock_TD[2], 1);
- TextDrawLetterSize(NOS_Clock_TD[2], 0.310000, 0.999999);
- TextDrawColor(NOS_Clock_TD[2], 2063555071);
- TextDrawSetOutline(NOS_Clock_TD[2], 1);
- TextDrawSetProportional(NOS_Clock_TD[2], 1);
- TextDrawSetSelectable(NOS_Clock_TD[2], 0);
- NOS_Clock_TD[3] = TextDrawCreate(BASE_X - 51.0, BASE_Y - 13.0, ".");
- TextDrawBackgroundColor(NOS_Clock_TD[3], 255);
- TextDrawFont(NOS_Clock_TD[3], 1);
- TextDrawLetterSize(NOS_Clock_TD[3], 0.180000, 0.899999);
- TextDrawColor(NOS_Clock_TD[3], -1);
- TextDrawSetOutline(NOS_Clock_TD[3], 1);
- TextDrawSetProportional(NOS_Clock_TD[3], 1);
- TextDrawSetSelectable(NOS_Clock_TD[3], 0);
- NOS_Clock_TD[4] = TextDrawCreate(BASE_X - 20.0, BASE_Y - 45.0, ".");
- TextDrawBackgroundColor(NOS_Clock_TD[4], 255);
- TextDrawFont(NOS_Clock_TD[4], 1);
- TextDrawLetterSize(NOS_Clock_TD[4], 0.180000, 0.899999);
- TextDrawColor(NOS_Clock_TD[4], -1);
- TextDrawSetOutline(NOS_Clock_TD[4], 1);
- TextDrawSetProportional(NOS_Clock_TD[4], 1);
- TextDrawSetSelectable(NOS_Clock_TD[4], 0);
- return 1;
- }
- public OnFilterScriptExit()
- {
- for(new x = 0; x < 3; x++)
- {
- TextDrawDestroy(NOS_TD[x]);
- }
- for(new x = 0; x < 5; x++)
- {
- TextDrawDestroy(NOS_Clock_TD[x]);
- }
- for(new p = 0, t = GetPlayerPoolSize(); p <= t; p++)
- {
- if(NOS_gauge[p] != PlayerText:INVALID_TEXT_DRAW)
- {
- PlayerTextDrawDestroy(p, NOS_gauge[p]);
- }
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- NOS_timer[playerid] = -1;
- CreateNOSGaugeForPlayer(playerid, BASE_X, BASE_Y);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if(NOS_timer[playerid] != -1)
- {
- KillTimer(NOS_timer[playerid]);
- NOS_timer[playerid] = -1;
- }
- PlayerTextDrawDestroy(playerid, NOS_gauge[playerid]);
- NOS_gauge[playerid] = PlayerText:INVALID_TEXT_DRAW;
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- if(IsPlayerInAnyVehicle(playerid))
- {
- if(IsValidNOSVehicle(GetPlayerVehicleID(playerid)))
- {
- new Float:NEW_X;
- new Float:NEW_Y;
- new Float:GAUGE_ANGLE;
- GAUGE_ANGLE = GAUGE_MIN_ANG + float(Vehicle_NOS{GetPlayerVehicleID(playerid) - 1}) * MAGIC_NUMBER;
- NEW_X = BASE_X + floatcos(GAUGE_ANGLE, degrees) * GAUGE_RADIO;
- NEW_Y = BASE_Y + floatsin(GAUGE_ANGLE, degrees) * GAUGE_RADIO;
- PlayerTextDrawDestroy(playerid, NOS_gauge[playerid]);
- CreateNOSGaugeForPlayer(playerid, NEW_X, NEW_Y);
- PlayerTextDrawShow(playerid, NOS_gauge[playerid]);
- }
- }
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if((newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER) && IsValidNOSVehicle(GetPlayerVehicleID(playerid)))
- {
- for(new x = 0; x < 3; x++)
- {
- TextDrawShowForPlayer(playerid, NOS_TD[x]);
- }
- for(new x = 0; x < 5; x++)
- {
- TextDrawShowForPlayer(playerid, NOS_Clock_TD[x]);
- }
- PlayerTextDrawShow(playerid, NOS_gauge[playerid]);
- }
- if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
- {
- if(NOS_timer[playerid] != -1)
- {
- KillTimer(NOS_timer[playerid]);
- NOS_timer[playerid] = -1;
- }
- for(new x = 0; x < 3; x++)
- {
- TextDrawHideForPlayer(playerid, NOS_TD[x]);
- }
- for(new x = 0; x < 5; x++)
- {
- TextDrawHideForPlayer(playerid, NOS_Clock_TD[x]);
- }
- PlayerTextDrawHide(playerid, NOS_gauge[playerid]);
- }
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(HOLDING(KEY_FIRE))
- {
- new v_id = GetPlayerVehicleID(playerid);
- if(v_id != 0 && Vehicle_NOS{v_id - 1} > 0 && NOS_timer[playerid] == -1 && GetPlayerState(playerid) == PLAYER_STATE_DRIVER && IsValidNOSVehicle(v_id))
- {
- AddVehicleComponent(v_id, 1010);
- NOS_timer[playerid] = SetTimerEx("DecreaseVehicleNOS", 70, true, "dd", playerid, v_id);
- }
- }
- if(RELEASED(KEY_FIRE))
- {
- if(NOS_timer[playerid] != -1)
- {
- KillTimer(NOS_timer[playerid]);
- NOS_timer[playerid] = -1;
- RemoveVehicleComponent(GetPlayerVehicleID(playerid), 1010);
- }
- }
- return 1;
- }
- forward DecreaseVehicleNOS(playerid, vehicleid);
- public DecreaseVehicleNOS(playerid, vehicleid)
- {
- Vehicle_NOS{vehicleid - 1} -= DECREASE_UNITS;
- if(Vehicle_NOS{vehicleid - 1} <= 0)
- {
- KillTimer(NOS_timer[playerid]);
- NOS_timer[playerid] = -1;
- RemoveVehicleComponent(vehicleid, 1010);
- }
- return 1;
- }
- /* =============================== | [FUNCTIONS] | ================================ */
- CreateNOSGaugeForPlayer(playerid, Float:x, Float:y)
- {
- NOS_gauge[playerid] = CreatePlayerTextDraw(playerid, x, y, ".");
- PlayerTextDrawBackgroundColor(playerid,NOS_gauge[playerid], 255);
- PlayerTextDrawFont(playerid,NOS_gauge[playerid], 1);
- PlayerTextDrawLetterSize(playerid,NOS_gauge[playerid], 0.500000, 2.000000);
- PlayerTextDrawColor(playerid,NOS_gauge[playerid], -1);
- PlayerTextDrawSetOutline(playerid,NOS_gauge[playerid], 1);
- PlayerTextDrawSetProportional(playerid,NOS_gauge[playerid], 1);
- PlayerTextDrawSetSelectable(playerid,NOS_gauge[playerid], 0);
- }
- IsValidNOSVehicle(vehicleid)
- {
- new modelid = GetVehicleModel(vehicleid);
- for(new x = 0; x < sizeof(Invalid_NOS_Vehicles); x++)
- {
- if(modelid == Invalid_NOS_Vehicles[x])
- {
- return 0;
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment