// /lock
if(strcmp(cmdtext, "/lock", true, 20) == 0)
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "ERROR: You are not in any vehicle.");
if(GetPlayerState(playerid)==PLAYER_STATE_PASSENGER) return SendClientMessage(playerid, COLOR_ORANGE, "ERROR: Only drivers can lock car doors.");
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pAdmin]<5)
{
SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid), i, 0, 1);
doorslocked[playerid]=1;
}
}
}
SendClientMessage(playerid, COLOR_YELLOW, "Doors locked.");
return 1;
}
// /unlock
if(strcmp(cmdtext, "/unlock", true, 20) == 0)
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "ERROR: You are not in any vehicle.");
if(GetPlayerState(playerid)==PLAYER_STATE_PASSENGER) return SendClientMessage(playerid, COLOR_ORANGE, "ERROR: Only drivers can unlock car doors.");
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid), i, 0, 0);
doorslocked[playerid]=0;
}
}
SendClientMessage(playerid, COLOR_YELLOW, "Doors unlocked.");
return 1;
}
if(strcmp(cmdtext, "/lock", true, 20) == 0)
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "ERROR: You are not in any vehicle.");
if(GetPlayerState(playerid)==PLAYER_STATE_PASSENGER) return SendClientMessage(playerid, COLOR_ORANGE, "ERROR: Only drivers can lock car doors.");
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pAdmin]<5)
{
SetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, 1, bonnet, boot, objective);
doorslocked[playerid]=1;
}
}
}
SendClientMessage(playerid, COLOR_YELLOW, "Doors locked.");
return 1;
}
// /unlock
if(strcmp(cmdtext, "/unlock", true, 20) == 0)
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "ERROR: You are not in any vehicle.");
if(GetPlayerState(playerid)==PLAYER_STATE_PASSENGER) return SendClientMessage(playerid, COLOR_ORANGE, "ERROR: Only drivers can unlock car doors.");
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
SetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, 0, bonnet, boot, objective);
doorslocked[playerid]=0;
}
}
SendClientMessage(playerid, COLOR_YELLOW, "Doors unlocked.");
return 1;
}
doorslocked[playerid]=1;
public OnVehicleStreamIn(vehicleid, forplayerid)
{
if(doorslocked[vehicleid]==1)
{
SetVehicleParamsForPlayer(vehicleid,forplayerid,0,1);
}
}
pawn Код:
You need to review your code more... There's no doubt simple mistakes such as this. Also go back to using SetVehicleParamsForPlayer, and doing all the user IDs, Then pawn Код:
|
I'm using that variable to only make the doors unlock after the player exit vehicle.
That variable has got nothing else to do with this. |
I'm using that variable to only make the doors unlock after the player exit vehicle.
|
new vehicle_loock[MAX_PLAYERS]; // Note: This variable must be in 0 when you spawn to a vehicle.
if(strcmp(cmdtext, "/lock", true, 20) == 0)
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "ERROR: You are not in any vehicle.");
if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid, COLOR_ORANGE, "ERROR: Only drivers can lock car doors.");
if(vehicle_loock[GetPlayerVehicleID(playerid)] == 1) return SendClientMessage(playerid, COLOR_ORANGE, "ERROR: Your vehicle is already locked.");
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pAdmin] <5)
{
if(i != playerid)
{
SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid), i, 0, 1);
vehicle_loock[GetPlayerVehicleID(playerid)] = 1;
}
}
}
}
SendClientMessage(playerid, COLOR_YELLOW, "Doors locked.");
return 1;
}
if(strcmp(cmdtext, "/unlock", true, 20) == 0)
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "ERROR: You are not in any vehicle.");
if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid, COLOR_ORANGE, "ERROR: Only drivers can unlock car doors.");
if(vehicle_loock[GetPlayerVehicleID(playerid)] == 0) return SendClientMessage(playerid, COLOR_ORANGE, "ERROR: Your vehicle is not blocked.");
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(i != playerid)
{
SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid), i, 0, 0);
vehicle_loock[GetPlayerVehicleID(playerid)] = 0;
}
}
}
SendClientMessage(playerid, COLOR_YELLOW, "Doors unlocked.");
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid) //When you exit the vehicle will automatically unlock.
{
if(vehicle_loock[GetPlayerVehicleID(playerid)] == 1)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid), i, 0, 0);
}
vehicle_loock[GetPlayerVehicleID(playerid)] = 0;
}
return true;
}
pawn Код:
|