SA-MP Forums Archive
[Ayuda] Verificar vehiculo... - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Español/Spanish (https://sampforum.blast.hk/forumdisplay.php?fid=29)
+---- Thread: [Ayuda] Verificar vehiculo... (/showthread.php?tid=406324)



[Ayuda] Verificar vehiculo... - OTACON - 09.01.2013

Buenas a Todos, Necesito Ayuda con esto ke tengo la Lamparita quemada :P XD.

chequear todos los vehiculos y detectar los vehiculos sin conductor y dale una funcion.

hice estto pero esta imcompleto:

pawn Код:
stock VerifyVehicleDriver()
{
    for(new v=0; v<MAX_VEHICLES; v++)
    for(new i=0; i<GetMaxPlayers(); i++)
    if(IsPlayerConnected(i))
    if(IsPlayerInAnyVehicle(i))
    if(GetPlayerVehicleSeat(i) == 0)
    return 0;
}
Desde ya muichas Gracias.


Respuesta: [Ayuda] Verificar vehiculo... - CaptainMactavish - 09.01.2013

pawn Код:
#define IsVehicleOccupied(%0) VehicleOccupied[%0]

new bool:VehicleOccupied[MAX_VEHICLES char];
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER) VehicleOccupied[GetPlayerVehicleID(playerid)] = true;
    else if(oldstate == PLAYER_STATE_DRIVER) VehicleOccupied[GetPlayerVehicleID(playerid)] = false;
}

stock VerifyVehicleDriver()
{
    new count;
    for(new v=0; v<MAX_VEHICLES; v++)
    {
        if(IsVehicleOccupied(v)) count++;
    }
    return count;
}



Respuesta: [Ayuda] Verificar vehiculo... - OTACON - 10.01.2013

Gracias, pero aca hice uno y funciona, pero cuando se ejecutaa la funcion tira error Unknown Command,.

alguien sabe por ke puede ser?

pawn Код:
stock VerifyVehicleDriver()
{
    new bool:driver[MAX_PLAYERS];
    for(new i=0; i<GetMaxPlayers(); i++)
    {
        if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i) && GetPlayerVehicleSeat(i) == 0)
        {
            driver[GetPlayerVehicleID(i)] = true;
        }
    }
    for(new v=0; v<MAX_VEHICLES; v++)
    {
        if(driver[v] == false)
        {
            //funcion
        }
    }
    return 0;
}
y el plugin crashdetect tira error en el log, nada mas cuando ejecuto la funcion.

PHP код:
[debugRun time error 4"Array index out of bounds"
[debug]  Accessing element at index 500 past array upper bound 499
[debugAMX backtrace:
[
debug#0 00045b48 in ?? () from gm.amx
[debug#1 0000d250 in public cmd_comando () from gm.amx
[debug#2 native CallLocalFunction () [00472c00] from samp-server.exe
[debug#3 00000508 in public OnPlayerCommandText () from gm.amx 



Re: [Ayuda] Verificar vehiculo... - Daniel-92 - 10.01.2013

para vehiculos se usa MAX_VEHICLES y no MAX_PLAYERS, me refiero a la declaracion de la variable driver.


Respuesta: [Ayuda] Verificar vehiculo... - Jovanny - 10.01.2013

Quote:
Originally Posted by bytytus
Посмотреть сообщение
Gracias, pero aca hice uno y funciona, pero cuando se ejecutaa la funcion tira error Unknown Command,.

alguien sabe por ke puede ser?

pawn Код:
stock VerifyVehicleDriver()
{
    new bool:driver[MAX_PLAYERS];
    for(new i=0; i<GetMaxPlayers(); i++)
    {
        if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i) && GetPlayerVehicleSeat(i) == 0)
        {
            driver[GetPlayerVehicleID(i)] = true;
        }
    }
    for(new v=0; v<MAX_VEHICLES; v++)
    {
        if(driver[v] == false)
        {
            //funcion
        }
    }
    return 0;
}
y el plugin crashdetect tira error en el log, nada mas cuando ejecuto la funcion.

PHP код:
[debugRun time error 4"Array index out of bounds"
[debug]  Accessing element at index 500 past array upper bound 499
[debugAMX backtrace:
[
debug#0 00045b48 in ?? () from gm.amx
[debug#1 0000d250 in public cmd_comando () from gm.amx
[debug#2 native CallLocalFunction () [00472c00] from samp-server.exe
[debug#3 00000508 in public OnPlayerCommandText () from gm.amx 
si se trata de eficacia, es mejor la de CaptainMactavish


Respuesta: Re: [Ayuda] Verificar vehiculo... - OTACON - 10.01.2013

Quote:
Originally Posted by Daniel-92
Посмотреть сообщение
para vehiculos se usa MAX_VEHICLES y no MAX_PLAYERS, me refiero a la declaracion de la variable driver.
ahh XDD, no lo puse aproposito no me di cuenta XDD
Gracias .

Con razon tiraba error :P XDDD

EDIT:

@Jovanny por ke dices ke es mejor?


Respuesta: Re: [Ayuda] Verificar vehiculo... - oOFotherOo - 10.01.2013

Quote:
Originally Posted by bytytus
Посмотреть сообщение
ahh XDD, no lo puse aproposito no me di cuenta XDD
Gracias .

Con razon tiraba error :P XDDD

EDIT:

@Jovanny por ke dices ke es mejor?
Jovanny lo dice porque la funciуn del seсor CaptainMactavish ejecuta solamente un loop, pero la de usted ejecuta 2 loops.

Un saludo.


Respuesta: Re: [Ayuda] Verificar vehiculo... - OTACON - 10.01.2013

Quote:
Originally Posted by oOFotherOo
Посмотреть сообщение
Jovanny lo dice porque la funciуn del seсor CaptainMactavish ejecuta solamente un loop, pero la de usted ejecuta 2 loops.

Un saludo.
y por eso es mas eficas? O_O