pawn Код:
command(lights, playerid, params[])
{
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return 1;
new engine,lights,alarm,doors,bonnet,boot,objective;
new vid = GetPlayerVehicleID(playerid);
new string[128];
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
if(vid != INVALID_VEHICLE_ID)
{
if(lights == VEHICLE_PARAMS_ON)
{
SetVehicleParamsEx(vid,engine,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
format(string, sizeof(string), "* %s turns off the vehicle lights.", RPName(playerid));
NearByMessage(playerid, NICESKY, string);
}
else
{
if(Vehicles[vid][Battery] >= 1)
{
SetVehicleParamsEx(vid,engine,VEHICLE_PARAMS_ON,alarm,doors,bonnet,boot,objective);
format(string, sizeof(string), "* %s turns on the vehicle lights.", RPName(playerid));
NearByMessage(playerid, NICESKY, string);
}
else
{
RemoveTextMessage(playerid);
TextDrawShowForPlayer(playerid, Text:OutOfBattery);
SetTimerEx("RemoveTextMessage", 3500, false, "d", playerid);
}
}
}
return 1;
}
forward NearByMessage(playerid, colour, string[]);
public NearByMessage(playerid, colour, string[])
{
new Float: PlayerX, Float: PlayerY, Float: PlayerZ;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
GetPlayerPos(playerid, PlayerX, PlayerY, PlayerZ);
if(IsPlayerInRangeOfPoint(i, 12, PlayerX, PlayerY, PlayerZ))
{
if(GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i) && GetPlayerInterior(playerid) == GetPlayerInterior(i))
{
SendClientMessage(i, colour, string);
}
}
}
}
return 1;
}