Driving license - 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: Driving license (
/showthread.php?tid=667278)
Driving license -
KamilPolska - 16.06.2019
Hello. I wanted to remind myself how it's done when getting into a vehicle, it popped up the message that "You do not have a driving license, you decide to leave the vehicle!". How to make it work well?
Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) //test123
{
if(playerid == vehicleid)
{
if(PlayerInfo[playerid][DrivingLicense] == 0)
{
SendClientMessage(playerid, -1, "You do not have a driving license, you decide to leave the vehicle!");
ClearAnimations(playerid);
}
}
return 1;
}
Re: Driving license -
Zipfer247 - 16.06.2019
Try this. I didn't test it.
pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate){
if(newstate == PLAYER_STATE_DRIVER){
if(PlayerInfo[playerid][pDrivingLicense] == 0){
SendClientMessage(playerid, -1, "You do not have a driving license, you decide to leave the vehicle!");
RemovePlayerFromVehicle(playerid);
}
}
return 1;
}
Re: Driving license -
KamilPolska - 16.06.2019
Thank you also works nicely.

It works but I'm not sure if this is correct for this public.
Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) //test123
{
if(vehicleid)
{
if(PlayerInfo[playerid][DrivingLicense] == 0)
{
SendClientMessage(playerid, -1, "You do not have a driving license, you decide to leave the vehicle!");
ClearAnimations(playerid);
}
}
return 1;
}
Or
Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) //test123
{
if(PlayerInfo[playerid][DrivingLicense] == 0)
{
SendClientMessage(playerid, -1, "You do not have a driving license, you decide to leave the vehicle!");
ClearAnimations(playerid);
}
return 1;
}
Re: Driving license -
Stev - 16.06.2019
They both do the same thing, but I would recommend OnPlayerStateChange
Re: Driving license -
KamilPolska - 16.06.2019
Yes, but OnPlayerEnterVehicle has my plus that it does not get into the vehicle just shows the message by clicking "F" or "Enter". I want to make sure I do not do the wrong thing in OnPlayerEnterVehicle. Later it may happen that it will be bugs.
Re: Driving license -
SiaReyes - 16.06.2019
Just Get the player pos and set the player pos!
pawn Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) //test123
{
if(playerid == vehicleid)
{
if(PlayerInfo[playerid][DrivingLicense] == 0)
{
new Float:POS[3];
GetPlayerPos(playerid, POS[0], POS[1], POS[2]);
SetPlayerPos(playerid, POS[0], POS[1], POS[2]);
SendClientMessage(playerid, -1, "You do not have a driving license, you decide to leave the vehicle!");
return true;
}
}
return 1;
}
Re: Driving license -
KamilPolska - 16.06.2019
Oh, that's good for me too. Thanks

. What should I do with this " if(playerid == vehicleid) " ?
Re: Driving license -
SiaReyes - 17.06.2019
Quote:
Originally Posted by KamilPolska
Oh, that's good for me too. Thanks  . What should I do with this " if(playerid == vehicleid) " ?
|
Remove that if statement!