Problem mit fwrite

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
  • Hi Community.
    Ich arbeite derzeit an einem Entwickler-Script für mich selbst(<-weil ich nicht weiß was ich tun soll)
    Soweit hat alles geklappt, jedoch hänge ich an meinen eigenen Save-Befehlen.
    Ich möchte, dass nicht alles als AddPlayerClass ausgespieben wird sondern gleich als z.B. CreatePickup.
    Nun zum Problem:
    Ich habe diesen Code:

    dcmd_savepickup(playerid, params[])
    {
    #pragma unused params
    if(!IsPlayerInAnyVehicle(playerid))
    {
    ShowPlayerDialog(playerid, pickup_start, DIALOG_STYLE_MSGBOX, "Pickup Saving Progress - 0%", "This dialog will guide you through the pickup saving.\nThe data type will be shown at the single steps.", "Next", "Cancel");
    }
    else
    {
    SendClientMessage(playerid, 0xFF0000FF, "Feature not available. Leave the car and try it again.");
    }
    return 1;
    }


    public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
    {
    if(dialogid == pickup_start)
    {
    ShowPlayerDialog(playerid, pickup_variable, DIALOG_STYLE_INPUT, "Pickup Saving Progress - 20%", "The variable you want to use in the script(e.g. pickup1)\nShould be a string.", "Next", "Back");
    }
    if(dialogid == pickup_variable)
    {
    if(response == 0)
    {
    ShowPlayerDialog(playerid, pickup_start, DIALOG_STYLE_MSGBOX, "Pickup Saving Progress - 0%", "This dialog will guide you through the pickup saving.\nThe data type will be shown at the single steps.", "Next", "Cancel");
    }
    else
    {
    pickupVariableTag = strlen(inputtext);
    ShowPlayerDialog(playerid, pickup_type, DIALOG_STYLE_INPUT, "Pickup Saving Progress - 40%", "The type of pickup(e.g. 1 for 'Not pickupable, exists all the time.')\nShould be an integer.\nFull list at http://wiki.sa-mp.com/wiki/PickupTypes.", "Next", "Back");
    }
    }
    if(dialogid == pickup_type)
    {
    if(response == 0)
    {
    ShowPlayerDialog(playerid, pickup_variable, DIALOG_STYLE_INPUT, "Pickup Saving Progress - 20%", "The variable you want to use in the script(e.g. pickup1)\nShould be a string.", "Next", "Back");
    pickupVariableTag = 0;
    }
    else
    {
    pickupType = strlen(inputtext);
    ShowPlayerDialog(playerid, pickup_world, DIALOG_STYLE_INPUT, "Pickup Saving Progress - 60%", "The world where the pickup will be shown(Hint: -1 for all worlds)\nShould be an integer.", "Next", "Back");
    }
    }
    if(dialogid == pickup_world)
    {
    if(response == 0)
    {
    ShowPlayerDialog(playerid, pickup_type, DIALOG_STYLE_INPUT, "Pickup Saving Progress - 40%", "The type of pickup(e.g. 1 for 'Not pickupable, exists all the time.')\nShould be an integer.\nFull list at http://wiki.sa-mp.com/wiki/PickupTypes.", "Next", "Back");
    pickupType = 0;
    }
    else
    {
    pickupWorld = strlen(inputtext);
    ShowPlayerDialog(playerid, pickup_name, DIALOG_STYLE_INPUT, "Pickup Saving Progress - 80%", "The name will be shown as a comment behind the line.\nShould be an string.", "Next", "Back");
    }
    }
    if(dialogid == pickup_name)
    {
    if(response == 0)
    {
    ShowPlayerDialog(playerid, pickup_world, DIALOG_STYLE_INPUT, "Pickup Saving Progress - 60%", "The world where the pickup will be shown(Hint: -1 for all worlds)\nShould be an integer.", "Next", "Back");
    pickupWorld = 0;
    }
    else
    {
    pickupName = strlen(inputtext);
    ShowPlayerDialog(playerid, pickup_end, DIALOG_STYLE_INPUT, "Pickup Saving Progress - 100%", "While you are reading this, the pickup data will be saved in a file.\nHint: Look at the scriptfiles folder.", "Next", "Back");
    }
    }
    if(dialogid == pickup_end)
    {
    if(response == 0)
    {
    ShowPlayerDialog(playerid, pickup_name, DIALOG_STYLE_INPUT, "Pickup Saving Progress - 80%", "The name will be shown as a comment behind the line.\nShould be an string.", "Next", "Back");
    pickupName = 0;
    }
    else
    {
    GetPlayerPos(playerid, xPos, yPos, zPos);
    new File:picks=fopen("pickups.wrn", io_append);
    format(string, 256, "new %s \r\n%s = CreatePickup(1242, %d, %f, %f, %f, %d);//%s \r\n", pickupVariableTag, pickupType, xPos, yPos, zPos, pickupWorld, pickupName);
    fwrite(picks, string);
    fclose(picks);
    }
    }
    return 1;
    }

    Im Script sind keine Errors und keine Warnings.
    Aber wenn ich nun ins Spiel gehe und etwas eingebe passiert etwas vollkommen falsches.
    Ich gebe jetzt z.B. ein: Variable = pickup1, Type=1, World=-1, Name=pickup is nice
    Und das wird generiert:

    Code
    new ÌÆ 
    ÌÆ = CreatePickup(1242, 1155621836, -1577.737915, 13.416204, 0.000000, 16);//


    Hatte es vorher auch anders, wie z.B. bei den Vehicles:

    dcmd_savevehcoords(playerid, params[])
    {
    new vehicleVariableTag, vehicleType, vehicleLongName, vehicleFirstColor, vehicleSecondColor, Float:xPos, Float:yPos, Float:zPos, Float:rotation, string[128];
    if(IsPlayerInVehicle(playerid, car))
    {
    if (sscanf(params, "sdds", vehicleVariableTag, vehicleFirstColor, vehicleSecondColor, vehicleLongName)) SendClientMessage(playerid, 0xFF0000FF, "Usage: \"/savevehcoords [variable tag][first color][second color][longname]\"");
    if (vehicleFirstColor <= 0 && vehicleFirstColor >= 255) vehicleFirstColor = 0;
    if (vehicleSecondColor <= 0 && vehicleSecondColor >= 255) vehicleSecondColor = 0;
    else
    {
    GetVehiclePos(car, xPos, yPos, zPos);
    GetVehicleZAngle(car, rotation);
    vehicleType = GetVehicleModel(car);
    new File:vehs=fopen("vehicles.wrn", io_append);
    format(string, 256, " %s = CreateVehicle(%d, %f, %f, %f, %f, %d, %d, 0);//%s \r\n", vehicleVariableTag, vehicleType, xPos, yPos, zPos, rotation, vehicleFirstColor, vehicleSecondColor, vehicleLongName);
    fwrite(vehs, string);
    fclose(vehs);
    }
    }
    else
    {
    SendClientMessage(playerid, 0xFF0000FF, "Feature not available. Enter a car and try it again.");
    }
    return 1;
    }

    Eingegeben: /savevehcoords test 89 43 thisisatestingcar
    Also: Variable=test, Farbe1=89, Farbe2=43, Name=thisisatestingcar
    Da kam dann raus:

    Code
    isisatestingcar = CreateVehicle(456, 1821.068725, -1569.034545, 13.625162, 206.888534, 89, 43, 0);//tÈisisatestingcar


    Wäre nett wenn mit jemand versucht zu helfen und gut wenn jemand weiß was mein Fehler ist.
    Seit ruhig hart zu mir wenn es ein dummer Fehler ist :D
    Solange es dann geht...
    MfG Raphii

    Scripter aus Leidenschaft!
    Tod dem Godfather, lasst Selfmade-Scripts freie Möglichkeiten!