[AYUDA] DistanciaEntreJugadorAlVehiculo
#1

Hola, yo tengo este Codigo, que se fija el Auto que tiene mas cerca el Jugador...

pawn Код:
forward Float:DistanciaEntreJugadorAlVehiculo(playerid, vehicleid);
public DistanciaEntreJugadorAlVehiculo(playerid, vehicleid)
{
    new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
    if(!IsPlayerConnected(playerid))
    {
        return -1.00;
    }
    GetPlayerPos(playerid, x1, y1, z1);
    GetVehiclePos(vehicleid, x2, y2, z2);
    return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}

forward VehiculoMasCerca(p1);
public VehiculoMasCerca(p1);
{
    new x,Float:dis,Float:dis2,vehicle;
    vehicle = -1;
    dis = 99999.99;
    for (x = 0; x < MAX_VEHICLES; x++)
    {
        if(x != p1)
        {
            dis2 = DistanciaEntreJugadorAlVehiculo(p1, x);
            if(dis2 < dis && dis2 != -1.00)
            {
                dis = dis2;
                vehicle = x;
            }
        }
    }
    return vehicle;
}
Pero al Compilar...

Код:
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\pawno\include\progress.inc(63) : warning 219: local variable "x" shadows a variable at a preceding level
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(3924) : warning 219: local variable "x" shadows a variable at a preceding level
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(5282) : warning 219: local variable "x" shadows a variable at a preceding level
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(5296) : warning 219: local variable "x" shadows a variable at a preceding level
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(11206) : warning 219: local variable "x" shadows a variable at a preceding level
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(11206) : warning 219: local variable "dis" shadows a variable at a preceding level
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(11214) : warning 219: local variable "x" shadows a variable at a preceding level
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(11232) : warning 219: local variable "x" shadows a variable at a preceding level
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(11232) : warning 219: local variable "dis" shadows a variable at a preceding level
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(11240) : warning 219: local variable "x" shadows a variable at a preceding level
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(11304) : warning 219: local variable "x" shadows a variable at a preceding level
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(11684) : error 025: function heading differs from prototype
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(11685) : error 025: function heading differs from prototype
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(11690) : warning 213: tag mismatch
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(11694) : warning 213: tag mismatch
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(11699) : error 055: start of function body without function header
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(11701) : error 010: invalid function or declaration
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(11703) : error 010: invalid function or declaration
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(11705) : error 010: invalid function or declaration
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(11708) : error 010: invalid function or declaration
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(11715) : error 010: invalid function or declaration
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(11721) : warning 219: local variable "x" shadows a variable at a preceding level
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(11721) : warning 219: local variable "dis" shadows a variable at a preceding level
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(11721) : warning 219: local variable "dis2" shadows a variable at a preceding level
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(12188) : warning 219: local variable "x" shadows a variable at a preceding level
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(12391) : warning 219: local variable "x" shadows a variable at a preceding level
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(12404) : warning 219: local variable "x" shadows a variable at a preceding level
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(12665) : warning 219: local variable "x" shadows a variable at a preceding level
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(13243) : warning 203: symbol is never used: "dis"
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(13243) : warning 203: symbol is never used: "dis2"
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(13243) : warning 203: symbol is never used: "vehicle"
C:\Documents and Settings\Administrador\Escritorio\CoD_Black_Ops\gamemodes\LSZombies.pwn(13243) : warning 203: symbol is never used: "x"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


8 Errors.
No se que puedo hacer..

Si alguien me Ayudase
Reply
#2

creo qe ya habia una funcion, qe era de mirar los vehiculos mas cercanos
Reply
#3

Gracias, pero ahora que me fijo, encontre un ";" en un public, luego un "Float:" que no habia puesto en el public

Ahora posteo el Codigo con los Errores Solucionados.
Reply
#4

pawn Код:
forward Float:DistanciaEntreJugadorAlVehiculo(playerid, vehicleid);
public Float:DistanciaEntreJugadorAlVehiculo(playerid, vehicleid)
{
    new Float:pX,Float:pY,Float:pZ,Float:vX,Float:vY,Float:vZ;
    GetPlayerPos(playerid, pX, pY, pZ);
    GetVehiclePos(vehicleid, vX, vY, vZ);
    return floatsqroot(floatpower(floatabs(floatsub(vX,pX)),2)+floatpower(floatabs(floatsub(vY,pY)),2)+floatpower(floatabs(floatsub(vZ,pZ)),2));
}

forward VehiculoMasCerca(p1);
public VehiculoMasCerca(p1)
{
    new vx,Float:distancia,Float:distancia2,vehicle;
    vehicle = -1;
    distancia = 99999.99;
    for (vx = 0; vx < MAX_VEHICLES; vx++)
    {
        if(vx != p1)
        {
            distancia2 = DistanciaEntreJugadorAlVehiculo(p1, vx);
            if(distancia2 < distancia && distancia2 != -1.00)
            {
                distancia = distancia2;
                vehicle = vx;
            }
        }
    }
    return vehicle;
}
Y ningun Error

Quote:

Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase

Igual Gracias A Veto :P
Reply
#5

ok, igual cualquier inquietud no dudes en preguntar xD
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)