Beiträge von BloodyEric

    if(newstate==PLAYER_STATE_DRIVER)
    {
    if(GetPlayerVehicleID(playerid) == 520)
    {
    new string[256];
    warn[playerid]++;
    format(string,sizeof(string),"{FC0000}Warning: {00F8FC}You can´t Drive with this Vehicle {FCF800}[Warn:%d/3]",warn[playerid]);
    SendClientMessage(playerid,0xFF0000FF,string);
    RemovePlayerFromVehicle(playerid);
    return 1;
    }
    }

    a) Nicht pushen
    b) Keine Crashlogs posten
    c) Irgendwelche Mods? Gehts auf 0.3b? Geht der Singleplayer?
    d) Wenn, dann poste das Crashlog ins offizielle SA:MP Forum, da wird geholfen.

    Schau dir mal die Funktion hier an, ist vom GrandLarceny geklaut:


    stock LoadStaticVehiclesFromFile(const filename[])
    {
    new File:file_ptr;
    new line[256];
    new var_from_line[64];
    new vehicletype;
    new Float:SpawnX;
    new Float:SpawnY;
    new Float:SpawnZ;
    new Float:SpawnRot;
    new Color1, Color2;
    new index;
    new vehicles_loaded;


    file_ptr = fopen(filename,filemode:io_read);
    if(!file_ptr) return 0;


    vehicles_loaded = 0;


    while(fread(file_ptr,line,256) > 0)
    {
    index = 0;


    // Read type
    index = token_by_delim(line,var_from_line,',',index);
    if(index == (-1)) continue;
    vehicletype = strval(var_from_line);
    if(vehicletype < 400 || vehicletype > 611) continue;


    // Read X, Y, Z, Rotation
    index = token_by_delim(line,var_from_line,',',index+1);
    if(index == (-1)) continue;
    SpawnX = floatstr(var_from_line);


    index = token_by_delim(line,var_from_line,',',index+1);
    if(index == (-1)) continue;
    SpawnY = floatstr(var_from_line);


    index = token_by_delim(line,var_from_line,',',index+1);
    if(index == (-1)) continue;
    SpawnZ = floatstr(var_from_line);


    index = token_by_delim(line,var_from_line,',',index+1);
    if(index == (-1)) continue;
    SpawnRot = floatstr(var_from_line);


    // Read Color1, Color2
    index = token_by_delim(line,var_from_line,',',index+1);
    if(index == (-1)) continue;
    Color1 = strval(var_from_line);


    index = token_by_delim(line,var_from_line,';',index+1);
    Color2 = strval(var_from_line);


    //printf("%d,%d,%f,%f,%f,%f,%d,%d",total_vehicles_from_files+vehicles_loaded+1,vehicletype,SpawnX,SpawnY,SpawnZ,SpawnRot,Color1,Color2);


    AddStaticVehicleEx(vehicletype,SpawnX,SpawnY,SpawnZ,SpawnRot,Color1,Color2,(30*60)); // respawn 30 minutes
    vehicles_loaded++;
    }


    fclose(file_ptr);
    printf("Loaded %d vehicles from: %s",vehicles_loaded,filename);
    return vehicles_loaded;
    }


    Dort sehen die Dateien so aus:

    513,291.1346,2535.5850,17.3778,180.2974,21,36 ; Stuntplane


    Du musst dann halt in der Funktion auf XYZ reduzieren, wenn du in den Dateien nur XYZ hast. ;)


    EDIT: token_by_delim brauchst dann natürlich auch noch:


    stock token_by_delim(const string[], return_str[], delim, start_index)
    {
    new x=0;
    while(string[start_index] != EOS && string[start_index] != delim) {
    return_str[x] = string[start_index];
    x++;
    start_index++;
    }
    return_str[x] = EOS;
    if(string[start_index] == EOS) start_index = (-1);
    return start_index;
    }

    Das macht keinen Sinn, dein else bezieht sich so auf den Command. Du musst oben noch eine if-Abfrage einbauen, ob der Spieler im DM ist, dann kann dein Else kommen. ;)

    Eigentlich mach ich sowas ja nicht, aber.......


    Das ist ganz, ganz wenig. Es ist unüberlegt gecodet (was hat PlaySoundForPlayer da verloren?), anstatt Funktionen wie EngineOn und EngineOff in einer zusammenzufassen werden sie "doppelt" geschrieben. Allgemein ist es nicht sinnvoll, immer den Playerid statt den Vehicleid Parameter zu benutzen, das schränkt die Benutzbarkeit nochmal stark ein.


    Es ist richtig schlecht (sorry) gecodet -


    new veh;
    veh = GetPlayerVehicleID(playerid);
    new xxxx[256], pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    format(xxxx, sizeof(xxxx), "%s", pname);
    SetVehicleNumberPlate(veh, xxxx);


    Die ganzen Funktionen wie

    Zitat

    SpawnVehObjectOL

    machen keinen Sinn, da die Offsets für jedes Fahrzeug anders sind und daher bei 95% der Fahrzeuge die Objekte im Auto stecken oder in der Luft schweben.



    Also...auf ein Neues. ;)