SA-MP Forums Archive
Duda - 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: Duda (/showthread.php?tid=372953)



Duda - chucho - 28.08.2012

existe algun codigo que no permita al jugador salir de vehiculo a menos que muera?


Respuesta: Duda - OTACON - 28.08.2012

pawn Код:
static
    PlayerQuieto[MAX_PLAYERS],
    VehiculoID[MAX_PLAYERS],
    AsientoID[MAX_PLAYERS];

public OnPlayerStateChange(playerid,newstate,oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        if(PlayerQuieto[playerid] == 0)
        {
            VehiculoID[playerid] = GetPlayerVehicleID(playerid);
            AsientoID[playerid] = GetPlayerVehicleSeat(playerid);
        }
    }
    if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
    {
        if(PlayerQuieto[playerid] == 1)
        {
            PutPlayerInVehicle(playerid, VehiculoID[playerid], AsientoID[playerid]);
        }
    }
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    VehiculoID[playerid] = 0;
    AsientoID[playerid] = 0;
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    VehiculoID[killerid] = 0;
    AsientoID[killerid] = 0;
    return 1;
}



Respuesta: Duda - Bu11Sh0t - 28.08.2012

pawn Код:
static
    PlayerQuieto[MAX_PLAYERS],
    VehiculoID[MAX_PLAYERS],
    AsientoID[MAX_PLAYERS];

public OnPlayerStateChange(playerid,newstate,oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        if(PlayerQuieto[playerid] == 0)
        {
            VehiculoID[playerid] = GetPlayerVehicleID(playerid);
            AsientoID[playerid] = GetPlayerVehicleSeat(playerid);
            PlayerQuieto[playerid] = 1;
        }
    }
    if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
    {
        if(PlayerQuieto[playerid] == 1)
        {
            PutPlayerInVehicle(playerid, VehiculoID[playerid], AsientoID[playerid]);
            PlayerQuieto[playerid] = 0;
        }
    }
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    VehiculoID[playerid] = 0;
    AsientoID[playerid] = 0;
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    VehiculoID[killerid] = 0;
    AsientoID[killerid] = 0;
    return 1;
}
Es el mismo cуdigo de arriba, solo que le arregle un error que iba a dar


Respuesta: Duda - OTACON - 28.08.2012

Quote:
Originally Posted by Bu11Sh0t
Посмотреть сообщение
pawn Код:
static
    PlayerQuieto[MAX_PLAYERS],
    VehiculoID[MAX_PLAYERS],
    AsientoID[MAX_PLAYERS];

public OnPlayerStateChange(playerid,newstate,oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        if(PlayerQuieto[playerid] == 0)
        {
            VehiculoID[playerid] = GetPlayerVehicleID(playerid);
            AsientoID[playerid] = GetPlayerVehicleSeat(playerid);
            PlayerQuieto[playerid] = 1;
        }
    }
    if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
    {
        if(PlayerQuieto[playerid] == 1)
        {
            PutPlayerInVehicle(playerid, VehiculoID[playerid], AsientoID[playerid]);
            PlayerQuieto[playerid] = 0;
        }
    }
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    VehiculoID[playerid] = 0;
    AsientoID[playerid] = 0;
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    VehiculoID[killerid] = 0;
    AsientoID[killerid] = 0;
    return 1;
}
Es el mismo cуdigo de arriba, solo que le arregle un error que iba a dar
esta mal, lo ke agregaste, por ke cuando se suba de se blokeada el asiento, pero lo dejara sali igual, ya ke cuando subir le das acceso a la otra funcion y cuando bajas le das a la otra.

eso lo deberia colocar en algun comando, por ejemplo . /Seguros .

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp("/Seguros ", cmdtext, true, 10) == 0)
    {
        if(PlayerQuieto[playerid] == 0)
        {
            PlayerQuieto[playerid] = 1;
        }
        else if(PlayerQuieto[playerid] == 1)
        {
            PlayerQuieto[playerid] = 0;
        }
        return 1;
    }
    return 0;
}