else if(newcar >= 112 && newcar <= 130)
{
if (HireCar[playerid] != newcar)
{
format(string, sizeof(string), "Vehicle Rental:Rent a vehicle for $%d /rentcar",SBizzInfo[1][sbEntranceCost]);
SendClientMessage(playerid,COLOR_WHITE,string);
SendClientMessage(playerid,COLOR_GREEN,"Rent a vehicle,and you will be able to /rlock your car");
TogglePlayerControllable(playerid, 0);
VehAsk[playerid] = 1;
}
}
if(IsABus(newcar))
{
if(PlayerInfo[playerid][pJob] != 14)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_GREY,"You don't have keys to this bus.");
TogglePlayerControllable(playerid,true);
VehAsk[playerid] = 0;
}
else
{
if(JobDelay[playerid] > 0)
{
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid,true);
VehAsk[playerid] = 0;
SendClientMessage(playerid, COLOR_GREY," You need to wait for Your last route time to reduce !");
}
else if(BusRoute[playerid] == 0)
{
ShowMenuForPlayer(BusRoutesM, playerid);
BusRoute[playerid] = 1;
gPlayerCheckpointStatus[playerid] = CHECKPOINT_BUSROUTE;
BusRouteS[playerid] = 0;
}
}
}
else if(IsATowcar(newcar))
{
if(PlayerInfo[playerid][pJob] != 7)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_GREY,"You don't have keys of this vehicle.");
TogglePlayerControllable(playerid,true);
VehAsk[playerid] = 0;
}
}
Then do it under OnPlayerUpdate
Then do if(IsPlayerInAnyVehicle(playerid)) The get the players states if he is the driver and put ur message and code there. Sorry that I can't give an example I am on my phone. |
Well for one thing, why do you get the player's vehicle id twice at the top? Secondly, I wouldn't use else if's and you checked twice if the player was in the state 'driver'. That's probably why.
|
I tried with OnPlayerEnterVehicle, it works but there's a massive spam when I enter the bike and I have to job.
![]() |
enum pInfo { bool:ConditionAAA[MAX_PLAYERS] }
OnPlayerConnect(playerid) { Player[playerid][ConditionAAA] = false; return 1; }
COMMAND:whattodo(playerid,params[]) { if(Player[playerid][ConditionAAA]) // If condition is true, nothing will happen. return 1; } // If not, then server will send message. SendClientMessage(playerid,COLOR_WHITE,"Bla bla"); return 1; }
if (IsAPizzabike(vehicleid) && !ispassenger)
{
if(PlayerInfo[playerid][pJob] != 17)
{
SetVehicleParamsForPlayer(vehicleid,playerid,0,1);
new Float:cx, Float:cy, Float:cz;
GetPlayerPos(playerid, cx, cy, cz);
SetPlayerPos(playerid, cx, cy, cz);
SendClientMessage(playerid,COLOR_GREY," Only Pizza Delivers can drive this bike!");
LockCars[playerid][0] = 3;
LockCars[playerid][1] = vehicleid;
}
else if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
SendClientMessage(playerid, COLOR_WHITE,"Type /startpizza to begin a pizza mission.");
}
}
if(IsPlayerInAnyVehicle(playerid))
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if (IsAPizzabike(vehicleid))
{
SendClientMessage(playerid, COLOR_WHITE, "Type /startpizza to begin your mission.");
}
}
}
if(IsAPizzabike(newcar))
{
if(PlayerInfo[playerid][pJob] != 17)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_GREY,"You don't have keys to this bike.");
TogglePlayerControllable(playerid,true);
VehAsk[playerid] = 0;
}
else
{
SendClientMessage(playerid, COLOR_WHITE,"Type /startpizza to begin a pizza mission.");
}
}