All pastes #183930 Raw Edit

Untitled

public text v1 · immutable
#183930 ·published 2006-09-27 11:21 UTC
rendered paste body
//------------------------------------------------------------------------------
// THOM'S SERVER
//
// This gamemode is created by SA-MP Script Maker 0.1
//------------------------------------------------------------------------------
#include <a_samp>

#define TEAM_1 1
#define TEAM_2 2
#define TEAM_3 3
#define TEAM_1_COLOR 0x00FF00AA // Bright Green (in RGBA format)
#define TEAM_2_COLOR 0xFF00FFAA // Bright Purple
#define TEAM_3_COLOR 0x0000A0FF // Blue
//Colours (Relevant code!)
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
//Fuel (Relevant code!)
#define TIME 3000
#define AMOUNT 100
//Gas stations (Relevant code!)
#define CP_STATION1   0
#define CP_STATION2   1
#define CP_STATION3   2
#define CP_STATION4   3
#define CP_STATION5   4
#define CP_STATION6   5
#define CP_STATION7   6
#define CP_STATION8   7
#define CP_STATION9   8
#define CP_STATION10  9
#define CP_STATION11  10
#define CP_STATION12  11
#define CP_STATION13  12
#define CP_STATION14  13
#define CP_STATION15  14
#define CP_STATION16  15


#define MAX_POINTS 16 //(Relevant code!)

new gTeam[MAX_PLAYERS];
//Checkpoint vars (Relevant code!)
new playerCheckpoint[MAX_PLAYERS];

//Fuel vars (Relevant code!)
#define MAX_CARS 46 //make sure to change this to your vehicle count
new Petrol[MAX_CARS];

new Float:checkCoords[MAX_POINTS][4] = {
{2098.1316,901.7380,2137.7456,963.0146},
{2617.5967,1062.8710,2656.6526,1142.5109},
{501.7475,1626.7821,653.2095,1774.1093},
{-1351.2833,2638.8943,-1265.1661,2738.6450},
{-2450.3767,949.5080,-2400.8530,1069.8329},
{-1715.5112,349.5567,-1658.8451,458.3686},
{-2265.3027,-2586.3762,-2219.1868,-2558.2539},
{-1657.4102,-2763.3518,-1501.5303,-2666.7454},
{1903.7450,-1795.7990,1955.5667,-1759.5187},
{-135.2077,-1199.8291,-43.7008,-1134.7999},
{1336.7378,454.7961,1430.0760,483.9776},
{648.2494,-592.9003,670.9278,-540.8264},
{-1494.2593,1854.1290,-1449.4076,1885.2032},
{2097.0452,2708.1218,2172.7161,2762.7495},
{2187.6587,2462.8057,2215.5042,2495.0332},
{1577.7729,2182.5112,1616.5842,2242.3628}
};
new Float:checkpoints[MAX_POINTS][4] = {
{2109.2126,917.5845,10.8203,5.0},
{2640.1831,1103.9224,10.8203,5.0},
{611.8934,1694.7921,6.7193,5.0},
{-1327.5398,2682.9771,49.7896,5.0},
{-2413.7427,975.9317,45.0031,5.0},
{-1672.3597,414.2950,6.8866,5.0},
{-2244.1365,-2560.6294,31.6276,5.0},
{-1603.0166,-2709.3589,48.2419,5.0},
{1939.3275,-1767.6813,13.2787,5.0},
{-94.7651,-1174.8079,1.9979,5.0},
{1381.6699,462.6467,19.8540,5.0},
{657.8167,-559.6507,16.0630,5.0},
{-1478.2916,1862.8318,32.3617,5.0},
{2147.3054,2744.9377,10.5263,5.0},
{2204.9602,2480.3494,10.5278,5.0},
{1590.9493,2202.2637,10.5247,5.0}
};
//Checkpoint type var (Relevant code!)
new checkpointType[MAX_POINTS] = {
CP_STATION1,
CP_STATION2,
CP_STATION3,
CP_STATION4,
CP_STATION5,
CP_STATION6,
CP_STATION7,
CP_STATION8,
CP_STATION9,
CP_STATION10,
CP_STATION11,
CP_STATION12,
CP_STATION13,
CP_STATION14,
CP_STATION15,
CP_STATION16
};
//------------------------------------------------------------------------------
//Pre made Functions (Relevant code!)
//------------------------------------------------------------------------------

//Check point type function
public getCheckpointType(playerID) {
return checkpointType[playerCheckpoint[playerID]];
}

//IsPlayerInArea function
public isPlayerInArea(playerID, Float:data[4])
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerID, X, Y, Z);
if(X >= data[0] && X <= data[2] && Y >= data[1] && Y <= data[3])
{
return 1;
}
return 0;
}

//Update the players checkpoint function
public checkpointUpdate()
{
for(new i=0; i<MAX_PLAYERS; i++)
{
 if(IsPlayerConnected(i))
  {
  for(new j=0; j < MAX_POINTS; j++)
  {
  if(isPlayerInArea(i, checkCoords[j]))
   {
   if(playerCheckpoint[i]!=j)
    {
    DisablePlayerCheckpoint(i);
    SetPlayerCheckpoint(i, checkpoints[j][0],checkpoints[j][1],checkpoints[j][2],checkpoints[j][3]);
    playerCheckpoint[i] = j;
    }
   }
   else
   {
   if(playerCheckpoint[i]==j)
    {
    DisablePlayerCheckpoint(i);
    playerCheckpoint[i] = 999;
    }
   }
  }
  }
}
}

//Fuel check function
public CheckFuel(playerid)
{
new Ptmess[32];
for(new i=0;i<MAX_PLAYERS;i++)
 {
  if(IsPlayerConnected(i) == 1 && IsPlayerInAnyVehicle(i) == 1)
   {
   if(GetPlayerState(i) == 2)
    {
	 new Vi;
     Vi = GetPlayerVehicleID(i);
     Petrol[Vi]--;

     if(Petrol[Vi] >= 1)
      {
      format(Ptmess, sizeof(Ptmess), "~w~Petrol ->~r~%d", Petrol[Vi]);
      GameTextForPlayer(i, Ptmess, 500, 4);
      }
      else
      {
      RemovePlayerFromVehicle(i);
      SendClientMessage(i, COLOR_RED, "Your vehicle ran out of petrol");
      if(Petrol[Vi] < 0)
	   {
	   Petrol[Vi] = 0;
	   }
      }

      if(Petrol[i] >= 51)
       {
       format(Ptmess, sizeof(Ptmess), "~w~Petrol ->%d", Petrol[Vi]);
       GameTextForPlayer(i, Ptmess, 500, 4);
       }

	 }
    }
 }
}

//Refill fuel function
public FuelRefill(playerid)
{
new VID;
VID = GetPlayerVehicleID(playerid);
if(Petrol[VID] < AMOUNT)
 {
 new FillUp;
 FillUp = AMOUNT - Petrol[VID];
 if(GetPlayerMoney(playerid) >= FillUp)
  {
  Petrol[VID] +=FillUp;
  new mess[64];
  format(mess, sizeof(mess), "You put %d units of petrol in your vehicle", FillUp);
  SendClientMessage(playerid, COLOR_WHITE, mess);
  GivePlayerMoney(playerid, -FillUp);
  return 1;
  }
  else
  {
  SendClientMessage(playerid, COLOR_RED, "You don't have enough money for petrol");
  return 1;
  }
 }
 else
 {
 SendClientMessage(playerid, COLOR_RED, "Your vehicle is allready full with petrol");
 return 1;
 }
return 1;
}
//T(he next 6 lines are all Relevant code!)
	for(new c=0;c<MAX_CARS;c++)
	 {
	 Petrol[c] = AMOUNT;
	 }
    SetTimer("CheckFuel", TIME, 1);
    SetTimer("checkpointUpdate", 1100, 1);

public OnPlayerCommandText(playerid, cmdtext[])
{
printf("OnPlayerText(%d)");

 if(strcmp(cmdtext, "/gasloc", true) == 0) {
 SendClientMessage(playerid, COLOR_GREEN, "Gas stations are located at:");
 SendClientMessage(playerid, COLOR_YELLOW, "LV South, The Strip -- LV SouthEast, Come-a-lot");
 SendClientMessage(playerid, COLOR_YELLOW, "LV Central, Bonecounty -- LV NorthWest, Tierra Robada");
 SendClientMessage(playerid, COLOR_YELLOW, "SF NorthWest, Juniper Hollow -- SF East, Easter Basin");
 SendClientMessage(playerid, COLOR_YELLOW, "LS SouthWest, Angel Pine -- LS SouthWest, Whetstone");
 SendClientMessage(playerid, COLOR_YELLOW, "LS Central, Idlewood -- LS West, Flint County");
 SendClientMessage(playerid, COLOR_YELLOW, "LS North, montgomery -- LS North, Dillimore");
 SendClientMessage(playerid, COLOR_YELLOW, "LV NorthWest, South Tierra Robada -- LV North, Spiny Bed");
 SendClientMessage(playerid, COLOR_YELLOW, "LV North, Emerald Isle......");
 return 1;
 }
 return 0;
}

//------------------------------------------------------------------------------
    main()
{
    print("Loaded THoM's server\n");
}

public OnGameModeInit()
{
    SetGameModeText("THoM's server");
    ShowPlayerMarkers(1);
    ShowNameTags(1);
    AddPlayerClass(105,2494.3562,-1686.1851,13.5128,1.6176,5,0,100,50,0,0); // 
    AddPlayerClass(102,1908.4832,-1084.3281,24.2066,332.1639,5,0,0,0,0,0); // 
    AddPlayerClass(280,251.2728,65.9932,1003.6406,84.6008,5,0,0,0,0,0); // 
    AddStaticVehicle(596,1604.0367,-1620.8091,13.2294,90.3612,0,1); // 
    AddStaticVehicle(536,2505.4890,-1695.3503,13.2931,1.4558,26,96); // 
    return 1;
}

public OnPlayerConnect(playerid)
{
    SendClientMessage(playerid, 0xFFFFFFAA, "Hi, welcome to my server");
    GivePlayerMoney(playerid, 100);
//Other stuff
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerCameraPos(playerid, 2495.4807, -1684.4324, 13.4795);
    SetPlayerPos(playerid, 2495.4431, -1688.6630, 13.9467);
    SetPlayerFacingAngle(playerid, 1.8265);
    SetPlayerCameraLookAt(playerid, 2495.4431, -1688.6630, 13.9467);
    if(classid == 0){
      gTeam[playerid] = TEAM_1;
      GameTextForPlayer(playerid, "Team Grove", 1000, 3);}
    else if(classid == 1){
      gTeam[playerid] = TEAM_2;
      GameTextForPlayer(playerid, "Team Ballas", 1000, 3);}
    else if(classid == 2){
      gTeam[playerid] = TEAM_3;
      GameTextForPlayer(playerid, "Team Cop", 1000, 3);}
    return 1;
}

public OnPlayerSpawn(playerid)
{
    SetPlayerInterior(playerid,0);
    if(gTeam[playerid] == TEAM_1)
       SetPlayerColor(playerid, 0x0000A0AA);
    else if(gTeam[playerid] == TEAM_2)
       SetPlayerColor(playerid, 0x00C0A9AA);
    else if(gTeam[playerid] == TEAM_3)
       SetPlayerColor(playerid, 0xCC2341AA);
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != INVALID_PLAYER_ID){
       if(gTeam[killerid] != gTeam[playerid]){
       GivePlayerMoney(killerid, 500);
       SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
       }else{
         GivePlayerMoney(killerid, 1000);
         SetPlayerScore(killerid, GetPlayerScore(killerid) - 1);
       }
    }
    SendDeathMessage(killerid, playerid, reason);
    return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
	printf("OnPlayerEnterCheckpoint(%d)", playerid);
	//(The next 13 lines (the return should always be at the end) is Relevant code!)
     if(getCheckpointType(playerid)>= 0 && getCheckpointType(playerid)<= 15)
      {
	  if(IsPlayerInAnyVehicle(playerid))
	   {
       SendClientMessage(playerid,COLOR_WHITE,"Stay in the checkpoint to refill your car with petrol");
       FuelRefill(playerid);
	   }
	   else
	   {
	   SendClientMessage(playerid, COLOR_RED, "Your not in a vehicle");
	   }
	   return 1;
	  }
	  return 1;
}

//------------------------------------------------------------------------------

public OnPlayerLeaveCheckpoint(playerid)
{
	printf("OnPlayerLeaveCheckpoint(%d)", playerid);
    return 1;
}

//------------------------------------------------------------------------------