17.12.2014, 15:29
So i have the next code , i want to restrict the users from starting their cars when they have a flat:
I added the restriction but it's not working , i still can start the car, my server uses 4 personal vehicles , but if i let only 2 on the row it's working , any idees?
This is the restriction who is not working if i put 4 cars:
pawn Код:
if((newkeys == KEY_SUBMISSION)&&(IsPlayerInAnyVehicle(playerid))&&(GetPlayerState(playerid)==PLAYER_STATE_DRIVER))
{
new sendername[MAX_PLAYER_NAME];
new vehicless;
new newcar = GetPlayerVehicleID(playerid);
if(!IsABike(newcar))
{
if(playerVariables[playerid][pCarID1] != newcar || playerVariables[playerid][pCarID2] != newcar || playerVariables[playerid][pCarID3] != newcar || playerVariables[playerid][pCarID4] != newcar)
{
vehicless = GetVehicleModel(newcar) - 400;
vehicless = GetVehicleModel(newcar) - 400;
GetPlayerName(playerid, sendername, sizeof(sendername));
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, -1, "You need to be the driver of the vehicle");
GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
if(HUndercover[playerid] == 0)
{
if(engine == 1)
{
SetVehicleParamsEx(GetPlayerVehicleID(playerid), 0, lights, alarm, doors, bonnet, boot, objective);
format(szMessage, sizeof(szMessage), "* %s stops the engine of his %s.", sendername, aVehicleNames[vehicless]);
nearByMessage(playerid, COLOR_PURPLE, szMessage);
}
else
{
SetVehicleParamsEx(GetPlayerVehicleID(playerid), 1, lights, alarm, doors, bonnet, boot, objective);
format(szMessage, sizeof(szMessage), "* %s starts the engine of his %s.", sendername, aVehicleNames[vehicless]);
nearByMessage(playerid, COLOR_PURPLE, szMessage);
}
}
else
{
if(engine == 1)
{
SetVehicleParamsEx(GetPlayerVehicleID(playerid), 0, lights, alarm, doors, bonnet, boot, objective);
format(szMessage, sizeof(szMessage), "* An unknown hitman stops the engine of his %s.", aVehicleNames[vehicless]);
nearByMessage(playerid, COLOR_PURPLE, szMessage);
}
else
{
SetVehicleParamsEx(GetPlayerVehicleID(playerid), 1, lights, alarm, doors, bonnet, boot, objective);
format(szMessage, sizeof(szMessage), "* An unknown hitman starts the engine of his %s.", aVehicleNames[vehicless]);
nearByMessage(playerid, COLOR_PURPLE, szMessage);
}
}
}
else
{ vehicless = GetVehicleModel(newcar) - 400;
vehicless = GetVehicleModel(newcar) - 400;
GetPlayerName(playerid, sendername, sizeof(sendername));
if(playerVariables[playerid][TireFlat] > 0)
{
if(engine == 1)
{
SetVehicleParamsEx(GetPlayerVehicleID(playerid), 0, lights, alarm, doors, bonnet, boot, objective);
format(szMessage, sizeof(szMessage), "* %s stops the engine of his %s.", sendername, aVehicleNames[vehicless]);
nearByMessage(playerid, COLOR_PURPLE, szMessage);
}
else
{
SetVehicleParamsEx(GetPlayerVehicleID(playerid), 1, lights, alarm, doors, bonnet, boot, objective);
format(szMessage, sizeof(szMessage), "* %s starts the engine of his %s.", sendername, aVehicleNames[vehicless]);
nearByMessage(playerid, COLOR_PURPLE, szMessage);
}
}
else SendClientMessage(playerid, -1, "You can't start your car because you have flat tire.");
}
}
return 1;
}
This is the restriction who is not working if i put 4 cars:
pawn Код:
if(playerVariables[playerid][pCarID1] != newcar || playerVariables[playerid][pCarID2] != newcar || playerVariables[playerid][pCarID3] != newcar || playerVariables[playerid][pCarID4] != newcar)