Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Script Type: Filterscript
- Script Name: Nitro Bar Filterscript (ProgressBar Version)
- Script Version: V1.0 (Initial Release)
- Script Author: SpiritEvil
- ++++++++ | Cahgnge Log | +++++++++
- + +
- + *V1.0 Initial Release +
- + +
- + +
- + +
- + +
- + +
- + +
- ++++++++++++++++++++++++++++++++++
- */
- #define FILTERSCRIPT
- #include <a_samp>
- #include <progress>
- new Bar:NitroBar[MAX_PLAYERS] = {INVALID_BAR_ID, ...};
- new Text:NitroLabel;
- new timer1;
- new timer2;
- forward NitroBarUpdate(playerid);
- forward NosUpdate(playerid);
- #define COL_RED 0xFF0000FF
- #define COL_GREEN 0x00FF44FF
- #define COL_YELLOW 0xFFFF00FF
- //==============================================================================
- // Customization
- //==============================================================================
- #define NosConsumSpeed 2 // Increase to loose Nitro faster or decrase to loose it slower (the number must NOT contain period or comma).
- #define NitroBarColor 1340286975 // Change this to the color of progressbar you want to use (you can also put hex numbers e.g. 0xFF0000FF).
- #define NOS_DIALOG 1596 // The nitro purchase dialog ID (list style)
- #define NOS_INPUT 1597 // The custom Nitro purchase dialog ID (input style)
- #undef MAX_PLAYERS
- #define MAX_PLAYERS 100 // Change to the maximum players of your server
- //==============================================================================
- public OnFilterScriptInit()
- {
- print("\n======================================");
- print(" Nitro Bar by SpiritEvil loaded!");
- print("======================================\n");
- timer2 = SetTimer("NitroBarUpdate", 100, true);
- return 1;
- }
- public NitroBarUpdate(playerid)
- {
- new Float:nitro = GetPVarInt(playerid, "Nitro");
- if(NitroBar[playerid] != INVALID_BAR_ID)
- {
- SetProgressBarValue(NitroBar[playerid], nitro);
- if(IsPlayerInAnyVehicle(playerid)) UpdateProgressBar(NitroBar[playerid], playerid);
- }
- return 1;
- }
- public OnFilterScriptExit()
- {
- for(new playerid = 0; playerid < MAX_PLAYERS; playerid ++)
- {
- TextDrawDestroy(NitroLabel);
- DestroyProgressBar(NitroBar[playerid]);
- KillTimer(timer2);
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- SetPVarInt(playerid, "Nitro", 100);
- NitroLabel = TextDrawCreate(32.000000, 301.000000, "Nitro:");
- TextDrawBackgroundColor(NitroLabel, 255);
- TextDrawFont(NitroLabel, 2);
- TextDrawLetterSize(NitroLabel, 0.350000, 1.200000);
- TextDrawColor(NitroLabel, 16777215);
- TextDrawSetOutline(NitroLabel, 1);
- TextDrawSetProportional(NitroLabel, 1);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/buynos", cmdtext, true, 10) == 0)
- {
- ShowPlayerDialog(playerid, NOS_DIALOG, DIALOG_STYLE_LIST, "SpiritEvil's Nitro system - Purchase Nitro", "Full Nitro\t{23C910}$500\n{FFFFFF}Half Nitro\t{23C910}$250\n{FFFFFF}Quarter Nitro\t{23C910}$125\n{F2EE0C}Custom Amount\n{FF0000}Empty Bar", "Purchase", "Cancel");
- return 1;
- }
- return 0;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if(newstate == PLAYER_STATE_DRIVER)
- {
- if(CanUseNitro(GetPlayerVehicleID(playerid)))
- {
- NitroBar[playerid] = CreateProgressBar(33.00, 316.00, 115.50, 18.20, NitroBarColor, 100.0);
- TextDrawShowForPlayer(playerid, NitroLabel);
- }
- }
- else if(oldstate == PLAYER_STATE_DRIVER)
- {
- if(NitroBar[playerid] != INVALID_BAR_ID)
- {
- DestroyProgressBar(NitroBar[playerid]);
- NitroBar[playerid] = INVALID_BAR_ID;
- TextDrawHideForPlayer(playerid, NitroLabel);
- }
- }
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerEnterRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnRconCommand(cmd[])
- {
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- return 1;
- }
- public OnPlayerObjectMoved(playerid, objectid)
- {
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- return 1;
- }
- public OnVehicleMod(playerid, vehicleid, componentid)
- {
- return 1;
- }
- public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
- {
- return 1;
- }
- public OnVehicleRespray(playerid, vehicleid, color1, color2)
- {
- return 1;
- }
- public OnPlayerSelectedMenuRow(playerid, row)
- {
- return 1;
- }
- public OnPlayerExitedMenu(playerid)
- {
- return 1;
- }
- public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
- {
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- new Nitro = GetPVarInt(playerid, "Nitro");
- if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER || !CanUseNitro(GetPlayerVehicleID(playerid))) return false;
- else if ((((newkeys & (4)) == (4)) && ((oldkeys & (4)) != (4))))
- {
- if(Nitro > 0)
- {
- AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
- timer1 = SetTimerEx("NosUpdate", 100, true, "d", playerid);
- }
- }
- else if ((((newkeys & (4)) != (4)) && ((oldkeys & (4)) == (4))))
- {
- RemoveVehicleComponent(GetPlayerVehicleID(playerid), 1010);
- KillTimer(timer1);
- SetPVarInt(playerid, "Nitro", Nitro);
- }
- return 1;
- }
- public NosUpdate(playerid)
- {
- new Nitro = GetPVarInt(playerid, "Nitro");
- if(Nitro > 0)
- {
- Nitro -= NosConsumSpeed;
- SetPVarInt(playerid, "Nitro", Nitro);
- }
- else if(Nitro <= 0)
- {
- Nitro = 0;
- SetPVarInt(playerid, "Nitro", Nitro);
- RemoveVehicleComponent(GetPlayerVehicleID(playerid), 1010);
- }
- return 1;
- }
- public OnRconLoginAttempt(ip[], password[], success)
- {
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- return 1;
- }
- public OnPlayerStreamIn(playerid, forplayerid)
- {
- return 1;
- }
- public OnPlayerStreamOut(playerid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamIn(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamOut(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- new Nitro = GetPVarInt(playerid, "Nitro");
- if(response)
- {
- if(dialogid == NOS_DIALOG)
- {
- switch(listitem)
- {
- case 0: {
- if(GetPlayerMoney(playerid) < 500)
- {
- SendClientMessage(playerid, COL_RED, ">> You need at least $500 in order to buy this item! <<");
- return ReturnDialog(playerid, NOS_DIALOG);
- }
- SetPVarInt(playerid, "Nitro", 100);
- SendClientMessage(playerid, COL_GREEN, ">> Full Nitro purchased! <<");
- GivePlayerMoney(playerid, -500);
- }
- case 1: {
- if(GetPlayerMoney(playerid) < 250)
- {
- SendClientMessage(playerid, COL_RED, ">> You need at least $250 in order to buy this item! <<");
- return ReturnDialog(playerid, NOS_DIALOG);
- }
- Nitro += 50;
- if(Nitro > 100) Nitro = 100;
- SetPVarInt(playerid, "Nitro", Nitro);
- SendClientMessage(playerid, COL_GREEN, ">> Half Nitro purchased! <<");
- GivePlayerMoney(playerid, -250);
- }
- case 2: {
- if(GetPlayerMoney(playerid) < 125)
- {
- SendClientMessage(playerid, COL_RED, ">> You need at least $120 in order to buy this item! <<");
- return ReturnDialog(playerid, NOS_DIALOG);
- }
- Nitro += 25;
- if(Nitro > 100) Nitro = 100;
- SetPVarInt(playerid, "Nitro", Nitro);
- SendClientMessage(playerid, COL_GREEN, ">> Quarter Nitro purchased! <<");
- GivePlayerMoney(playerid, -125);
- }
- case 3: {
- new str[250];
- format(str, sizeof(str), "Enter the percentage of nitro you would like to purchase.\n");
- format(str, sizeof(str), "%s1 %% = $5\n",str);
- format(str, sizeof(str), "%sYou currently have %i %% of Nitro.",str, Nitro);
- ShowPlayerDialog(playerid, NOS_INPUT, DIALOG_STYLE_INPUT, "SpiritEvil's Nitro system - Purchase Nitro", str, "Purchase", "Cancel");
- }
- case 4: {
- SetPVarInt(playerid, "Nitro", 0);
- SendClientMessage(playerid, COL_YELLOW, ">> Nitro Bar is now empty! <<");
- }
- }
- }
- else if(dialogid == NOS_INPUT)
- {
- if(!IsNumeric(inputtext))
- {
- SendClientMessage(playerid, COL_RED, ">> Nitro Amount must be number! <<");
- return ReturnDialog(playerid, NOS_INPUT);
- }
- if(strval(inputtext) < 0 || strval(inputtext) > 100)
- {
- SendClientMessage(playerid, COL_RED, ">> The amount of Nitro must be between 0 and 100! <<");
- return ReturnDialog(playerid, NOS_INPUT);
- }
- if(strval(inputtext) + Nitro > 100 || strval(inputtext) + Nitro < 0)
- {
- SendClientMessage(playerid, COL_RED, ">> Invalud Nitro amount! <<");
- return ReturnDialog(playerid, NOS_INPUT);
- }
- new MoneyVal = strval(inputtext) * 5;
- new str[128];
- if(GetPlayerMoney(playerid) < MoneyVal)
- {
- format(str, sizeof(str), ">> You need $%i in order to buy %i Percent Nitro! <<", MoneyVal, strval(inputtext));
- SendClientMessage(playerid, COL_RED, str);
- return ReturnDialog(playerid, NOS_INPUT);
- }
- Nitro += strval(inputtext);
- SetPVarInt(playerid, "Nitro", Nitro);
- GivePlayerMoney(playerid, -MoneyVal);
- format(str, sizeof(str), ">> You purchased %i Percent Nitro for $%i! <<",strval(inputtext), MoneyVal);
- SendClientMessage(playerid, COL_GREEN, str);
- }
- }
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
- //==============================================================================
- // Stocks
- //==============================================================================
- stock CanUseNitro(vehid)
- {
- new vehmodel = GetVehicleModel(vehid);
- switch(vehmodel)
- {
- case 522, 481, 441, 468, 448, 446, 513, 521, 510, 430, 520, 476, 463, 509, 462, 581, 461, 523, 586, 471, 472, 473, 493, 595, 484, 453, 452, 454: return false;
- }
- return true;
- }
- stock IsNumeric(string[]) // Not by me :P
- {
- for(new i = 0; i < strlen(string); i++) if(string[i] > '9' || string[i] < '0') return false;
- return true;
- }
- stock ReturnDialog(playerid, dialogid)
- {
- new Nitro = GetPVarInt(playerid, "Nitro");
- switch(dialogid)
- {
- case NOS_DIALOG:
- {
- ShowPlayerDialog(playerid, NOS_DIALOG, DIALOG_STYLE_LIST, "SpiritEvil's Nitro system - Purchase Nitro", "Full Nitro\t{23C910}$500\n{FFFFFF}Half Nitro\t{23C910}$250\n{FFFFFF}Quarter Nitro\t{23C910}$125\n{F2EE0C}Custom Amount\n{FF0000}Empty Bar", "Purchase", "Cancel");
- }
- case NOS_INPUT:
- {
- new str[250];
- format(str, sizeof(str), "Enter the percentage of nitro you would like to purchase.\n");
- format(str, sizeof(str), "%s1%% = $5\n",str);
- format(str, sizeof(str), "%sYou currently have %i%% of Nitro.",str, Nitro);
- ShowPlayerDialog(playerid, NOS_INPUT, DIALOG_STYLE_INPUT, "SpiritEvil's Nitro system - Purchase Nitro", str, "Purchase", "Cancel");
- }
- }
- return 1;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- // ~| THE END |~
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////All Rights Reserved ©///////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement