[Problem] mit /vehiclelock

Wichtiger Hinweis: Bitte ändert nicht manuell die Schriftfarbe auf schwarz sondern belasst es bei der Standardeinstellung. Somit tragt ihr dazu bei dass euer Text auch bei Verwendung unseren dunklen Forenstils noch lesbar ist!

Tipp: Ihr wollt längere Codeausschnitte oder Logfiles bereitstellen? Benutzt unseren eigenen PasteBin-Dienst Link
  • Dann musst du es so machen:
    ocmd:vehiclelock(playerid,params[])
    {
    new veh = INVALID_VEHICLE_ID;
    if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {
    new Float:Pos[3], Float:dist = 20.0, Float:tmp;
    for(new i=0;i<MAX_VEHICLES; i++)
    {
    GetVehiclePos(i, Pos[0], Pos[1], Pos[2]);
    tmp = GetPlayerDistanceFromPoint(playerid, Pos[0], Pos[1], Pos[2]);
    if(tmp < dist)
    {
    veh = i;
    dist = tmp;
    }
    }
    }
    else if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
    veh = GetPlayerVehicleID(playerid);
    }
    if(veh == INVALID_VEHICLE_ID) return SendClientMessage(playerid,COLOR_RED,"Es befindet sich keines deiner Fahrzeuge in der Nähe.");
    if(sInfo[playerid][alevel] > 0 || cInfo[veh][besitzer] == playerid)
    {
    new engine,lights,alarm,bonnet,boot,objective;
    GetVehicleParamsEx(veh,engine,lights,alarm,vehdoor,bonnet,boot,objective);
    GameTextForPlayer(playerid, (vehdoor)?("~w~Fahrzeug ~g~aufgeschlossen"):("~w~Fahrzeug ~g~abgeschlossen"), 3000, 5);
    PlaySoundForPlayer(playerid,1147);
    SetTimerEx("PlaySoundForPlayer",500,0,"id",playerid,1147);
    if(vehdoor!=0) vehdoor = 0;
    else vehdoor = 1;
    SetVehicleParamsEx(veh,engine,lights,alarm,vehdoor,bonnet,boot,objective);
    }
    else
    {
    return SendClientMessage(playerid,COLOR_RED,"Das Auto gehört dir nicht.");
    }
    return 1;
    }


    German_ScripterHD: Ändere in der Schleife: MAX_PLAYERS zu MAX_VEHICLES. Ist mir grade aufgefallen.

    3HZXdYd.png

    2 Mal editiert, zuletzt von Jeffry () aus folgendem Grund: MAX_PLAYERS => MAX_VEHICLES

  • Okay, Danke :) #Fehler verbessert


    Aber wie mach ich das jetzt wenn die Autos geladen werden, sollen sie am Anfang alle abgeschlossen sein.


    Ich habe es so, aber so geht es nicht, da die Fahrzeuge bei laden alle aufgeschlossen sind.


    Code:


    public OnPlayerCarsLoad(playerid)
    {
    new num_fields,num_rows;
    cache_get_data(num_rows,num_fields,dbhandle);
    if(!num_rows)return 1;
    for(new i=0; i<num_rows; i++)
    {
    new id=getFreeCarID();
    cInfo[id][model]=cache_get_field_content_int(i,"model",dbhandle);
    cInfo[id][besitzer]=cache_get_field_content_int(i,"besitzer",dbhandle);
    cInfo[id][c_x]=cache_get_field_content_float(i,"x",dbhandle);
    cInfo[id][c_y]=cache_get_field_content_float(i,"y",dbhandle);
    cInfo[id][c_z]=cache_get_field_content_float(i,"z",dbhandle);
    cInfo[id][c_r]=cache_get_field_content_float(i,"r",dbhandle);
    cInfo[id][db_id]=cache_get_field_content_int(i,"id",dbhandle);
    cache_get_field_content(i,"kennzeichen",cInfo[id][kennzeichen],dbhandle,16);
    cInfo[id][Car_Spoiler]=cache_get_field_content_int(i,"spoiler",dbhandle);
    cInfo[id][Car_Hood]=cache_get_field_content_int(i,"hood",dbhandle);
    cInfo[id][Car_Roof]=cache_get_field_content_int(i,"roof",dbhandle);
    cInfo[id][Car_Sideskirt]=cache_get_field_content_int(i,"sideskirt",dbhandle);
    cInfo[id][Car_Lamps]=cache_get_field_content_int(i,"lamps",dbhandle);
    cInfo[id][Car_Nitro]=cache_get_field_content_int(i,"nitro",dbhandle);
    cInfo[id][Car_Wheels]=cache_get_field_content_int(i,"wheels",dbhandle);
    cInfo[id][Car_Stereo]=cache_get_field_content_int(i,"stereo",dbhandle);
    cInfo[id][Car_Hydraulics]=cache_get_field_content_int(i,"hydraulics",dbhandle);
    cInfo[id][Car_FrontBumper]=cache_get_field_content_int(i,"frontbumper",dbhandle);
    cInfo[id][Car_RearBumper]=cache_get_field_content_int(i,"rearbumper",dbhandle);
    cInfo[id][Car_Exhaust]=cache_get_field_content_int(i,"exhaust",dbhandle);
    cInfo[id][Car_VentRight]=cache_get_field_content_int(i,"ventright",dbhandle);
    cInfo[id][Car_VentLeft]=cache_get_field_content_int(i,"ventleft",dbhandle);
    cInfo[id][Car_PaintJob]=cache_get_field_content_int(i,"paintjob",dbhandle);
    cInfo[id][Car_Color1]=cache_get_field_content_int(i,"color1",dbhandle);
    cInfo[id][Car_Color2]=cache_get_field_content_int(i,"color2",dbhandle);
    cInfo[id][id_x]=CreateVehicle(cInfo[id][model],cInfo[id][c_x],cInfo[id][c_y],cInfo[id][c_z],cInfo[id][c_r],cInfo[id][Car_Color1],cInfo[id][Car_Color2],-1);
    tank[cInfo[id][id_x]]=100;
    SetVehicleNumberPlate(cInfo[id][id_x],cInfo[id][kennzeichen]);
    SetVehicleToRespawn(cInfo[id][id_x]);
    AddVehicleComponent(cInfo[id][id_x],cInfo[id][Car_Spoiler]);
    AddVehicleComponent(cInfo[id][id_x],cInfo[id][Car_Hood]);
    AddVehicleComponent(cInfo[id][id_x],cInfo[id][Car_Roof]);
    AddVehicleComponent(cInfo[id][id_x],cInfo[id][Car_Sideskirt]);
    AddVehicleComponent(cInfo[id][id_x],cInfo[id][Car_Lamps]);
    AddVehicleComponent(cInfo[id][id_x],cInfo[id][Car_Nitro]);
    AddVehicleComponent(cInfo[id][id_x],cInfo[id][Car_Wheels]);
    AddVehicleComponent(cInfo[id][id_x],cInfo[id][Car_Stereo]);
    AddVehicleComponent(cInfo[id][id_x],cInfo[id][Car_Hydraulics]);
    AddVehicleComponent(cInfo[id][id_x],cInfo[id][Car_FrontBumper]);
    AddVehicleComponent(cInfo[id][id_x],cInfo[id][Car_RearBumper]);
    AddVehicleComponent(cInfo[id][id_x],cInfo[id][Car_Exhaust]);
    AddVehicleComponent(cInfo[id][id_x],cInfo[id][Car_VentRight]);
    AddVehicleComponent(cInfo[id][id_x],cInfo[id][Car_VentLeft]);
    ChangeVehiclePaintjob(cInfo[id][id_x],cInfo[id][Car_PaintJob]);
    new engine,lights,alarm,bonnet,boot,objective;
    GetVehicleParamsEx(cInfo[id][id_x],engine,lights,alarm,vehdoor,bonnet,boot,objective);
    vehdoor = 0;
    SetVehicleParamsEx(cInfo[id][id_x],engine,lights,alarm,vehdoor,bonnet,boot,objective);
    }
    return 1;
    }


    Mit freundlichen Grüßen
    German_ScripterHD