Problem with exit from vehicle
#1

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.
Reply
#2

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

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!");
}
Reply
#4

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/.
Reply
#5

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
Reply
#6

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.
Reply
#7

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!");
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)