[HELP] Lock car
#1

I ahve this FS, i buy the car, but wen i write /vlock, the car locked,write "Car locked", but, after 40sec, everyone can get intro the vehicle, wen i type again /vlock, write me "car unlocked". So....the car locked buy everyone can get intro the car.

pawn Код:
CMD:vlock(playerid, params[])
{
    new vehicleid;
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        vehicleid = GetPlayerVehicleID(playerid);
    }
    else
    {
        vehicleid = GetClosestVehicle(playerid);
        if(!PlayerToVehicle(playerid, vehicleid, 5.0)) vehicleid = 0;
    }
    if(!vehicleid) return SendClientMessage(playerid, COLOR_RED, "You are not close to a vehicle!");
    new id = GetVehicleID(vehicleid);
    if(!IsValidVehicle(id)) return SendClientMessage(playerid, COLOR_RED, "You don't have the keys for this vehicle!");
    if(GetPlayerVehicleAccess(playerid, id) < 2)
        return SendClientMessage(playerid, COLOR_RED, "You don't have the keys for this vehicle!");
    new engine, lights, alarm, doors, bonnet, boot, objective;
    GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
    if(doors == 1)
    {
        doors = 0;
        VehicleLock[id] = 0;
        GameTextForPlayer(playerid, "~g~doors unlocked", 3000, 6);
    }
    if(doors == 0)
    {
        doors = 1;
        VehicleLock[id] = 1;
        GameTextForPlayer(playerid, "~r~doors locked", 3000, 6);
    }
    SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
    SaveVehicle(id);
    return 1;
}
Reply
#2

The easiest fix would be this:

pawn Код:
CMD:vlock(playerid, params[])
{
    new vehicleid;
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        vehicleid = GetPlayerVehicleID(playerid);
    }
    else
    {
        vehicleid = GetClosestVehicle(playerid);
        if(!PlayerToVehicle(playerid, vehicleid, 5.0)) vehicleid = 0;
    }
    if(!vehicleid) return SendClientMessage(playerid, COLOR_RED, "You are not close to a vehicle!");
    new id = GetVehicleID(vehicleid);
    if(!IsValidVehicle(id)) return SendClientMessage(playerid, COLOR_RED, "You don't have the keys for this vehicle!");
    if(GetPlayerVehicleAccess(playerid, id) < 2)
        return SendClientMessage(playerid, COLOR_RED, "You don't have the keys for this vehicle!");
    new engine, lights, alarm, doors, bonnet, boot, objective;
    GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
    if(doors == 1)
    {
                SetVehicleParamsForPlayer(vehicleid,playerid,0,0);
        doors = 0;
        VehicleLock[id] = 0;
        GameTextForPlayer(playerid, "~g~doors unlocked", 3000, 6);
    }
    if(doors == 0)
    {
                SetVehicleParamsForPlayer(vehicleid,playerid,0,1);
        doors = 1;
        VehicleLock[id] = 1;
        GameTextForPlayer(playerid, "~r~doors locked", 3000, 6);
    }
    SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
    SaveVehicle(id);
    return 1;
}
[/QUOTE]
Reply
#3

Is Don't work, the command not have efect.
Reply
#4

It doesn't seem like you're locking it at all?

pawn Код:
SetVehicleParamsEx(vehicleid, engine, lights, alarm, 1, bonnet, boot, objective);
This will lock it.

pawn Код:
SetVehicleParamsEx(vehicleid, engine, lights, alarm, 0, bonnet, boot, objective);
This will unlock it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)