[ajuda]GetClosestCar
#1

alguem sabe fazer estб funзгo?
"GetClosestCar"
Tb queria perguntar se dб para com esta funзгo meter o player nesse carro
Reply
#2

Sim, essa funзгo tem no include uf. Mas nгo te aconselho pois ela utiliza uma data de stocks.

Eu usei desta forma hб uns tempos, contudo ela nгo estб perfeita e alйm do mais nгo estб optimizada. Tambйm nгo foi full tested.

pawn Код:
stock Float:GetDistanceBetwinPoint(p1, Float:x2, Float:y2, Float:z2) //Coole[AG] gave me from some script
{
    new Float:XX, Float:YY, Float:ZZ;
    GetPlayerPos(p1, XX, YY, ZZ);
    return floatsqroot(floatpower(floatabs(floatsub(x2,XX)),2)+floatpower(floatabs(floatsub(y2,YY)),2)+floatpower(floatabs(floatsub(z2,ZZ)),2));
}

stock GetClosestVehicle(playerid) //Coole[AG] gave me from some script
{
    new car, Float:ang;
    car = -1;
    ang = 9999.9999;

    for(new i = 0; i < MAX_PLAYERS; i++)
    for(new v = 0; v < MAX_VEHICLES; v++)
    {
        #define INVALID_ID (0xFFFF) //65535
        if(!IsPlayerConnected(i) && v == INVALID_ID) continue;
        if(!IsPlayerInVehicle(i, v))
        {
            new Float:X, Float:Y, Float:Z;
            GetVehiclePos(v, X, Y, Z);

            if(ang > GetDistanceBetwinPoint(playerid, X, Y, Z))
            {
                ang = GetDistanceBetwinPoint(playerid, X, Y, Z);
                car = v;
            }
        }
    }
    return car;
}

Para usares й simplesmente:

pawn Код:
PutPlayerInVehicle(playerid, GetClosestVehicle(playerid), seatid);

Seat ids:

0 - Driver
1 - Front Passenger
2 - Back left passenger
3 - Back right passenger
4+ - Passenger seats (coach etc.)
Reply
#3

da estes erros:

Код:
C:\Program Files\Rockstar Games\GTA San Andreas\server\gamemodes\BC_RP.pwn(19869) : warning 219: local variable "X" shadows a variable at a preceding level
C:\Program Files\Rockstar Games\GTA San Andreas\server\gamemodes\BC_RP.pwn(19869) : warning 219: local variable "Y" shadows a variable at a preceding level
C:\Program Files\Rockstar Games\GTA San Andreas\server\gamemodes\BC_RP.pwn(19869) : warning 219: local variable "Z" shadows a variable at a preceding level
C:\Program Files\Rockstar Games\GTA San Andreas\server\gamemodes\BC_RP.pwn(19870) : error 035: argument type mismatch (argument 2)
C:\Program Files\Rockstar Games\GTA San Andreas\server\gamemodes\BC_RP.pwn(19875) : warning 213: tag mismatch
C:\Program Files\Rockstar Games\GTA San Andreas\server\gamemodes\BC_RP.pwn(19875) : warning 213: tag mismatch
C:\Program Files\Rockstar Games\GTA San Andreas\server\gamemodes\BC_RP.pwn(19875) : warning 213: tag mismatch
C:\Program Files\Rockstar Games\GTA San Andreas\server\gamemodes\BC_RP.pwn(19877) : warning 213: tag mismatch
C:\Program Files\Rockstar Games\GTA San Andreas\server\gamemodes\BC_RP.pwn(19877) : warning 213: tag mismatch
C:\Program Files\Rockstar Games\GTA San Andreas\server\gamemodes\BC_RP.pwn(19877) : warning 213: tag mismatch
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#4

Estб tudo direito o que eu mandei, atй compila num gm em branco.

Ao tempo que programas acho que jб saberias mudar isso do mesmo uso de variбveis.

Em relaзгo ao resto sу vendo, mas retira a tag "Float:" da stock a ver.
Reply
#5

Quote:
Originally Posted by russooooo
pawn Код:
stock GetClosestVehicle(p1) //Coole[AG] gave me from some script//troquei playerid por p1
{
    new car, Float:ang;
    car = -1;
    ang = 9999.9999;

    for(new i = 0; i < MAX_PLAYERS; i++)
    for(new v = 0; v < MAX_VEHICLES; v++)
    {
        #define INVALID_ID (0xFFFF) //65535
        if(!IsPlayerConnected(i) && v == INVALID_ID) continue;
        if(!IsPlayerInVehicle(i, v))
        {
            new Float:X, Float:Y, Float:Z;
            GetVehiclePos(v, X, Y, Z);

            if(ang > GetDistanceBetwinPoint(p1, X, Y, Z))//troquei playerid por p1
            {
                ang = GetDistanceBetwinPoint(p1, X, Y, Z);//troquei playerid por p1
                car = v;
            }
        }
    }
    return car;
}
fiz uma troca de playerid para 1 faz algum mal?
Reply
#6

O que й que alteraste?
Reply
#7

esqueзe, sou mesmo noob, ja tinho um float X, Y, Z alterei para X3, Y3, Z3. e deu
Reply
#8

Uma duvida, o que essa funзгo faz?
Reply
#9

Vai buscar o id do carro mais proximo de ti
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)