Advertisement
Guest User

Xenforox's FS

a guest
Aug 11th, 2014
1,020
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.68 KB | None | 0 0
  1. //****************************************************XENFOROX*************************************************************************//
  2.  
  3. //defines
  4. #define                 MAX_FUELSTATIONS                    5
  5.  
  6. //new vars
  7. new  SpawnedFuels;
  8. new stock PickupsTimer;
  9.  
  10. //forward
  11. forward PickupMessages();
  12.  
  13. //enum
  14. enum FuelStationData
  15. {
  16.     Float:FSX,
  17.     Float:FSY,
  18.     Float:FSZ,
  19.     FSUnitPrice,
  20.     FSPickupID,
  21. };
  22. new Fuels[MAX_FUELSTATIONS][FuelStationData];
  23.  
  24. //timer
  25. PickupsTimer = SetTimer("PickupMsg", 1000, true); //place this under ongamemodeinit.
  26.  
  27. //public
  28. public PickupMsg() //this is for the game playertext
  29. {
  30.     new string[256];
  31.     for(new i = 0; i < MAX_PLAYERS; i++)
  32.     {
  33.          for(new f = 0; f <sizeof(Fuels); f++)
  34.      {
  35.                    new location[MAX_ZONE_NAME];
  36.                if(IsPlayerInRangeOfPoint(i, 3, Fuels[f][FSX], Fuels[f][FSY], Fuels[f][FSZ]))
  37.                        {
  38.                                Get2DZone(location, MAX_ZONE_NAME, Fuels[f][FSX], Fuels[f][FSY], Fuels[f][FSZ]);
  39.                    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]);
  40.                    GameTextForPlayer(i, string, 3500, 3);
  41.                }
  42.          }
  43.     }
  44.     return 1;
  45. }
  46.  
  47. //stocks
  48. SaveFuels();//OnGameModeExit
  49. InitFuels();//OnGameModeInit
  50.  
  51.  
  52. stock InitFuels()
  53. {
  54.     new FileName[128];
  55.     for(new i = 0; i < MAX_FUELSTATIONS; i++)
  56.     {
  57.         format(FileName, sizeof(FileName), "FuelStations/%d.ini", i);
  58.         if(fexist(FileName))
  59.         {
  60.             Fuels[i][FSX] = dini_Float(FileName, "FSX");
  61.             Fuels[i][FSY] = dini_Float(FileName, "FSY");
  62.             Fuels[i][FSZ] = dini_Float(FileName, "FSZ");
  63.             Fuels[i][FSUnitPrice] = dini_Int(FileName, "FSUnitPrice");
  64.             Fuels[i][FSPickupID] = CreateDynamicPickup(1650, 23,  Fuels[i][FSX], Fuels[i][FSY],  Fuels[i][FSZ] + 0.5 ,0, -1, -1, 150.0);
  65.             SpawnedFuels++;
  66.        }
  67.     }
  68.     return 1;
  69. }
  70.  
  71.  
  72. stock SaveFuels()
  73. {
  74.     new FileName[21];
  75.     for(new i = 0; i < MAX_FUELSTATIONS; i++)
  76.     {
  77.         format(FileName, sizeof(FileName), "FuelStations/%d.ini", i);
  78.         if(fexist(FileName))
  79.         {
  80.            
  81.             dini_FloatSet(FileName, "FSX", Fuels[i][FSX]);
  82.             dini_FloatSet(FileName, "FSY", Fuels[i][FSY]);
  83.             dini_FloatSet(FileName, "FSZ", Fuels[i][FSZ]);
  84.             dini_IntSet(FileName,"FSUnitPrice", Fuels[i][FSUnitPrice]);
  85.        }
  86.     }
  87.     return 1;
  88. }
  89.  
  90. //COMMAND
  91.  
  92. CMD:createfuelstation(playerid, params[])
  93. {
  94.     new unit, string[128];
  95.     if(sscanf(params, "d", unit))
  96.     {
  97.         if(PlayerInfo[playerid][pAdmin] >= 5)
  98.         {
  99.             SendClientMessage(playerid, WHITE, "SYNTAX: /createfuelstation [UnitPrice]");
  100.         }
  101.     }
  102.     else
  103.     {
  104.         if(PlayerInfo[playerid][pAdmin] >= 5)
  105.         {
  106.            
  107.                 new id = SpawnedFuels++;
  108.                 format(string, sizeof(string), "FuelStations/%d.ini", id);
  109.                 dini_Create(string);
  110.                 new Float: X, Float: Y, Float: Z;
  111.                 GetPlayerPos(playerid, X, Y, Z);
  112.                 if(fexist(string))
  113.                 {
  114.                    
  115.                     Fuels[id][FSX] = X;
  116.                     Fuels[id][FSY] = Y;
  117.                     Fuels[id][FSZ] = Z ;
  118.                     Fuels[id][FSUnitPrice] = unit;
  119.                     Fuels[id][FSPickupID] = CreateDynamicPickup(1650, 23,  X, Y, Z+1, 0, -1, -1, 150.0);
  120.                     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);
  121.                     SendClientMessage(playerid, WHITE, string);
  122.                 }
  123.                 else
  124.                 {
  125.                     SendClientMessage(playerid, WHITE, "An unexpected error has occured.");
  126.                 }
  127.         }
  128.     }
  129.     return 1;
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement