Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //****************************************************XENFOROX*************************************************************************//
- //defines
- #define MAX_FUELSTATIONS 5
- //new vars
- new SpawnedFuels;
- new stock PickupsTimer;
- //forward
- forward PickupMessages();
- //enum
- enum FuelStationData
- {
- Float:FSX,
- Float:FSY,
- Float:FSZ,
- FSUnitPrice,
- FSPickupID,
- };
- new Fuels[MAX_FUELSTATIONS][FuelStationData];
- //timer
- PickupsTimer = SetTimer("PickupMsg", 1000, true); //place this under ongamemodeinit.
- //public
- public PickupMsg() //this is for the game playertext
- {
- new string[256];
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- for(new f = 0; f <sizeof(Fuels); f++)
- {
- new location[MAX_ZONE_NAME];
- if(IsPlayerInRangeOfPoint(i, 3, Fuels[f][FSX], Fuels[f][FSY], Fuels[f][FSZ]))
- {
- Get2DZone(location, MAX_ZONE_NAME, Fuels[f][FSX], Fuels[f][FSY], Fuels[f][FSZ]);
- format(string, sizeof(string), "~r~%s's ~w~Fuel Station ~n~ ~w~Price Per Unit: ~y~ %d ~n~ ~y~ /refuel ~w~ or ~y~ /refillgascan", location,Fuels[f][FSUnitPrice]);
- GameTextForPlayer(i, string, 3500, 3);
- }
- }
- }
- return 1;
- }
- //stocks
- SaveFuels();//OnGameModeExit
- InitFuels();//OnGameModeInit
- stock InitFuels()
- {
- new FileName[128];
- for(new i = 0; i < MAX_FUELSTATIONS; i++)
- {
- format(FileName, sizeof(FileName), "FuelStations/%d.ini", i);
- if(fexist(FileName))
- {
- Fuels[i][FSX] = dini_Float(FileName, "FSX");
- Fuels[i][FSY] = dini_Float(FileName, "FSY");
- Fuels[i][FSZ] = dini_Float(FileName, "FSZ");
- Fuels[i][FSUnitPrice] = dini_Int(FileName, "FSUnitPrice");
- Fuels[i][FSPickupID] = CreateDynamicPickup(1650, 23, Fuels[i][FSX], Fuels[i][FSY], Fuels[i][FSZ] + 0.5 ,0, -1, -1, 150.0);
- SpawnedFuels++;
- }
- }
- return 1;
- }
- stock SaveFuels()
- {
- new FileName[21];
- for(new i = 0; i < MAX_FUELSTATIONS; i++)
- {
- format(FileName, sizeof(FileName), "FuelStations/%d.ini", i);
- if(fexist(FileName))
- {
- dini_FloatSet(FileName, "FSX", Fuels[i][FSX]);
- dini_FloatSet(FileName, "FSY", Fuels[i][FSY]);
- dini_FloatSet(FileName, "FSZ", Fuels[i][FSZ]);
- dini_IntSet(FileName,"FSUnitPrice", Fuels[i][FSUnitPrice]);
- }
- }
- return 1;
- }
- //COMMAND
- CMD:createfuelstation(playerid, params[])
- {
- new unit, string[128];
- if(sscanf(params, "d", unit))
- {
- if(PlayerInfo[playerid][pAdmin] >= 5)
- {
- SendClientMessage(playerid, WHITE, "SYNTAX: /createfuelstation [UnitPrice]");
- }
- }
- else
- {
- if(PlayerInfo[playerid][pAdmin] >= 5)
- {
- new id = SpawnedFuels++;
- format(string, sizeof(string), "FuelStations/%d.ini", id);
- dini_Create(string);
- new Float: X, Float: Y, Float: Z;
- GetPlayerPos(playerid, X, Y, Z);
- if(fexist(string))
- {
- Fuels[id][FSX] = X;
- Fuels[id][FSY] = Y;
- Fuels[id][FSZ] = Z ;
- Fuels[id][FSUnitPrice] = unit;
- Fuels[id][FSPickupID] = CreateDynamicPickup(1650, 23, X, Y, Z+1, 0, -1, -1, 150.0);
- format(string, sizeof(string), "You have created a fuel station(ID: %d) and set the unit price to %d (X = %f | Y = %f | Z = %f).",id, unit, X, Y, Z);
- SendClientMessage(playerid, WHITE, string);
- }
- else
- {
- SendClientMessage(playerid, WHITE, "An unexpected error has occured.");
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement