Lock&Unlock bug [+REP]
#1

Vehicle doesn't lock, it says "Vehicle Locked" but when i get out, i enter it (Unlocked)

pawn Код:
dcmd_lock(playerid,params[]){
    #pragma unused params
    if(IsPlayerConnected(playerid) && Vehicle[GetPlayerVehicleID(playerid)][IsLocked] == 0){
        if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER){
            for(new i = 0; i <MAX_PLAYERS; i++) { if (i != playerid) { SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 1); } }
            GameTextForPlayer(playerid,"~G~Vehicle locked",4000,3);
            new Float:X, Float:Y, Float:Z; GetPlayerPos(playerid,X,Y,Z);
            PlayerPlaySound(playerid,1057,X,Y,Z); Vehicle[GetPlayerVehicleID(playerid)][IsLocked] = 1;
            SetTimerEx("UnlockVehicle",600000,false,"i",GetPlayerVehicleID(playerid)); } }
           
    return true;
}

dcmd_unlock(playerid,params[]){
    #pragma unused params
    if(IsPlayerConnected(playerid) && Vehicle[GetPlayerVehicleID(playerid)][IsLocked] == 1){
        if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
            for(new i = 0; i <MAX_PLAYERS; i++) { SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 0); }
            GameTextForPlayer(playerid,"~G~Vehicle unlocked",4000,3);
            new Float:X, Float:Y, Float:Z; GetPlayerPos(playerid,X,Y,Z);
            PlayerPlaySound(playerid,1057,X,Y,Z); Vehicle[GetPlayerVehicleID(playerid)][IsLocked] = 0; } }
    return true;
}
Reply
#2

Use this for check if car is locked/unlocked.
https://sampwiki.blast.hk/wiki/OnVehicleStreamIn
Reply
#3

Can you give me the Code ready, im new in scripting
Reply
#4

Have fun
pawn Код:
public OnVehicleStreamIn(vehicleid, forplayerid)
{
    if (Vehicle[vehicleid][IsLocked] == 1) { SetVehicleParamsForPlayer(vehicleid,forplayerid,0,1); }
    else { SetVehicleParamsForPlayer(vehicleid,forplayerid,0,0); }
    return 1;
}
Reply
#5

It didn't work, i get out , and i can get in it again without unlocking it
Reply
#6

anyone ?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)