Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*******************************************************************************
- * *
- * #Nome script: Fuel System *
- * #Versione script: 0.1 *
- * #Autore script: ~Peppinux AKA Peppe_Stasu *
- * #Ringraziamenti: *
- * Francesco_Ronaldo - Idea script *
- * Los Angeles RolePlay - Coordinate rifornimenti *
- * *
- * # Vietato rimuovere i crediti. # *
- * *
- *******************************************************************************/
- //******************************************************************************
- #include <a_samp>
- //******************************************************************************
- forward scaloBenzina(vehicleid);
- //==============================================================================
- new
- vFuel[MAX_VEHICLES],
- pFuelTimer[MAX_PLAYERS];
- //******************************************************************************
- public OnFilterScriptInit()
- {
- print("\n================================"),
- print("| Fuel System v0.1 |"),
- print("| By ~Peppinux AKA Peppe_Stasu |"),
- print("| Caricato con successo! |"),
- print("================================\n");
- for(new i = 1; i < MAX_VEHICLES; i++) vFuel[i] = 100;
- return 1;
- }
- //==============================================================================
- public OnFilterScriptExit()
- {
- print("\n================================"),
- print("| Fuel System v0.1 |"),
- print("| By ~Peppinux AKA Peppe_Stasu |"),
- print("| Rimosso con successo! |"),
- print("================================\n");
- return 1;
- }
- //==============================================================================
- public OnPlayerDisconnect(playerid, reason)
- {
- if(IsPlayerInAnyVehicle(playerid)) KillTimer(pFuelTimer[playerid]);
- return 1;
- }
- //==============================================================================
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new
- cmd[256],
- idx;
- cmd = strtok(cmdtext, idx);
- if(!strcmp(cmdtext, "/serbatoio", true))
- {
- if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "{F60000}ERRORE: {AFAFAF}Devi essere in un veicolo.");
- new string[128];
- format(string, 128, "{00FF00}INFO: {AFAFAF}Benzina attualmente presente nel sebratoio: %d.", vFuel[GetPlayerVehicleID(playerid)]),
- SendClientMessage(playerid, -1, string),
- SendClientMessage(playerid, -1, "{00FF00}INFO: {AFAFAF}Se hai bisogno di rifornire la tua auto di carburante digita i comandi /pieno o /benzina ad un rifornimento.");
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i) && (GetPlayerVehicleID(i) == GetPlayerVehicleID(playerid)))
- {
- new pName[24];
- GetPlayerName(playerid, pName, 24),
- format(string, 128, "* %s guarda l'indicatore di benzina dell'auto. *", pName),
- SendClientMessage(i, 0x00FF00FF, string);
- }
- }
- return 1;
- }
- if(!strcmp(cmdtext, "/pieno", true))
- {
- if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "{F60000}ERRORE: {AFAFAF}Devi essere in un veicolo.");
- if(!isAtGasStation(playerid)) return SendClientMessage(playerid, -1, "{F60000}ERRORE: {AFAFAF}Devi essere ad un rifornimento.");
- new
- string[128],
- soldiIndispensabili = (100 - vFuel[GetPlayerVehicleID(playerid)]) * 2;
- if(GetPlayerMoney(playerid) < soldiIndispensabili)
- {
- format(string, 128, "{F60000}ERRORE: {AFAFAF}Servono $%d per fare il pieno alla tua auto attualmente.", soldiIndispensabili),
- SendClientMessage(playerid, -1, string);
- return 1;
- }
- vFuel[GetPlayerVehicleID(playerid)] = 100,
- GivePlayerMoney(playerid, -soldiIndispensabili),
- format(string, 128, "{00FF00}INFO: {AFAFAF}Hai fatto il pieno alla tua auto per $%d. Ricorda che per controllare la tua benzina puoi digitare /serbatoio", soldiIndispensabili),
- SendClientMessage(playerid, -1, string);
- return 1;
- }
- if(!strcmp(cmd, "/benzina", true))
- {
- if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "{F60000}ERRORE: {AFAFAF}Devi essere in un veicolo.");
- if(!isAtGasStation(playerid)) return SendClientMessage(playerid, -1, "{F60000}ERRORE: {AFAFAF}Devi essere ad un rifornimento.");
- new
- tmp[256],
- ammontare;
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp)) return SendClientMessage(playerid, -1, "{F6D500}USO: {AFAFAF}/benzina [Ammontare]. Usa /pieno se vuoi fare direttamente il pieno.");
- ammontare = strval(tmp);
- if(ammontare > 100 - vFuel[GetPlayerVehicleID(playerid)]) return SendClientMessage(playerid, -1, "{F60000}ERRORE: {AFAFAF}Devi inserire un numero minore della differenza tra 100 e la benzina attuale del veicolo.");
- new
- string[128],
- soldiIndispensabili = ammontare * 2;
- if(GetPlayerMoney(playerid) < soldiIndispensabili)
- {
- format(string, 128, "{F60000}ERRORE: {AFAFAF}Per rifornire il tuo veicolo del %d%% di benzina hai bisogno di $%d.", ammontare, soldiIndispensabili),
- SendClientMessage(playerid, -1, string);
- return 1;
- }
- vFuel[GetPlayerVehicleID(playerid)] += ammontare;
- GivePlayerMoney(playerid, -soldiIndispensabili);
- format(string, 128, "{00FF00}INFO: {AFAFAF}Hai aggiunto il %d%% di benzina per $%d.", ammontare, soldiIndispensabili),
- SendClientMessage(playerid, -1, string);
- return 1;
- }
- return 0;
- }
- //==============================================================================
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if(newstate == PLAYER_STATE_DRIVER) pFuelTimer[playerid] = SetTimerEx("scaloBenzina", 20*1000/*20 sec*/, true, "d", GetPlayerVehicleID(playerid));
- else if(newstate == PLAYER_STATE_PASSENGER) KillTimer(pFuelTimer[playerid]);
- return 1;
- }
- //******************************************************************************
- stock strtok(const string[], &index)
- {
- new length = strlen(string);
- while((index < length) && (string[index] <= ' ')) index++;
- new
- offset = index,
- result[20];
- while((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
- {
- result[index - offset] = string[index];
- index++;
- }
- result[index - offset] = EOS;
- return result;
- }
- //==============================================================================
- isAtGasStation(playerid)
- {
- if(IsPlayerInRangeOfPoint(playerid, 10.0, 1004.0070, -939.3102, 42.1797) || IsPlayerInRangeOfPoint(playerid, 10.0, 1944.3260, -1772.9254, 13.3906) || IsPlayerInRangeOfPoint(playerid, 10.0, -90.5515, -1169.4578, 2.4079) || IsPlayerInRangeOfPoint(playerid, 10.0, -1609.7958, -2718.2048, 48.5391)
- || IsPlayerInRangeOfPoint(playerid, 10.0, -2029.4968, 156.4366, 28.9498) || IsPlayerInRangeOfPoint(playerid, 10.0, -2408.7590, 976.0934, 45.4175) || IsPlayerInRangeOfPoint(playerid, 10.0, -2243.9629, -2560.6477, 31.8841) || IsPlayerInRangeOfPoint(playerid, 10.0, -1676.6323, 414.0262, 6.9484)
- || IsPlayerInRangeOfPoint(playerid, 10.0, 2202.2349, 2474.3494, 10.5258) || IsPlayerInRangeOfPoint(playerid, 10.0, 614.9333, 1689.7418, 6.6968) || IsPlayerInRangeOfPoint(playerid, 10.0, -1328.8250, 2677.2173, 49.7665) || IsPlayerInRangeOfPoint(playerid, 10.0, 70.3882, 1218.6783, 18.5165)
- || IsPlayerInRangeOfPoint(playerid, 10.0, 2113.7390, 920.1079, 10.5255) || IsPlayerInRangeOfPoint(playerid, 10.0, -1327.7218, 2678.8723, 50.0625) || IsPlayerInRangeOfPoint(playerid, 10.0, 656.4265, -559.8610, 16.5015) || IsPlayerInRangeOfPoint(playerid, 10.0, 656.3797, -570.4138, 16.5015))
- return 1; // Coordinate by Los Angeles RolePlay
- return 0;
- }
- //==============================================================================
- getVehicleDriver(vehicleid)
- {
- for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && IsPlayerInVehicle(i, vehicleid) && GetPlayerState(i) == PLAYER_STATE_DRIVER) return i;
- return -1;
- }
- //==============================================================================
- public scaloBenzina(vehicleid)
- {
- if(vFuel[vehicleid] > 0) vFuel[vehicleid]--;
- switch(vFuel[vehicleid])
- {
- case 30: SendClientMessage(getVehicleDriver(vehicleid), -1, "{F60000}ATTENZIONE: {AFAFAF}La percentuale di benzina del tuo veicolo è pari al 30%%. Ti consigliamo di fare il /pieno.");
- case 20: SendClientMessage(getVehicleDriver(vehicleid), -1, "{F60000}ATTENZIONE: {AFAFAF}La percentuale di benzina del tuo veicolo è pari al 20%%. Ti consigliamo di fare il /pieno.");
- case 10: SendClientMessage(getVehicleDriver(vehicleid), -1, "{F60000}ATTENZIONE: {AFAFAF}La percentuale di benzina del tuo veicolo è pari al 10%%. Fai il /pieno o rimarrai a piedi!");
- case 5: SendClientMessage(getVehicleDriver(vehicleid), -1, "{F60000}ATTENZIONE: {AFAFAF}La percentuale di benzina del tuo veicolo è pari al 5%%. Fai subito il /pieno o resterai a piedi.");
- }
- }
- //******************************************************************************
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement