SA-MP Forums Archive
Problem with exit from vehicle - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem with exit from vehicle (/showthread.php?tid=458749)



Problem with exit from vehicle - deimantas1 - 18.08.2013

Hi, I want to do, that if player is secured with belt, he wouldn't get out from vehicle. But always he can exit from vehicle.

I try:
Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(dirzas[playerid]==1)
{
   SendClientMessage(playerid,RED,"You are with belt!");
   return 0;
}
else
{
dirzas[playerid]=0;
return 1;
}
}
Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(dirzas[playerid]==1)
{
   SendClientMessage(playerid,RED,"You are with belt!");
   return 0;
}
else
{
dirzas[playerid]=0;
return 1;
}
return 0;
}
Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(dirzas[playerid]==1)
{
   SendClientMessage(playerid,RED,"You are with belt!");
   return 0;
}
else
{
dirzas[playerid]=0;
return 1;
}
    return 1;
}
Thanks.


Re: Problem with exit from vehicle - Edix - 18.08.2013

Instead of just returning 0; try using this:
https://sampwiki.blast.hk/wiki/GetPlayerVehicleSeat
and then this:
https://sampwiki.blast.hk/wiki/Function:PutPlayerInVehicle


Re: Problem with exit from vehicle - Youarex - 18.08.2013

It doesn't seem work for the driver unless you call in between function like SetPlayerPos

pawn Код:
{
    new
        vehid, seatid;
       
    vehid = GetPlayerVehicleID(playerid);
    seatid = GetPlayerVehicleSeat(playerid);
   
    if(seatid == 128)
    {
        return SendClientMessage(playerid, 0xFFFFFFFF, "An error has prevented us from returning the seat ID.");
    }
   
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) SetPlayerPos(playerid, 0.0, 0.0, 0.0);
    //This is necessary, otherwise it won't work for the driver
    PutPlayerInVehicle(playerid, vehid, seatid);
    SendClientMessage(playerid,RED,"You are with belt!");
}



Re: Problem with exit from vehicle - Edix - 18.08.2013

Quote:
Originally Posted by Youarex
Посмотреть сообщение
It doesn't seem work for the driver unless you call in between function like SetPlayerPos

pawn Код:
{
    new
        vehid, seatid;
       
    vehid = GetPlayerVehicleID(playerid);
    seatid = GetPlayerVehicleSeat(playerid);
   
    if(seatid == 128)
    {
        return SendClientMessage(playerid, 0xFFFFFFFF, "An error has prevented us from returning the seat ID.");
    }
   
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) SetPlayerPos(playerid, 0.0, 0.0, 0.0);
    //This is necessary, otherwise it won't work for the driver
    PutPlayerInVehicle(playerid, vehid, seatid);
    SendClientMessage(playerid,RED,"You are with belt!");
}
You dont need to get the vehid again as its in the callback already "(playerid, vehicleid)" less lines YAY \O/.


Re: Problem with exit from vehicle - Youarex - 18.08.2013

Quote:
Originally Posted by Edix
Посмотреть сообщение
You dont need to get the vehid again as its in the callback already "(playerid, vehicleid)" less lines YAY \O/.
Yes, you are absolutely 100% correct. There's already vehicleid parameter in the OnPlayerExitVehicle callback, but there's no callback in my example Mr. Wiseman


Re: Problem with exit from vehicle - deimantas1 - 18.08.2013

Quote:
Originally Posted by Youarex
Посмотреть сообщение
It doesn't seem work for the driver unless you call in between function like SetPlayerPos

pawn Код:
{
    new
        vehid, seatid;
       
    vehid = GetPlayerVehicleID(playerid);
    seatid = GetPlayerVehicleSeat(playerid);
   
    if(seatid == 128)
    {
        return SendClientMessage(playerid, 0xFFFFFFFF, "An error has prevented us from returning the seat ID.");
    }
   
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) SetPlayerPos(playerid, 0.0, 0.0, 0.0);
    //This is necessary, otherwise it won't work for the driver
    PutPlayerInVehicle(playerid, vehid, seatid);
    SendClientMessage(playerid,RED,"You are with belt!");
}
Thanks, working.


Re: Problem with exit from vehicle - Paul1990 - 18.08.2013

Its a Pawn Script.
new
vehid, seatid;

vehid = GetPlayerVehicleID(playerid);
seatid = GetPlayerVehicleSeat(playerid);

if(seatid == 12
{
return SendClientMessage(playerid, 0xFFFFFFFF, "An error has prevented us from returning the seat ID.");
}

if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) SetPlayerPos(playerid, 0.0, 0.0, 0.0);
//This is necessary, otherwise it won't work for the driver
PutPlayerInVehicle(playerid, vehid, seatid);
SendClientMessage(playerid,RED,"You are with belt!");
}