lock car and unlock help
#1

Код:
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); } }
			SendClientMessage(playerid,LIME, ".::[VEHICLE]::. Vehicle is Locked!");
			new Float:X, Float:Y, Float:Z; GetPlayerPos(playerid,X,Y,Z);
			PlayerPlaySound(playerid,1057,X,Y,Z); Vehicle[GetPlayerVehicleID(playerid)][IsLocked] = 1;
		 } }
	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); }
			SendClientMessage(playerid,LIME, ".::[VEHICLE]::. Vehicle is Unlocked!");
			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;
}
I don't want you to be in the car to lock the car i need it if like if you are in the car it returns error then if you are out your car is locked then when u reenter vehicle gets unlocked
Reply
#2

if(GetPlayerState(playerid) == 2) {

?
Reply
#3

if(GetPlayerState(playerid) == ON_FOOT) {

?
Reply
#4

put in there somewhere

Код:
if(GetPlayerState(playerid) = PLAYER_STATE_ONFOOT) {
Reply
#5

How do you expect the command to work (as it is currently coded) without having to be in the car?

Quote:

if(IsPlayerConnected(playerid) && Vehicle[GetPlayerVehicleID(playerid)][IsLocked] == 0){

You get the vehicleid to lock by getting the player's current vehicle ID. If he's not inside, this command won't work as it is currently coded.
Reply
#6

no no no.

if i enter a vehicle then exit then lock it work thats what i mean so like if i enter another vehicle and exit it would lock that one instead
Reply
#7

does anyone understand what im trying to say<.<
Reply
#8

I guess I know, but I wont help you with It, but to explain for others;

1. You enter a vehicle
2. You exit the vehicle, that vehicle will be locked for everybody else but yourself.
3. When you enter another vehicle your previous vehicle will be unlocked and the one you're in will be locked once you exit It.
Reply
#9

yupp
Reply
#10

Under public OnPlayerExitVehicle add the following

pawn Код:
for(new i=0; i<MAX_PLAYERS; i++){
    if(IsPlayerConnected(i)) {
      if(i != playerid){
      SetVehicleParamsForPlayer(vehicleid, i, 0, 1);
      }
    }
}
Im not sure if it'll work, but I think it will... Sorry for the bad identation, done with space lol.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)