This seems to be the better option, you were allowing any player to enter the vehicle when you should of been allowing only the vehicle's owner to enter the vehicle. I removed some functions.
pawn Код:
if(strcmp(cmd, "/carlock", true) ==0)
{
new str[128];
new vehicleid = GetClosestVehicle(playerid, 5);
if(!strcmp(CarSystem[vehicleid][Carowner], pName(playerid), true))
{
if(CarLock[vehicleid] == 0)
{
CarLock[vehicleid] = 1;
SetVehicleParamsForPlayer(vehicleid, playerid, 0, 1);
format(str, sizeof(str), "* %s presses a key which locks the doors of the vehicle", pName(playerid));
ProxDetector(30.0, playerid, str, MECHAT, MECHAT, MECHAT, MECHAT, MECHAT);
}
else if(CarLock[vehicleid] == 1)
{
CarLock[vehicleid] = 0;
SetVehicleParamsForPlayer(vehicleid, playerid, 0, 0);
format(str, sizeof(str), "* %s presses a key which unlocks the doors of the vehicle", pName(playerid));
ProxDetector(30.0, playerid, str, MECHAT, MECHAT, MECHAT, MECHAT, MECHAT);
}
}
return 1;
}