if((newkeys & KEY_YES) && !(oldkeys & KEY_YES)) { new NearestVehicleID = GetClosestVehicle(playerid); if(!PlayerToVehicle(playerid, NearestVehicleID, 3.0)) NearestVehicleID = 0; new Float:NearestVehiclePosX, Float:NearestVehiclePosY, Float:NearestVehiclePosZ; GetVehiclePos(NearestVehicleID, NearestVehiclePosX, NearestVehiclePosY, NearestVehiclePosZ); new playerName[MAX_PLAYER_NAME]; GetPlayerName(playerid,playerName,sizeof playerName); if(IsPlayerInAnyVehicle(playerid)) { Dialog_Show(playerid, DIALOG_VEHICLEMENU, DIALOG_STYLE_LIST, "Vehicle", "Engine\nLight\nHood\nBoot\nDoors\nWindows\nPark", "Ok", "Cancel"); } else { if(IsPlayerInRangeOfPoint(playerid, 3.0, NearestVehiclePosX, NearestVehiclePosY, NearestVehiclePosZ)) { if(IsVehiclePrivate(NearestVehicleID)) { if(!strcmp(playerName,PrivateVehicles[ConvertVID(NearestVehicleID)][_owner])) return 0; new engine, lights, alarm, doors, bonnet, boot, objective; GetVehicleParamsEx(NearestVehicleID, engine, lights, alarm, doors, bonnet, boot, objective); if(doors == VEHICLE_PARAMS_OFF) { SetVehicleParamsEx(NearestVehicleID, engine, lights, alarm, VEHICLE_PARAMS_ON, bonnet, boot, objective); SendClientMessage(playerid, -1, "your vehicle is now locked"); } if(doors == VEHICLE_PARAMS_ON) { SetVehicleParamsEx(NearestVehicleID, engine, lights, alarm, VEHICLE_PARAMS_OFF, bonnet, boot, objective); SendClientMessage(playerid, -1, "your vehicle is now unlocked"); } } else { } } } }
if(doors == VEHICLE_PARAMS_OFF
//to
if(doors != VEHICLE_PARAMS_ON)
//Before the if(doors == VEHICLE_PARAMS_OFF)
if(doors == VEHICLE_PARAMS_UNSET)
{
SendClientMessage(playerid, -1, "Vehicle params are unset");
}
if(engine == -1) engine = 0;
if(lights == -1) lights = 0;
if(alarm == -1) alarm = 0;
if(doors == -1) doors = 0;
if(boot == -1) boot = 0;
if(objective == -1) objective = 0;
if((newkeys & KEY_YES) && !(oldkeys & KEY_YES)) { new NearestVehicleID = GetClosestVehicle(playerid, 3.0); new string[128]; format(string, sizeof(string), "ID %i ", NearestVehicleID); SendClientMessage(playerid, -1, string);
stock GetClosestVehicle(playerid, Float:range) { new Float:p_X; new Float:p_Y; new Float:p_Z; new Float:Distance; new Float:PretendentDistance = range +1; new Pretendent; GetPlayerPos(playerid, p_X, p_Y, p_Z); for(new vehicleid=1; vehicleid < MAX_VEHICLES; vehicleid++) { Distance = GetVehicleDistanceFromPoint(vehicleid, p_X, p_Y, p_Z); if(Distance <= range && Distance <= PretendentDistance) { Pretendent = vehicleid; PretendentDistance = Distance; } } return Pretendent; }
if((newkeys & KEY_YES) && !(oldkeys & KEY_YES)) { new NearestVehicleID = GetClosestVehicle(playerid, 3.0); //if(!PlayerToVehicle(playerid, NearestVehicleID, 3.0)) NearestVehicleID = 0; new Float:NearestVehiclePosX, Float:NearestVehiclePosY, Float:NearestVehiclePosZ; GetVehiclePos(NearestVehicleID, NearestVehiclePosX, NearestVehiclePosY, NearestVehiclePosZ); new playerName[MAX_PLAYER_NAME]; GetPlayerName(playerid,playerName,sizeof playerName); new string[128]; format(string, sizeof(string), "ID %i ", NearestVehicleID); SendClientMessage(playerid, -1, string); /* if(IsPlayerInAnyVehicle(playerid)) { Dialog_Show(playerid, DIALOG_VEHICLEMENU, DIALOG_STYLE_LIST, "Vehicle", "Engine\nLight\nHood\nBoot\nDoors\nWindows\nPark", "Ok", "Cancel"); } else { if(IsPlayerInRangeOfPoint(playerid, 5.0, NearestVehiclePosX, NearestVehiclePosY, NearestVehiclePosZ)) { if(IsVehiclePrivate(NearestVehicleID)) { if(!strcmp(playerName,PrivateVehicles[ConvertVID(NearestVehicleID)][_owner])) return 0; new string[128]; new engine, lights, alarm, doors, bonnet, boot, objective; GetVehicleParamsEx(NearestVehicleID, engine, lights, alarm, doors, bonnet, boot, objective); if(engine == -1) engine = 0; if(lights == -1) lights = 0; if(alarm == -1) alarm = 0; if(doors == -1) doors = 0; if(boot == -1) boot = 0; if(objective == -1) objective = 0; format(string, sizeof(string), "ID %i doors %i", NearestVehicleID, doors); SendClientMessage(playerid, -1, string); if(doors == VEHICLE_PARAMS_UNSET) { SendClientMessage(playerid, -1, "Vehicle params are unset"); } if(doors != VEHICLE_PARAMS_ON) { SetVehicleParamsEx(NearestVehicleID, engine, lights, alarm, VEHICLE_PARAMS_ON, bonnet, boot, objective); SendClientMessage(playerid, -1, "your vehicle is now locked"); } if(doors != VEHICLE_PARAMS_OFF) { SetVehicleParamsEx(NearestVehicleID, engine, lights, alarm, VEHICLE_PARAMS_OFF, bonnet, boot, objective); SendClientMessage(playerid, -1, "your vehicle is now unlocked"); } } else { } } } */ }
if((newkeys & KEY_YES) && !(oldkeys & KEY_YES)) { new NearestVehicleID = GetClosestVehicle(playerid, 3.0); new string[128]; format(string, sizeof(string), "ID %i ", NearestVehicleID); SendClientMessage(playerid, -1, string); }
stock GetClosestVehicle(playerid, Float:range)
{
new Float:p_X;
new Float:p_Y;
new Float:p_Z;
new Float:Vpos[3];
GetPlayerPos(playerid, p_X, p_Y, p_Z);
for(new vehicleid=1; vehicleid < MAX_VEHICLES; vehicleid++)
{
GetVehiclePos(vehicleid,Vpos[0],Vpos[1],Vpos[2]);
if(IsPlayerInRangeOfPoint(playerid,range,Vpos[0],Vpos[1],Vpos[2]))
{
return vehicleid;
}
}
return 0;
}
Try
PHP код:
|
your stock work. thank you. re-writing whole code with your stock
|
your stock work. thank you. re-writing whole code with your stock
|