/lock command bug.
#5

First of all, having char requires the index to be with {vehicleid} instead of [vehicleid].

I don't really get how "one" player-array is useful in this case but checking if there is a vehicle stored and if there is, if it is locked, you can easily unlock it.

By the way, it is important to note that you reset playersvehicle to -1 and then use it in the array which results to a run time error 4 for accessing negative index (-1).

Код:
// OnPlayerDisconnect:
if (playersvehicle[playerid] != -1) // if there is a vehicle stored
{
    if (locked{playersvehicle[playerid]} == 1) // and it's locked | notice how { } are used for char-arrays
    {
        locked{playersvehicle[playerid]} = 0; // it is now unlocked for whoever try to enter it, assuming you only need the variable to check in OnPlayerEnterVehicle/OnPlayerStateChange
    }
    playersvehicle[playerid] = -1;
}
Код:
// command /lock
if(locked{GetPlayerVehicleID(playerid)} == 1) return SendClientMessage(playerid, COLOR_RED, "This vehicle is already locked!");

...

locked{GetPlayerVehicleID(playerid)} = 1;
Another note: just check directly if the player is driver, there is really no point for having both IsPlayerInAnyVehicle and driver check.

Код:
// command /unlock
if(locked{GetPlayerVehicleID(playerid)} == 0) return SendClientMessage(playerid, COLOR_RED, "This vehicle is already unlocked!");

...

locked{GetPlayerVehicleID(playerid)} = 0;
Same apply here for the drive state. I guess you have translated the name of the variables for us because of "aizslegts".
Reply


Messages In This Thread
/lock command bug. - by GrInDzO - 13.08.2016, 12:29
Re: /lock command bug. - by Shinja - 13.08.2016, 12:34
Re: /lock command bug. - by SyS - 13.08.2016, 12:36
Re: /lock command bug. - by Shinja - 13.08.2016, 12:38
Re: /lock command bug. - by Konstantinos - 13.08.2016, 12:44

Forum Jump:


Users browsing this thread: 1 Guest(s)