Help me with car lock [/lock]
#1

When I try /lock vehicle works fine but when i try /lock in near of other owned vehicles by others, it returns vehicle id -1(means no vehicle near)

/lock CMD
PHP код:
CMD:lock(playerid,params[]){
    new 
id,enginelightsalarmdoorsbonnetbootobjective;
    
GetVehicleParamsEx(DynamicVehicle[id][dvehicle_vehicle], enginelightsalarmdoorsbonnetbootobjective);
    
id GetPlayerOwnVehicleID(playerid);
    if(
VehicleInfo[DynamicVehicle[id][dvehicle_vehicle]][vehicle_door]){
        
VehicleInfo[DynamicVehicle[id][dvehicle_vehicle]][vehicle_door] = 0;
        
GameTextForPlayer(playerid"~g~UNLOCKED"20005);
    }else{
        
VehicleInfo[DynamicVehicle[id][dvehicle_vehicle]][vehicle_door] = 1;
        
GameTextForPlayer(playerid"~r~LOCKED"20005);
    }
    
SetVehicleParamsEx(DynamicVehicle[id][dvehicle_vehicle], enginelightsalarmVehicleInfo[DynamicVehicle[id][dvehicle_vehicle]][vehicle_door], bonnetbootobjective);
    return 
1;

GetPlayerOwnVehicleID:
PHP код:
GetPlayerOwnVehicleID(playeridFloatrange 2.0)
{
    new 
id = -1Floatdist rangeFloattempdist;
    for(new 
iMAX_PLAYER_VEHICLEi++)
    {
        if(
DynamicVehicle[i][dvehicle_owner]==PlayerInfo[playerid][pID]){
            
tempdist GetPlayerDistanceFromPoint(playeridDynamicVehicle[i][dvehicle_pos][0], DynamicVehicle[i][dvehicle_pos][1],DynamicVehicle[i][dvehicle_pos][2]);
            if(
tempdist range) continue;
            if(
tempdist <= dist)
            {
                
dist tempdist;
                
id i;
            }
        }
    }
    return 
id;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)