Saving /lock and /unlock -
Sensation - 02.01.2015
How can I make saving /lock and /unlock system? Please help me..
Re: Saving /lock and /unlock -
ATGOggy - 02.01.2015
on top
PHP код:
new doorslocked[MAX_VEHICLES]=0;
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_YELLOW 0xFFFF00AA
on public OnPlayerCommandText
PHP код:
// /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;
}
on public OnPlayerExitVehicle
PHP код:
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);
}
}
on public OnVehicleStreamIn
PHP код:
if(doorslocked[vehicleid]==1)
{
SetVehicleParamsForPlayer(vehicleid,forplayerid,0,1);
}
on OnPlayerDisconnect
PHP код:
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;
}