if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER
public OnPlayerEnterVehicle(playerid, vehicleid) { new vmodel = GetVehicleModel(vehicleid); new Float:x, Float:y, Float:z; GetPlayerPos(playerid, x, y, z); if(pInfo[playerid][pLic1] == 1) { if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) { if(pInfo[playerid][pGroup] == 0 && cInfo[vehicleid][cGroup] > 0) { SetPlayerPos(playerid, x, y, z+3); if(cInfo[vehicleid][cGroup] == 1) { SendClientMessage(playerid, -1, "You are not part of Los Santos Police Department."); } } else if(pInfo[playerid][pGroupRank] < cInfo[vehicleid][cRank]) { new rank = cInfo[vehicleid][cRank]; new string[256]; format(string, sizeof(string), "You must be a rank %d police officer to drive this car.", rank); SendClientMessage(playerid, -1, string); } } else return 0; } else { if(vmodel == 481 || vmodel == 510 || vmodel == 509) { new engine, lights, alarm, doors, bonnet, boot, objective; GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective); SetVehicleParamsEx(vehicleid, VEHICLE_PARAMS_ON, lights, alarm, doors, bonnet, boot, objective); } else if(vmodel == 462) { return 0; } else { if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) { SetPlayerPos(playerid, x, y, z+3); SendClientMessage(playerid, -1, "You don't have a drivings license, a checkpoint has been set on your map."); SetPlayerCheckpoint(playerid, 1219.1997,-1811.9343,16.5938, 5); return 1; } else return 0; } } return 1; }
Try using OnPlayerStateChange instead of OnPlayerEnterVehicle, it might help.
Edit: Also a little bit of a tip, I'd use RemovePlayerFromVehicle function instead of teleporting them. |
public OnPlayerEnterVehicle(playerid, vehicleid)
{
new vmodel = GetVehicleModel(vehicleid);
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
if(pInfo[playerid][pLic1] == 1)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(pInfo[playerid][pGroup] == 0 && cInfo[vehicleid][cGroup] > 0)
{
SetPlayerPos(playerid, x, y, z+3);
if(cInfo[vehicleid][cGroup] == 1)
{
SendClientMessage(playerid, -1, "You are not part of Los Santos Police Department.");
}
}
else if(pInfo[playerid][pGroupRank] < cInfo[vehicleid][cRank])
{
new rank = cInfo[vehicleid][cRank];
new string[256];
format(string, sizeof(string), "You must be a rank %d police officer to drive this car.", rank);
SendClientMessage(playerid, -1, string);
}
}
else return 0;
}
else
{
if(vmodel == 481 || vmodel == 510 || vmodel == 509)
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid, VEHICLE_PARAMS_ON, lights, alarm, doors, bonnet, boot, objective);
}
else if(vmodel == 462)
{
return 0;
}
else
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
SetPlayerPos(playerid, x, y, z+3);
ClearAnimations(playerid); // Edited
SendClientMessage(playerid, -1, "You don't have a drivings license, a checkpoint has been set on your map.");
SetPlayerCheckpoint(playerid, 1219.1997,-1811.9343,16.5938, 5);
return 1;
}
else return 0;
}
}
return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
if(ispassenger == 0)
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) { if(ispassenger == 0) { if(pInfo[playerid][pLic1] == 0) { SetPlayerPos(playerid, x, y, z+3); SendClientMessage(playerid, -1, "You do not have a driver license. A checkpoint has been set on your map."); SetPlayerCheckpoint(playerid, 1219.1997,-1811.9343,16.5938, 5); return 1; } if(pInfo[playerid][pLic1] == 1) { if(pInfo[playerid][pGroup] == 0 && cInfo[vehicleid][cGroup] > 0) { SetPlayerPos(playerid, x, y, z+3); if(cInfo[vehicleid][cGroup] == 1) { SendClientMessage(playerid, -1, "You are not part of Los Santos Police Department."); } } if(pInfo[playerid][pGroupRank] < cInfo[vehicleid][cRank]) { new rank = cInfo[vehicleid][cRank]; new string[256]; format(string, sizeof(string), "You must be a rank %d police officer to drive this car.", rank); SendClientMessage(playerid, -1, string); } if(vmodel == 481 || vmodel == 510 || vmodel == 509) { new engine, lights, alarm, doors, bonnet, boot, objective; GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective); SetVehicleParamsEx(vehicleid, VEHICLE_PARAMS_ON, lights, alarm, doors, bonnet, boot, objective); } if(vmodel == 462) { return 0; } return 1; } } return 1; }