• Страница 1 из 1
  • 1
Модератор форума: [east_side]_trane, drifter-dron, valych, admin  
pawno урок создание радара для ментов/полиции/милиции/фбр
adminДата: Воскресенье, 28.04.2013, 01:16:02 | Сообщение # 1

Группа: Администраторы
Сообщений: 3869
В этом уроке я вам расскажу как создать радар для полиции и т.п
И там начнем
Верху мода
где все new вставим это:
Код
#define COLOR_YELLOW 0xFFFF00AA

new VehRadarID [MAX_VEHICLES];
new Text: RadarHud;
new Text: SpeedAndModel [MAX_VEHICLES];
new CheckingSpeed [MAX_VEHICLES];
new OldVehID [MAX_PLAYERS];

forward UpdateSpeed (vehid);
forward CheckValidTextDraws();

new VehicleModel[212][] ={
"Landstalker", "Bravura", "Buffalo", "Linerunner", "Perrenial","Sentinel", "Dumper", "Firetruck", "Trashmaster", "Stretch", "Manana",
"Infernus", "Voodoo", "Pony", "Mule", "Cheetah", "Ambulance","Leviathan", "Moonbeam", "Esperanto", "Taxi",
"Washington", "Bobcat","Whoopee", "BF Injection", "Hunter", "Premier","Enforcer", "Securicar", "Banshee",
"Predator", "Bus", "Rhino", "Barracks", "Hotknife","Trailer 1", "Previon", "Coach", "Cabbie", "Stallion",
"Rumpo", "RC Bandit", "Romero", "Packer","Monster", "Admiral", "Squalo","Seasparrow", "Pizzaboy", "Tram", "Trailer 2",
"Turismo", "Speeder", "Reefer", "Tropic","Flatbed", "Yankee", "Caddy", "Solair","Berkley's RC Van", "Skimmer", "PCJ-600", "Faggio",
"Freeway", "RC Baron", "RC Raider","Glendale", "Oceanic", "Sanchez", "Sparrow","Patriot", "Quad", "Coastguard", "Dinghy", "Hermes",
"Sabre", "Rustler", "ZR-350","Walton", "Regina", "Comet", "BMX", "Burrito","Camper", "Marquis", "Baggage", "Dozer", "Maverick",
"News Chopper", "Rancher","FBI Rancher", "Virgo", "Greenwood", "Jetmax", "Hotring","Sandking", "Blista Compact", "Police Maverick",
"Boxvillde", "Benson","Mesa", "RC Goblin", "Hotring Racer A", "Hotring Racer B","Bloodring Banger", "Rancher", "Super GT", "Elegant",
"Journey", "Bike", "Mountain Bike", "Beagle", "Cropduster","Stunt",  "Tanker", "Roadtrain", "Nebula", "Majestic", "Buccaneer",
"Shamal", "Hydra","FCR-900", "NRG-500", "HPV1000", "Cement Truck", "Tow Truck", "Fortune","Cadrona", "FBI Truck", "Willard",
"Forklift", "Tractor", "Combine","Feltzer", "Remington", "Slamvan", "Blade", "Freight","Streak","Vortex", "Vincent", "Bullet",
"Clover", "Sadler", "Firetruck LA","Hustler", "Intruder", "Primo", "Cargobob", "Tampa","Sunrise", "Merit","Utility", "Nevada",
"Yosemite", "Windsor", "Monster A", "Monster B", "Uranus", "Jester", "Sultan","Stratum", "Elegy", "Raindance","RC Tiger",
"Flash", "Tahoma", "Savanna", "Bandito","Freight Flat", "Streak Carriage", "Kart","Mower", "Dune", "Sweeper", "Broadway",
"Tornado", "AT-400", "DFT-30", "Huntley", "Stafford","BF-400", "News Van", "Tug", "Trailer 3", "Emperor","Wayfarer", "Euros",
"Hotdog","Club", "Freight Carriage", "Trailer 4","Andromada", "Dodo", "RC Cam", "Launch", "Police Car (LSPD)","Police Car (SFPD)",
"Police Car (LVPD)", "Police Ranger", "Picador", "S.W.A.T", "Alpha","Phoenix", "Glendale", "Sadler", "Luggage Trailer A",
"Luggage Trailer B", "Stairs", "Boxville", "Tiller", "Utility Trailer" };

после этого ищем
Код
public OnGameModeInit()
и туда вставляем:
Код
SetTimer ("CheckValidTextDraws", 1000, 1);
           
      RadarHud = TextDrawCreate (495.0, 200.0, "~b~Model: ~n~~r~Speed:         kmph");
      TextDrawFont (RadarHud, 2);
      TextDrawLetterSize (RadarHud, 0.3, 1.0);
              
      for (new i = 1; i <= MAX_VEHICLES; i++)
      {
          VehRadarID  [i]= -1;
          SpeedAndModel  = TextDrawCreate (545.0, 200.0, "~b~ ~n~~r~");
          TextDrawFont (SpeedAndModel , 2);
          TextDrawLetterSize (SpeedAndModel , 0.3, 1.0);
          CheckingSpeed  = 0;
      }[/i]

примерно так должен быть public:
Код
public OnGameModeInit()
{
      printf (" \nCruiser speed radar made by Srdjan loaded.\n");
           
      SetTimer ("CheckValidTextDraws", 1000, 1);
           
      RadarHud = TextDrawCreate (495.0, 200.0, "~b~Model: ~n~~r~Speed:         kmph");
      TextDrawFont (RadarHud, 2);
      TextDrawLetterSize (RadarHud, 0.3, 1.0);
              
      for (new i = 1; i <= MAX_VEHICLES; i++)
      {
          VehRadarID  = -1;
          SpeedAndModel  = TextDrawCreate (545.0, 200.0, "~b~ ~n~~r~");
          TextDrawFont (SpeedAndModel , 2);
          TextDrawLetterSize (SpeedAndModel , 0.3, 1.0);
          CheckingSpeed  = 0;
      }
            
      return 1;
}

После этого ищем public OnPlayerCommandText и туда вставляем:
Код
if (!strcmp (cmdtext, "/placeradar"))
      {
       if (IsPlayerInAnyVehicle (playerid))
       {
           new vehid = GetPlayerVehicleID (playerid);
           if (VehRadarID  [vehid]> -1) return 1;
                
                 new Float: x, Float: y, Float: z, Float: a;
           GetVehiclePos (vehid, x, y, z);
           GetVehicleZAngle (vehid, a);
           SendClientMessage (playerid, COLOR_YELLOW, "Radar has been added successfully.");
           VehRadarID  [vehid]= CreateObject (367, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 300.0);
           AttachObjectToVehicle (VehRadarID [vehid], vehid, 0.2, 0.50, 0.3, 0.0, 0.0, 90.0);
                
           for (new i = 0; i < MAX_PLAYERS; i++)
           {
               if (IsPlayerInVehicle (i, vehid))
               {
                  TextDrawShowForPlayer (i, RadarHud);
         }
           }
         }
       return 1;
      }
           
      if (!strcmp (cmdtext, "/removeradar"))
      {
          if (IsPlayerInAnyVehicle (playerid))
          {
              new vehid = GetPlayerVehicleID (playerid);
              if (VehRadarID  [vehid]== -1) return 1;

           DestroyObject (VehRadarID [vehid]);
              SendClientMessage (playerid, COLOR_YELLOW, "Radar has been removed successfully.");
              VehRadarID  [vehid]= -1;
              KillTimer (CheckingSpeed [vehid]);
               CheckingSpeed  [vehid]= -1;
                   
              for (new i = 0; i < MAX_PLAYERS; i++)
           {
               if (IsPlayerInVehicle (i, vehid))
               {
          TextDrawHideForPlayer (i, RadarHud);
          TextDrawHideForPlayer (playerid, SpeedAndModel [vehid]);
               }
           }
          }
          return 1;
      }

      if (!strcmp (cmdtext, "/checkspeed"))
      {
          if (IsPlayerInAnyVehicle (playerid))
          {
              new vehid = GetPlayerVehicleID (playerid);
              if (VehRadarID  [vehid]== -1) return 1;
              CheckingSpeed  [vehid]= SetTimerEx ("UpdateSpeed", 100, 1, "d", vehid);
            }
          return 1;
      }
           
      if (!strcmp (cmdtext, "/stopchecking"))
      {
          if (IsPlayerInAnyVehicle (playerid))
          {
              new vehid = GetPlayerVehicleID (playerid);
              if (CheckingSpeed  [vehid]> 0)
              {
                  KillTimer (CheckingSpeed [vehid]);
                  CheckingSpeed  [vehid]= -1;
              }
              for (new i = 0; i < MAX_PLAYERS; i++)
        {
         if (IsPlayerInVehicle (i, vehid))
            {
             TextDrawHideForPlayer (i, SpeedAndModel [vehid]);
          }
        }
          }
          return 1;
      }
           
      if (!strcmp (cmdtext, "/issueticket"))
      {
          if (IsPlayerInAnyVehicle (playerid))
          {
              new vehid = GetPlayerVehicleID (playerid);
              if (CheckingSpeed  [vehid]> -1)
              {
                  for (new i = 0; i < MAX_PLAYERS; i++)
                  {
                      if (IsPlayerConnected (i) && i != playerid)
                      {
                          if (IsPlayerInVehicle (i, GetVehicleInfrontID (vehid)))
                          {
                    if (GetPlayerVehicleSeat (i) == 0)
                    {
                        GivePlayerMoney (i, -1500);
                    }
                          }
                      }
                  }
              }
          }
          return 1;
      }

примерно так должен быть public:
Код
public OnPlayerCommandText (playerid, cmdtext[])
{
      if (!strcmp (cmdtext, "/placeradar"))
      {
       if (IsPlayerInAnyVehicle (playerid))
       {
           new vehid = GetPlayerVehicleID (playerid);
           if (VehRadarID  [vehid]> -1) return 1;
                
                 new Float: x, Float: y, Float: z, Float: a;
           GetVehiclePos (vehid, x, y, z);
           GetVehicleZAngle (vehid, a);
           SendClientMessage (playerid, COLOR_YELLOW, "Radar has been added successfully.");
           VehRadarID  [vehid]= CreateObject (367, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 300.0);
           AttachObjectToVehicle (VehRadarID [vehid], vehid, 0.2, 0.50, 0.3, 0.0, 0.0, 90.0);
                
           for (new i = 0; i < MAX_PLAYERS; i++)
           {
               if (IsPlayerInVehicle (i, vehid))
               {
                  TextDrawShowForPlayer (i, RadarHud);
         }
           }
         }
       return 1;
      }
           
      if (!strcmp (cmdtext, "/removeradar"))
      {
          if (IsPlayerInAnyVehicle (playerid))
          {
              new vehid = GetPlayerVehicleID (playerid);
              if (VehRadarID  [vehid]== -1) return 1;

           DestroyObject (VehRadarID [vehid]);
              SendClientMessage (playerid, COLOR_YELLOW, "Radar has been removed successfully.");
              VehRadarID  [vehid]= -1;
              KillTimer (CheckingSpeed [vehid]);
               CheckingSpeed  [vehid]= -1;
                   
              for (new i = 0; i < MAX_PLAYERS; i++)
           {
               if (IsPlayerInVehicle (i, vehid))
               {
          TextDrawHideForPlayer (i, RadarHud);
          TextDrawHideForPlayer (playerid, SpeedAndModel [vehid]);
               }
           }
          }
          return 1;
      }

      if (!strcmp (cmdtext, "/checkspeed"))
      {
          if (IsPlayerInAnyVehicle (playerid))
          {
              new vehid = GetPlayerVehicleID (playerid);
              if (VehRadarID  [vehid]== -1) return 1;
              CheckingSpeed  [vehid]= SetTimerEx ("UpdateSpeed", 100, 1, "d", vehid);
            }
          return 1;
      }
           
      if (!strcmp (cmdtext, "/stopchecking"))
      {
          if (IsPlayerInAnyVehicle (playerid))
          {
              new vehid = GetPlayerVehicleID (playerid);
              if (CheckingSpeed  [vehid]> 0)
              {
                  KillTimer (CheckingSpeed [vehid]);
                  CheckingSpeed  [vehid]= -1;
              }
              for (new i = 0; i < MAX_PLAYERS; i++)
        {
         if (IsPlayerInVehicle (i, vehid))
            {
             TextDrawHideForPlayer (i, SpeedAndModel [vehid]);
          }
        }
          }
          return 1;
      }
           
      if (!strcmp (cmdtext, "/issueticket"))
      {
          if (IsPlayerInAnyVehicle (playerid))
          {
              new vehid = GetPlayerVehicleID (playerid);
              if (CheckingSpeed  [vehid]> -1)
              {
                  for (new i = 0; i < MAX_PLAYERS; i++)
                  {
                      if (IsPlayerConnected (i) && i != playerid)
                      {
                          if (IsPlayerInVehicle (i, GetVehicleInfrontID (vehid)))
                          {
                    if (GetPlayerVehicleSeat (i) == 0)
                    {
                        GivePlayerMoney (i, -1500);
                    }
                          }
                      }
                  }
              }
          }
          return 1;
      }
           
      return 0;
}

Потом в любое вместо ставим функцию
Код
GetVehicleInfrontID (vehid)
{
         new Float: temp = 7.0;
      new j = 0;
      for (new i = 1; i <= MAX_VEHICLES; i++)
      {
          new Float: a, Float: x1, Float: y1, Float: z1, Float: x2, Float: y2, Float: z2;
          GetVehiclePos (vehid, x1, y1, z1);
          GetVehicleZAngle (vehid, a);
        if (i != vehid)
        {
         if (GetVehiclePos (i, x2, y2, z2))
        {
         new Float: distance = floatsqroot (floatpower ((x1 - x2), 2) + floatpower ((y1 - y2), 2) + floatpower ((z1 - z2), 2));
         GetVehicleZAngle (vehid, a);

         if (distance < 300.0)
         {
             x1 = x1 + (distance * floatsin(-a, degrees));
          y1 = y1 + (distance * floatcos(-a, degrees));

          distance = floatsqroot ((floatpower ((x1 - x2), 2)) + (floatpower ((y1 - y2), 2)));

          if (temp > distance)
          {
           temp = distance;
           j = i;
          }
         }
        }
       }
      }
      if (temp < 7.0) return j;
      return -1;
}

public UpdateSpeed (vehid)
{
         new id = GetVehicleInfrontID (vehid);
      if (id < 0)
      {
          TextDrawSetString (SpeedAndModel [vehid], "~b~N/A ~n~~r~N/A");
      }
      else
      {
       new str[32], Float: velocityX, Float: velocityY, Float: velocityZ;
          GetVehicleVelocity (id, velocityX, velocityY, velocityZ);
             new speed = floatround (floatsqroot (floatpower (velocityX, 2) + floatpower (velocityY, 2) + floatpower (velocityZ, 2)) * 136.666667, floatround_round);
       format (str, sizeof (str), "~b~%s ~n~~r~%d", VehicleModel [GetVehicleModel (id) - 400], speed);
       TextDrawSetString (SpeedAndModel [vehid], str);
      }

       for (new i = 0; i < MAX_PLAYERS; i++)
      {
       if (IsPlayerInVehicle (i, vehid))
          {
           TextDrawShowForPlayer (i, SpeedAndModel [vehid]);
        }
      }
      return 1;
}

public CheckValidTextDraws()
{
      for (new i = 0; i < MAX_PLAYERS; i++)
      {
          if (IsPlayerConnected (i))
          {
        if (IsPlayerInAnyVehicle (i))
        {
            new vehid = GetPlayerVehicleID (i);
            if (VehRadarID  [vehid]> -1)
            {
                TextDrawShowForPlayer (i, RadarHud);
                if (CheckingSpeed  [vehid]> 0)
                {
                    TextDrawShowForPlayer (i, SpeedAndModel [vehid]);
                }
                else
                {
                    TextDrawHideForPlayer (i, SpeedAndModel [vehid]);
                }
            }
            else
            {
                TextDrawHideForPlayer (i, RadarHud);
            }
        }
             
        else
        {
            TextDrawHideForPlayer (i, RadarHud);
            TextDrawHideForPlayer (i, SpeedAndModel [OldVehID]);
            OldVehID  = 0;
        }
          }
      }
      return 1;
}

После этого ищем public OnPlayerStateChange и туда вставляем:
Код
if ((oldstate == PLAYER_STATE_ONFOOT) && (newstate == PLAYER_STATE_PASSENGER || newstate == PLAYER_STATE_DRIVER))
      {
           OldVehID  [playerid]= GetPlayerVehicleID (playerid);
      }

Примерно так должен быть public:
Код
public OnPlayerStateChange (playerid, newstate, oldstate)
{
      if ((oldstate == PLAYER_STATE_ONFOOT) && (newstate == PLAYER_STATE_PASSENGER || newstate == PLAYER_STATE_DRIVER))
      {
           OldVehID  [playerid]= GetPlayerVehicleID (playerid);
      }
      return 1;
}

Потом ищем public OnVehicleDeath и туда вставляем:
Код
DestroyObject (VehRadarID [vehicleid]);
         VehRadarID  [vehicleid]= -1;
         KillTimer (CheckingSpeed [vehicleid]);
        CheckingSpeed  [vehicleid]= -1;
       for (new i = 0; i < MAX_PLAYERS; i++)
      {
       if (IsPlayerInVehicle (i, vehicleid))
        {
        TextDrawHideForPlayer (i, RadarHud);
        TextDrawHideForPlayer (i, SpeedAndModel [vehicleid]);
       }
      }

примерно так должен быть public:

Код
public OnVehicleDeath (vehicleid)
{
         DestroyObject (VehRadarID [vehicleid]);
         VehRadarID  [vehicleid]= -1;
         KillTimer (CheckingSpeed [vehicleid]);
        CheckingSpeed  [vehicleid]= -1;
       for (new i = 0; i < MAX_PLAYERS; i++)
      {
       if (IsPlayerInVehicle (i, vehicleid))
        {
        TextDrawHideForPlayer (i, RadarHud);
        TextDrawHideForPlayer (i, SpeedAndModel [vehicleid]);
       }
      }
}

Автор:26_RUSSS


zm-jail.ru

Разработка сайта samp-pawno.ru


 
СообщениеВ этом уроке я вам расскажу как создать радар для полиции и т.п
И там начнем
Верху мода
где все new вставим это:
Код
#define COLOR_YELLOW 0xFFFF00AA

new VehRadarID [MAX_VEHICLES];
new Text: RadarHud;
new Text: SpeedAndModel [MAX_VEHICLES];
new CheckingSpeed [MAX_VEHICLES];
new OldVehID [MAX_PLAYERS];

forward UpdateSpeed (vehid);
forward CheckValidTextDraws();

new VehicleModel[212][] ={
"Landstalker", "Bravura", "Buffalo", "Linerunner", "Perrenial","Sentinel", "Dumper", "Firetruck", "Trashmaster", "Stretch", "Manana",
"Infernus", "Voodoo", "Pony", "Mule", "Cheetah", "Ambulance","Leviathan", "Moonbeam", "Esperanto", "Taxi",
"Washington", "Bobcat","Whoopee", "BF Injection", "Hunter", "Premier","Enforcer", "Securicar", "Banshee",
"Predator", "Bus", "Rhino", "Barracks", "Hotknife","Trailer 1", "Previon", "Coach", "Cabbie", "Stallion",
"Rumpo", "RC Bandit", "Romero", "Packer","Monster", "Admiral", "Squalo","Seasparrow", "Pizzaboy", "Tram", "Trailer 2",
"Turismo", "Speeder", "Reefer", "Tropic","Flatbed", "Yankee", "Caddy", "Solair","Berkley's RC Van", "Skimmer", "PCJ-600", "Faggio",
"Freeway", "RC Baron", "RC Raider","Glendale", "Oceanic", "Sanchez", "Sparrow","Patriot", "Quad", "Coastguard", "Dinghy", "Hermes",
"Sabre", "Rustler", "ZR-350","Walton", "Regina", "Comet", "BMX", "Burrito","Camper", "Marquis", "Baggage", "Dozer", "Maverick",
"News Chopper", "Rancher","FBI Rancher", "Virgo", "Greenwood", "Jetmax", "Hotring","Sandking", "Blista Compact", "Police Maverick",
"Boxvillde", "Benson","Mesa", "RC Goblin", "Hotring Racer A", "Hotring Racer B","Bloodring Banger", "Rancher", "Super GT", "Elegant",
"Journey", "Bike", "Mountain Bike", "Beagle", "Cropduster","Stunt",  "Tanker", "Roadtrain", "Nebula", "Majestic", "Buccaneer",
"Shamal", "Hydra","FCR-900", "NRG-500", "HPV1000", "Cement Truck", "Tow Truck", "Fortune","Cadrona", "FBI Truck", "Willard",
"Forklift", "Tractor", "Combine","Feltzer", "Remington", "Slamvan", "Blade", "Freight","Streak","Vortex", "Vincent", "Bullet",
"Clover", "Sadler", "Firetruck LA","Hustler", "Intruder", "Primo", "Cargobob", "Tampa","Sunrise", "Merit","Utility", "Nevada",
"Yosemite", "Windsor", "Monster A", "Monster B", "Uranus", "Jester", "Sultan","Stratum", "Elegy", "Raindance","RC Tiger",
"Flash", "Tahoma", "Savanna", "Bandito","Freight Flat", "Streak Carriage", "Kart","Mower", "Dune", "Sweeper", "Broadway",
"Tornado", "AT-400", "DFT-30", "Huntley", "Stafford","BF-400", "News Van", "Tug", "Trailer 3", "Emperor","Wayfarer", "Euros",
"Hotdog","Club", "Freight Carriage", "Trailer 4","Andromada", "Dodo", "RC Cam", "Launch", "Police Car (LSPD)","Police Car (SFPD)",
"Police Car (LVPD)", "Police Ranger", "Picador", "S.W.A.T", "Alpha","Phoenix", "Glendale", "Sadler", "Luggage Trailer A",
"Luggage Trailer B", "Stairs", "Boxville", "Tiller", "Utility Trailer" };

после этого ищем
Код
public OnGameModeInit()
и туда вставляем:
Код
SetTimer ("CheckValidTextDraws", 1000, 1);
           
      RadarHud = TextDrawCreate (495.0, 200.0, "~b~Model: ~n~~r~Speed:         kmph");
      TextDrawFont (RadarHud, 2);
      TextDrawLetterSize (RadarHud, 0.3, 1.0);
              
      for (new i = 1; i <= MAX_VEHICLES; i++)
      {
          VehRadarID  [i]= -1;
          SpeedAndModel  = TextDrawCreate (545.0, 200.0, "~b~ ~n~~r~");
          TextDrawFont (SpeedAndModel , 2);
          TextDrawLetterSize (SpeedAndModel , 0.3, 1.0);
          CheckingSpeed  = 0;
      }[/i]

примерно так должен быть public:
Код
public OnGameModeInit()
{
      printf (" \nCruiser speed radar made by Srdjan loaded.\n");
           
      SetTimer ("CheckValidTextDraws", 1000, 1);
           
      RadarHud = TextDrawCreate (495.0, 200.0, "~b~Model: ~n~~r~Speed:         kmph");
      TextDrawFont (RadarHud, 2);
      TextDrawLetterSize (RadarHud, 0.3, 1.0);
              
      for (new i = 1; i <= MAX_VEHICLES; i++)
      {
          VehRadarID  = -1;
          SpeedAndModel  = TextDrawCreate (545.0, 200.0, "~b~ ~n~~r~");
          TextDrawFont (SpeedAndModel , 2);
          TextDrawLetterSize (SpeedAndModel , 0.3, 1.0);
          CheckingSpeed  = 0;
      }
            
      return 1;
}

После этого ищем public OnPlayerCommandText и туда вставляем:
Код
if (!strcmp (cmdtext, "/placeradar"))
      {
       if (IsPlayerInAnyVehicle (playerid))
       {
           new vehid = GetPlayerVehicleID (playerid);
           if (VehRadarID  [vehid]> -1) return 1;
                
                 new Float: x, Float: y, Float: z, Float: a;
           GetVehiclePos (vehid, x, y, z);
           GetVehicleZAngle (vehid, a);
           SendClientMessage (playerid, COLOR_YELLOW, "Radar has been added successfully.");
           VehRadarID  [vehid]= CreateObject (367, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 300.0);
           AttachObjectToVehicle (VehRadarID [vehid], vehid, 0.2, 0.50, 0.3, 0.0, 0.0, 90.0);
                
           for (new i = 0; i < MAX_PLAYERS; i++)
           {
               if (IsPlayerInVehicle (i, vehid))
               {
                  TextDrawShowForPlayer (i, RadarHud);
         }
           }
         }
       return 1;
      }
           
      if (!strcmp (cmdtext, "/removeradar"))
      {
          if (IsPlayerInAnyVehicle (playerid))
          {
              new vehid = GetPlayerVehicleID (playerid);
              if (VehRadarID  [vehid]== -1) return 1;

           DestroyObject (VehRadarID [vehid]);
              SendClientMessage (playerid, COLOR_YELLOW, "Radar has been removed successfully.");
              VehRadarID  [vehid]= -1;
              KillTimer (CheckingSpeed [vehid]);
               CheckingSpeed  [vehid]= -1;
                   
              for (new i = 0; i < MAX_PLAYERS; i++)
           {
               if (IsPlayerInVehicle (i, vehid))
               {
          TextDrawHideForPlayer (i, RadarHud);
          TextDrawHideForPlayer (playerid, SpeedAndModel [vehid]);
               }
           }
          }
          return 1;
      }

      if (!strcmp (cmdtext, "/checkspeed"))
      {
          if (IsPlayerInAnyVehicle (playerid))
          {
              new vehid = GetPlayerVehicleID (playerid);
              if (VehRadarID  [vehid]== -1) return 1;
              CheckingSpeed  [vehid]= SetTimerEx ("UpdateSpeed", 100, 1, "d", vehid);
            }
          return 1;
      }
           
      if (!strcmp (cmdtext, "/stopchecking"))
      {
          if (IsPlayerInAnyVehicle (playerid))
          {
              new vehid = GetPlayerVehicleID (playerid);
              if (CheckingSpeed  [vehid]> 0)
              {
                  KillTimer (CheckingSpeed [vehid]);
                  CheckingSpeed  [vehid]= -1;
              }
              for (new i = 0; i < MAX_PLAYERS; i++)
        {
         if (IsPlayerInVehicle (i, vehid))
            {
             TextDrawHideForPlayer (i, SpeedAndModel [vehid]);
          }
        }
          }
          return 1;
      }
           
      if (!strcmp (cmdtext, "/issueticket"))
      {
          if (IsPlayerInAnyVehicle (playerid))
          {
              new vehid = GetPlayerVehicleID (playerid);
              if (CheckingSpeed  [vehid]> -1)
              {
                  for (new i = 0; i < MAX_PLAYERS; i++)
                  {
                      if (IsPlayerConnected (i) && i != playerid)
                      {
                          if (IsPlayerInVehicle (i, GetVehicleInfrontID (vehid)))
                          {
                    if (GetPlayerVehicleSeat (i) == 0)
                    {
                        GivePlayerMoney (i, -1500);
                    }
                          }
                      }
                  }
              }
          }
          return 1;
      }

примерно так должен быть public:
Код
public OnPlayerCommandText (playerid, cmdtext[])
{
      if (!strcmp (cmdtext, "/placeradar"))
      {
       if (IsPlayerInAnyVehicle (playerid))
       {
           new vehid = GetPlayerVehicleID (playerid);
           if (VehRadarID  [vehid]> -1) return 1;
                
                 new Float: x, Float: y, Float: z, Float: a;
           GetVehiclePos (vehid, x, y, z);
           GetVehicleZAngle (vehid, a);
           SendClientMessage (playerid, COLOR_YELLOW, "Radar has been added successfully.");
           VehRadarID  [vehid]= CreateObject (367, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 300.0);
           AttachObjectToVehicle (VehRadarID [vehid], vehid, 0.2, 0.50, 0.3, 0.0, 0.0, 90.0);
                
           for (new i = 0; i < MAX_PLAYERS; i++)
           {
               if (IsPlayerInVehicle (i, vehid))
               {
                  TextDrawShowForPlayer (i, RadarHud);
         }
           }
         }
       return 1;
      }
           
      if (!strcmp (cmdtext, "/removeradar"))
      {
          if (IsPlayerInAnyVehicle (playerid))
          {
              new vehid = GetPlayerVehicleID (playerid);
              if (VehRadarID  [vehid]== -1) return 1;

           DestroyObject (VehRadarID [vehid]);
              SendClientMessage (playerid, COLOR_YELLOW, "Radar has been removed successfully.");
              VehRadarID  [vehid]= -1;
              KillTimer (CheckingSpeed [vehid]);
               CheckingSpeed  [vehid]= -1;
                   
              for (new i = 0; i < MAX_PLAYERS; i++)
           {
               if (IsPlayerInVehicle (i, vehid))
               {
          TextDrawHideForPlayer (i, RadarHud);
          TextDrawHideForPlayer (playerid, SpeedAndModel [vehid]);
               }
           }
          }
          return 1;
      }

      if (!strcmp (cmdtext, "/checkspeed"))
      {
          if (IsPlayerInAnyVehicle (playerid))
          {
              new vehid = GetPlayerVehicleID (playerid);
              if (VehRadarID  [vehid]== -1) return 1;
              CheckingSpeed  [vehid]= SetTimerEx ("UpdateSpeed", 100, 1, "d", vehid);
            }
          return 1;
      }
           
      if (!strcmp (cmdtext, "/stopchecking"))
      {
          if (IsPlayerInAnyVehicle (playerid))
          {
              new vehid = GetPlayerVehicleID (playerid);
              if (CheckingSpeed  [vehid]> 0)
              {
                  KillTimer (CheckingSpeed [vehid]);
                  CheckingSpeed  [vehid]= -1;
              }
              for (new i = 0; i < MAX_PLAYERS; i++)
        {
         if (IsPlayerInVehicle (i, vehid))
            {
             TextDrawHideForPlayer (i, SpeedAndModel [vehid]);
          }
        }
          }
          return 1;
      }
           
      if (!strcmp (cmdtext, "/issueticket"))
      {
          if (IsPlayerInAnyVehicle (playerid))
          {
              new vehid = GetPlayerVehicleID (playerid);
              if (CheckingSpeed  [vehid]> -1)
              {
                  for (new i = 0; i < MAX_PLAYERS; i++)
                  {
                      if (IsPlayerConnected (i) && i != playerid)
                      {
                          if (IsPlayerInVehicle (i, GetVehicleInfrontID (vehid)))
                          {
                    if (GetPlayerVehicleSeat (i) == 0)
                    {
                        GivePlayerMoney (i, -1500);
                    }
                          }
                      }
                  }
              }
          }
          return 1;
      }
           
      return 0;
}

Потом в любое вместо ставим функцию
Код
GetVehicleInfrontID (vehid)
{
         new Float: temp = 7.0;
      new j = 0;
      for (new i = 1; i <= MAX_VEHICLES; i++)
      {
          new Float: a, Float: x1, Float: y1, Float: z1, Float: x2, Float: y2, Float: z2;
          GetVehiclePos (vehid, x1, y1, z1);
          GetVehicleZAngle (vehid, a);
        if (i != vehid)
        {
         if (GetVehiclePos (i, x2, y2, z2))
        {
         new Float: distance = floatsqroot (floatpower ((x1 - x2), 2) + floatpower ((y1 - y2), 2) + floatpower ((z1 - z2), 2));
         GetVehicleZAngle (vehid, a);

         if (distance < 300.0)
         {
             x1 = x1 + (distance * floatsin(-a, degrees));
          y1 = y1 + (distance * floatcos(-a, degrees));

          distance = floatsqroot ((floatpower ((x1 - x2), 2)) + (floatpower ((y1 - y2), 2)));

          if (temp > distance)
          {
           temp = distance;
           j = i;
          }
         }
        }
       }
      }
      if (temp < 7.0) return j;
      return -1;
}

public UpdateSpeed (vehid)
{
         new id = GetVehicleInfrontID (vehid);
      if (id < 0)
      {
          TextDrawSetString (SpeedAndModel [vehid], "~b~N/A ~n~~r~N/A");
      }
      else
      {
       new str[32], Float: velocityX, Float: velocityY, Float: velocityZ;
          GetVehicleVelocity (id, velocityX, velocityY, velocityZ);
             new speed = floatround (floatsqroot (floatpower (velocityX, 2) + floatpower (velocityY, 2) + floatpower (velocityZ, 2)) * 136.666667, floatround_round);
       format (str, sizeof (str), "~b~%s ~n~~r~%d", VehicleModel [GetVehicleModel (id) - 400], speed);
       TextDrawSetString (SpeedAndModel [vehid], str);
      }

       for (new i = 0; i < MAX_PLAYERS; i++)
      {
       if (IsPlayerInVehicle (i, vehid))
          {
           TextDrawShowForPlayer (i, SpeedAndModel [vehid]);
        }
      }
      return 1;
}

public CheckValidTextDraws()
{
      for (new i = 0; i < MAX_PLAYERS; i++)
      {
          if (IsPlayerConnected (i))
          {
        if (IsPlayerInAnyVehicle (i))
        {
            new vehid = GetPlayerVehicleID (i);
            if (VehRadarID  [vehid]> -1)
            {
                TextDrawShowForPlayer (i, RadarHud);
                if (CheckingSpeed  [vehid]> 0)
                {
                    TextDrawShowForPlayer (i, SpeedAndModel [vehid]);
                }
                else
                {
                    TextDrawHideForPlayer (i, SpeedAndModel [vehid]);
                }
            }
            else
            {
                TextDrawHideForPlayer (i, RadarHud);
            }
        }
             
        else
        {
            TextDrawHideForPlayer (i, RadarHud);
            TextDrawHideForPlayer (i, SpeedAndModel [OldVehID]);
            OldVehID  = 0;
        }
          }
      }
      return 1;
}

После этого ищем public OnPlayerStateChange и туда вставляем:
Код
if ((oldstate == PLAYER_STATE_ONFOOT) && (newstate == PLAYER_STATE_PASSENGER || newstate == PLAYER_STATE_DRIVER))
      {
           OldVehID  [playerid]= GetPlayerVehicleID (playerid);
      }

Примерно так должен быть public:
Код
public OnPlayerStateChange (playerid, newstate, oldstate)
{
      if ((oldstate == PLAYER_STATE_ONFOOT) && (newstate == PLAYER_STATE_PASSENGER || newstate == PLAYER_STATE_DRIVER))
      {
           OldVehID  [playerid]= GetPlayerVehicleID (playerid);
      }
      return 1;
}

Потом ищем public OnVehicleDeath и туда вставляем:
Код
DestroyObject (VehRadarID [vehicleid]);
         VehRadarID  [vehicleid]= -1;
         KillTimer (CheckingSpeed [vehicleid]);
        CheckingSpeed  [vehicleid]= -1;
       for (new i = 0; i < MAX_PLAYERS; i++)
      {
       if (IsPlayerInVehicle (i, vehicleid))
        {
        TextDrawHideForPlayer (i, RadarHud);
        TextDrawHideForPlayer (i, SpeedAndModel [vehicleid]);
       }
      }

примерно так должен быть public:

Код
public OnVehicleDeath (vehicleid)
{
         DestroyObject (VehRadarID [vehicleid]);
         VehRadarID  [vehicleid]= -1;
         KillTimer (CheckingSpeed [vehicleid]);
        CheckingSpeed  [vehicleid]= -1;
       for (new i = 0; i < MAX_PLAYERS; i++)
      {
       if (IsPlayerInVehicle (i, vehicleid))
        {
        TextDrawHideForPlayer (i, RadarHud);
        TextDrawHideForPlayer (i, SpeedAndModel [vehicleid]);
       }
      }
}

Автор:26_RUSSS

Автор - admin
Дата добавления - 28.04.2013 в 01:16:02
Mattxl8Дата: Четверг, 22.08.2013, 15:39:24 | Сообщение # 2

Группа: Пользователи
Сообщений: 5
И што радар делает?
И как ним пользоватся??
 
СообщениеИ што радар делает?
И как ним пользоватся??

Автор - Mattxl8
Дата добавления - 22.08.2013 в 15:39:24
  • Страница 1 из 1
  • 1
Поиск:
Загрузка страницы, займет меньше минуты...
Загрузка...

Статистика Форума
Последнии темы Читаемые темы Лучшие пользователи Новые пользователи
Система телефонов поломалась
Не в себе
фильм скалайн
Трансформеры 3
форсаж 6
Ищу [FS]Для админок на сервер
нужны координаты карты для отметки зон...
Помогите найти мод
pawno урок автоматические ворота
обращение к скриптерам.
Вопросы по скриптингу
Ваши ошибки при компиляции GM/FS

Вопросы по скриптингу

(1081)

Считаем до 1000

(274)

Ваши ошибки при компиляция gm

(260)

Набор в команду

(80)

Ваши ошибки при компиляции GM/FS

(71)

вопроосы по скриптингу от 22.04.2013

(64)

Баннеробмен

(64)

несколько команд на samp 0.3 c

(64)

Оценки сайта samp-pawno.ru

(55)

Заказ хостинга

(51)

Набор в команду(форум)

(45)

Урок №61 по созданию системы авто для GodFather

(45)

admin

(3869)

[east_side]_trane

(443)

TWiX

(316)

valych

(501)

drifter-dron

(477)

danik_rok

(317)

Dimka_71rus

(360)

Drifter96

(300)

MaNb9K

(220)

[MTA]MaPeR5518

(181)

Dima_Tkach

(107)

Nik_Ull

(184)

system32xzxz

(Четверг 09:25:24)

torbin169

(Суббота 23:09:29)

kuchuk_00

(Суббота 17:10:14)

artem_boyko_3

(Суббота 15:57:37)

greggelbak

(Среда 18:29:37)

vladisvlavs

(Среда 13:51:57)

add02102002

(Понедельник 22:37:15)

Диман221

(Понедельник 18:12:45)

almas051004

(Воскресенье 11:05:32)

megasuccessms

(Суббота 14:15:36)

nawe

(Пятница 22:25:23)

swoysb

(Пятница 14:55:29)

Вверх
04:32:58
ОбновитьСмайлыУправление мини-чатом
ЧАТ-PAWNO
2010-2025

vkontakte :samp-pawno.ru: