Radar bug
#1

If +two players are in the same range and they used this command it will be bugged
pawn Код:
public OnVehicleDeath(vehicleid, killerid)
{
    DestroyObject(obj1[vehicleid]);
    DestroyObject(obj2[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))
        {
            PlayerTextDrawHide (i, RadarHud);
            PlayerTextDrawHide (i, DashCamText);
            PlayerTextDrawHide (i, VehicleModel);
        }
    }
    return 1;
}
new VehicleModel22[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" };

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 (playerid,vehid)
{
    new id = GetVehicleInfrontID (playerid);
    if (id < 0)
    {
        for (new i = 0; i < MAX_PLAYERS; i++)
        {
            PlayerTextDrawSetString (i,RadarHud, "Speed:-");
            PlayerTextDrawSetString (i,VehicleModel,"Car Model:-");
        }
    }
    else
    {
        new str[258], Float: velocityX, Float: velocityY, Float: velocityZ;
        GetVehicleVelocity (id, velocityX, velocityY, velocityZ);
        new speed = floatround (floatsqroot (floatpower (velocityX, 2) + floatpower (velocityY, 2) + floatpower (velocityZ, 2)) * 187.666667, floatround_round);
        for (new i = 0; i < MAX_PLAYERS; i++)
        {
            format (str, sizeof (str), "Speed: %d", speed);
            PlayerTextDrawSetString (i,RadarHud, str);
            format (str, sizeof (str), "Car Model: %s", VehicleModel22 [GetVehicleModel (id) - 400]);
            PlayerTextDrawSetString (i,VehicleModel, str);
        }
    }
    for (new i = 0; i < MAX_PLAYERS; i++)
    {
        if (IsPlayerInVehicle (i, vehid))
        {
            PlayerTextDrawShow (i, RadarHud);
            PlayerTextDrawShow (i, DashCamText);
            PlayerTextDrawShow (i, VehicleModel);
        }
    }
    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)
                {
                    PlayerTextDrawShow (i, RadarHud);
                    PlayerTextDrawShow (i, DashCamText);
                    if (CheckingSpeed [vehid] > 0)
                    {
                        PlayerTextDrawShow (i, VehicleModel);
                    }
                    else
                    {
                        PlayerTextDrawHide(i, VehicleModel);
                    }
                }
                else
                {
                    PlayerTextDrawHide (i, RadarHud);
                    PlayerTextDrawHide (i, DashCamText);
                }
            }

            else
            {
                PlayerTextDrawHide (i, RadarHud);
                PlayerTextDrawHide (i, VehicleModel);
                PlayerTextDrawHide (i, DashCamText);
                OldVehID [i] = 0;
            }
    }
    }
    return 1;
}
Command
pawn Код:
CMD:dcam(playerid, params[])
{
    if(DashCamActivated[playerid] == false)
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            new vehid = GetPlayerVehicleID (playerid);
            if(IsACop(playerid))
            {
                if (VehRadarID [vehid] == -1) return 1;
                {
                    CheckingSpeed [vehid] = SetTimerEx ("UpdateSpeed", 100, 1, "d", vehid);
                    PlayerTextDrawShow (playerid,RadarHud);
                    PlayerTextDrawShow (playerid,VehicleModel);
                    PlayerTextDrawShow (playerid,DashCamText);
                    DashCamActivated[playerid] = true;
                }
            }
        }
    }
    else
    {
        DashCamActivated[playerid] = false;
        new vehid = GetPlayerVehicleID (playerid);
        if(CheckingSpeed[vehid] > 0)
        {
            {
                KillTimer (CheckingSpeed [vehid]);
                CheckingSpeed [vehid] = -1;
                PlayerTextDrawHide (playerid, RadarHud);
                PlayerTextDrawHide (playerid, VehicleModel);
                PlayerTextDrawHide (playerid, DashCamText);
            }
        }
    }
    return 1;
}
Screenshots


First one is the good one
Reply
#2

someone?
Reply
#3

Whats bugged about it? It shows the wrong vehicle name?
Reply
#4

Quote:
Originally Posted by Facerafter
Посмотреть сообщение
Whats bugged about it? It shows the wrong vehicle name?
When two players are in the same range of eachother is will show your own vehicle
Reply
#5

You use PlayerTextDraws but you still have to make an array MAX_PLAYERS large, otherwise the mode doesn't know which text draw id to update for which player, there's your problem - just make a per-player variable.
Also, stop using redundant things like IsPlayerConnected check, it is written on the Wiki that in most cases it can be omitted and just think about it: can a player e.g. be in a vehicle if he isn't connected? So just use one check.
Reply
#6

Quote:
Originally Posted by Virtual1ty
Посмотреть сообщение
You use PlayerTextDraws but you still have to make an array MAX_PLAYERS large, otherwise the mode doesn't know which text draw id to update for which player, there's your problem - just make a per-player variable.
Also, stop using redundant things like IsPlayerConnected check, it is written on the Wiki that in most cases it can be omitted and just think about it: can a player e.g. be in a vehicle if he isn't connected? So just use one check.
I had first the MAX PLAYER textdraw but that gives the issue too
Reply
#7

I have tryed the MAX_PLAYERS again, but it still doesnt work that way
Reply
#8

someone
Reply
#9

Why is noone helping me
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)