PDA

View Full Version : Lock&Unlock bug [+REP]


Jaber_Brown
14/03/2012, 09:41 PM
Vehicle doesn't lock, it says "Vehicle Locked" but when i get out, i enter it (Unlocked)



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(playe rid),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(playe rid),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;
}

StreetGT
14/03/2012, 09:45 PM
Use this for check if car is locked/unlocked.
http://wiki.sa-mp.com/wiki/OnVehicleStreamIn

Jaber_Brown
14/03/2012, 10:02 PM
Can you give me the Code ready, im new in scripting

StreetGT
14/03/2012, 10:30 PM
Have fun :)

public OnVehicleStreamIn(vehicleid, forplayerid)
{
if (Vehicle[vehicleid][IsLocked] == 1) { SetVehicleParamsForPlayer(vehicleid,forplayerid,0, 1); }
else { SetVehicleParamsForPlayer(vehicleid,forplayerid,0, 0); }
return 1;
}

Jaber_Brown
15/03/2012, 01:19 PM
It didn't work, i get out , and i can get in it again without unlocking it

Jaber_Brown
15/03/2012, 06:25 PM
anyone ?