02.01.2015, 07:58
How can I make saving /lock and /unlock system? Please help me..
new doorslocked[MAX_VEHICLES]=0;
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_YELLOW 0xFFFF00AA
// /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.");
if(cardriver[GetPlayerVehicleID(playerid)]==0) return SendClientMessage(playerid, COLOR_ORANGE,"ERROR: You are not in any vehicle.");
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, 1, bonnet, boot, objective);
SendClientMessage(playerid, COLOR_YELLOW, "Doors locked.");
doorslocked[GetPlayerVehicleID(playerid)]=1;
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.");
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, 0, bonnet, boot, objective);
SendClientMessage(playerid, COLOR_YELLOW, "Doors unlocked.");
doorslocked[GetPlayerVehicleID(playerid)]=0;
return 1;
}
if(GetPlayerState(playerid)==PLAYER_STATE_DRIVER)
{
if(doorslocked[vehicleid]==1)
{
doorslocked[vehicleid]=0;
SendClientMessage(playerid, COLOR_YELLOW, "Doors unlocked.");
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, 0, bonnet, boot, objective);
}
}
if(doorslocked[vehicleid]==1)
{
SetVehicleParamsForPlayer(vehicleid,forplayerid,0,1);
}
if(GetPlayerState(playerid)==PLAYER_STATE_DRIVER)
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, 0, bonnet, boot, objective);
cardriver[GetPlayerVehicleID(playerid)]=0;
doorslocked[GetPlayerVehicleID(playerid)]=0;
}