Stats in dialog umschreiben

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
  • Guten Tag Community.
    Ich bin ja noch sehr sehr neu im Scripting Bereich und stelle deshalb viele Fragen.
    Natürlich hoffe ich, dass es noch Leute gibt die mir da helfen können.


    Heute habe ich eine Frage zum Thema /stats in einen Dialog umschreiben, weil das jetzige per SendClientMessage angezeigt wird.
    Kann mir jemand dabei helfen es umzuschreiben?


    Es ist besser wenn mir hier jemand hilft.
    Denn wenn ich Tutorials anschaue usw, mache ich manchmal trotzdem noch Fehler.



    new whostats[48];
    if (targetid == playerid) whostats = "Your";
    else if(targetid != playerid) format(whostats, sizeof(whostats), "%s's", PlayerName(targetid));



    format(string, sizeof(string), "%s Statistics", whostats);
    SendClientMessage(playerid, LIGHTORANGE, string);



    format(string, sizeof(string), "Level: %d ~ Gender: %s ~ Age: %d ~ Wallet: $%d ~ Bank Account: $%d ~ Bank PIN: %d ~ Phone Number: %d ~ Job: %s (%d)", plevel, gender, age, wallet, bank, bankpin, number, job, joblevel);
    SendClientMessage(playerid, WHITE, string);



    format(string, sizeof(string), "Total Hours Online: %d ~ Warnings: %d ~ Upgrade Points: %d ~ Spawn Armor: %d ~ Experience: %d/%d ~ Crimes Committed: %d ~ Times Arrested: %d", hours, warns, upgradepoints, spawnhealth, exp, expamount, crimes, arrests);
    SendClientMessage(playerid, WHITE, string);

    new smallstr[64];
    format(string, sizeof(string), "Organization: %s ~ Rank: %s (%d) ~ Products: %d ~ Wanted Level: %d ~ ", GetPlayerFactionName(targetid), GetPlayerRank(targetid), rank, prods, wantedlevel);
    #if defined COOKIE_SYSTEM
    format(smallstr, sizeof(smallstr), "Cookies: %d ~ ", cookies);
    strcat(string, smallstr);
    #endif
    #if defined GIFT_SYSTEM
    format(smallstr, sizeof(smallstr), "Gifts: %d ~ ", gifts);
    strcat(string, smallstr);
    #endif
    #if defined REWARD_SYSTEM
    format(smallstr, sizeof(smallstr), "Reward Tokens: %d ~ ", PlayerInfo[targetid][pRewardTokens]);
    strcat(string, smallstr);
    #endif
    format(smallstr, sizeof(smallstr), "Channel: %d khz", wtc);
    strcat(string, smallstr);

    SendClientMessage(playerid, WHITE, string);



    format(string, sizeof(string), "Health: %.0f ~ Armor: %.0f ~ %s: %s ~ Cocaine: %dg ~ Weed: %dg ~ Material Packages: %d ~ Drug Packages: %d ~ Materials: %d", health, armor, marriage, PlayerInfo[targetid][pMarriedTo], cocaine, weed, packages, drugpackages, materials);
    SendClientMessage(playerid, WHITE, string);



    format(string, sizeof(string), "VIP Rank: %s (%d) ~ Bills: $%d ~ Ropes: %d ~ Cigars: %d ~ Cans of Sprunk: %d ~ Spraycans: %d ~ Heroin: %dg ~ Meth: %dg", viprank, PlayerInfo[targetid][pDonateRank], bills, ropes, cigars, sprunk, spraycans, heroin, meth);
    SendClientMessage(playerid, WHITE, string);



    new divisiontext[32], divisiontag[12];
    if (PlayerInfo[targetid][pDivision] == 0) divisiontext = "None", divisiontag = "N/A";
    if (PlayerInfo[targetid][pDivision] >= 1) format(divisiontext, 32, DivisionInfo[PlayerInfo[targetid][pMember]][PlayerInfo[targetid][pDivision]][divisionName]), format(divisiontag, 12, DivisionInfo[PlayerInfo[targetid][pMember]][PlayerInfo[targetid][pDivision]][divisionTag]);

    new vehicles;
    for (new i = 1; i <= MAX_OWNED_CARS; i++)
    {
    if (VehicleKeys[targetid] != 0) vehicles++;
    }

    new yesno[10];
    if (iPod[targetid] == 0) yesno = "No";
    if (iPod[targetid] == 1) yesno = "Yes";

    format(string, sizeof(string), "Division: %s (%s) ~ Vehicles: %d/%d ~ iPod: %s ~ Total Wealth: $%d ~ Date Registered: %s %d, %d @ %02d:%02d:%02d", divisiontext, divisiontag, vehicles, MAX_OWNED_CARS, yesno, wallet + bank, GetMonth(PlayerInfo[targetid][pRegisterDate][2]), PlayerInfo[targetid][pRegisterDate][1], PlayerInfo[targetid][pRegisterDate][3], PlayerInfo[targetid][pRegisterDate][4], PlayerInfo[targetid][pRegisterDate][5], PlayerInfo[targetid][pRegisterDate][6]);
    SendClientMessage(playerid, WHITE, string);



    if (PlayerInfo[playerid][pAdmin] > 0) // How come this wasn't added?
    {
    format(string, sizeof(string), "Admin Level: %d ~ House Keys: %d/%d ~ Garage Keys: %d/%d ~ Business Keys: %d/%d ~ Interior: %d ~ World: %d ~ Jail: %s (%d sec)", admin, housekey, HouseKey2[targetid], garagekey, GarageKey2[targetid], bizkey, BizKey2[targetid], interior, virtualworld, jailtype, jailtime);
    SendClientMessage(playerid, LIGHTRED, string);
    }
    }
    return 1;
    }


    Ich bedanke mich schon mal im Voraus.

    MfG - Tobi_Wayne

  • new whostats[48];
    if (targetid == playerid) whostats = "Your";
    else if(targetid != playerid) format(whostats, sizeof(whostats), "%s's", PlayerName(targetid));



    format(whostats, sizeof(whostats), "%s Statistics", whostats);



    format(string, sizeof(string), "Level: %d ~ Gender: %s ~ Age: %d ~ Wallet: $%d ~ Bank Account: $%d ~ Bank PIN: %d ~ Phone Number: %d ~ Job: %s (%d)\n", plevel, gender, age, wallet, bank, bankpin, number, job, joblevel);



    format(string, sizeof(string), "%sTotal Hours Online: %d ~ Warnings: %d ~ Upgrade Points: %d ~ Spawn Armor: %d ~ Experience: %d/%d ~ Crimes Committed: %d ~ Times Arrested: %d\n", string, hours, warns, upgradepoints, spawnhealth, exp, expamount, crimes, arrests);


    new smallstr[64];
    format(string, sizeof(string), "%sOrganization: %s ~ Rank: %s (%d) ~ Products: %d ~ Wanted Level: %d ~ \n", string, GetPlayerFactionName(targetid), GetPlayerRank(targetid), rank, prods, wantedlevel);
    #if defined COOKIE_SYSTEM
    format(smallstr, sizeof(smallstr), "Cookies: %d ~ ", cookies);
    strcat(string, smallstr);
    #endif
    #if defined GIFT_SYSTEM
    format(smallstr, sizeof(smallstr), "Gifts: %d ~ ", gifts);
    strcat(string, smallstr);
    #endif
    #if defined REWARD_SYSTEM
    format(smallstr, sizeof(smallstr), "Reward Tokens: %d ~ ", PlayerInfo[targetid][pRewardTokens]);
    strcat(string, smallstr);
    #endif
    format(smallstr, sizeof(smallstr), "Channel: %d khz\n", wtc);
    strcat(string, smallstr);



    format(string, sizeof(string), "%sHealth: %.0f ~ Armor: %.0f ~ %s: %s ~ Cocaine: %dg ~ Weed: %dg ~ Material Packages: %d ~ Drug Packages: %d ~ Materials: %d\n", string, health, armor, marriage, PlayerInfo[targetid][pMarriedTo], cocaine, weed, packages, drugpackages, materials);



    format(string, sizeof(string), "%sVIP Rank: %s (%d) ~ Bills: $%d ~ Ropes: %d ~ Cigars: %d ~ Cans of Sprunk: %d ~ Spraycans: %d ~ Heroin: %dg ~ Meth: %dg\n", string, viprank, PlayerInfo[targetid][pDonateRank], bills, ropes, cigars, sprunk, spraycans, heroin, meth);



    new divisiontext[32], divisiontag[12];
    if (PlayerInfo[targetid][pDivision] == 0) divisiontext = "None", divisiontag = "N/A";
    if (PlayerInfo[targetid][pDivision] >= 1) format(divisiontext, 32, DivisionInfo[PlayerInfo[targetid][pMember]][PlayerInfo[targetid][pDivision]][divisionName]), format(divisiontag, 12, DivisionInfo[PlayerInfo[targetid][pMember]][PlayerInfo[targetid][pDivision]][divisionTag]);


    new vehicles;
    for (new i = 1; i <= MAX_OWNED_CARS; i++)
    {
    if (VehicleKeys[targetid] != 0) vehicles++;
    }


    new yesno[10];
    if (iPod[targetid] == 0) yesno = "No";
    if (iPod[targetid] == 1) yesno = "Yes";


    format(string, sizeof(string), "%sDivision: %s (%s) ~ Vehicles: %d/%d ~ iPod: %s ~ Total Wealth: $%d ~ Date Registered: %s %d, %d @ %02d:%02d:%02d\n", string, divisiontext, divisiontag, vehicles, MAX_OWNED_CARS, yesno, wallet + bank, GetMonth(PlayerInfo[targetid][pRegisterDate][2]), PlayerInfo[targetid][pRegisterDate][1], PlayerInfo[targetid][pRegisterDate][3], PlayerInfo[targetid][pRegisterDate][4], PlayerInfo[targetid][pRegisterDate][5], PlayerInfo[targetid][pRegisterDate][6]);



    if (PlayerInfo[playerid][pAdmin] > 0) // How come this wasn't added?
    {
    format(string, sizeof(string), "%sAdmin Level: %d ~ House Keys: %d/%d ~ Garage Keys: %d/%d ~ Business Keys: %d/%d ~ Interior: %d ~ World: %d ~ Jail: %s (%d sec)", string, admin, housekey, HouseKey2[targetid], garagekey, GarageKey2[targetid], bizkey, BizKey2[targetid], interior, virtualworld, jailtype, jailtime);
    }

    ShowPlayerDialog(playerid, 1337, DIALOG_STYLE_MSGBOX, whostats, string, "Ok", "");
    }
    return 1;
    }


    Du musst aber bei
    new string[was_auch_immer_hier_steht];
    das "was_auch_immer_hier_steht" erhöhen, zu 1024 oder sowas.

  • Gut, dann erkläre ich es dir.


    Beispiel:
    format(string, sizeof(string), "%sTotal Hours Online: %d ~ Warnings: %d ~ Upgrade Points: %d ~ Spawn Armor: %d ~ Experience: %d/%d ~ Crimes Committed: %d ~ Times Arrested: %d\n", string, hours, warns, upgradepoints, spawnhealth, exp, expamount, crimes, arrests);


    Ich hab vorne ein "%s" hin gemacht, und hinten ein \n.
    In die Parameter hab ich als erstes "string" hingesetzt, das fügt den bereits vorhandenen string (Zeile davor) bei "%s" ein. \n macht hinten den Zeilenumbruch.


    Anschaulich:
    new string[128];
    format(string, sizeof(string), "Hallo");
    format(string, sizeof(string), "%s Welt!", string);
    print(string);
    //print gibt aus: "Hallo Welt!"

  • Danke, ich probier das mal.
    Wie sieht es damit aus?




    if(strcmp(cmd, "/stats", true) == 0)
    {
    if(IsPlayerConnected(playerid))
    {
    if(gPlayerLogged[playerid] != 0) ShowStats(playerid,playerid);
    else SendClientMessage(playerid, GREY, " You are not Logged in.");
    }
    return 1;
    }
    if(strcmp(cmd, "/stealth", true) == 0)
    {
    if(IsPlayerConnected(playerid))
    {
    if(PlayerInfo[playerid][pAdmin] >= 3)
    {
    if(PlayerInfo[playerid][pStealthed] == 0)
    {
    PlayerInfo[playerid][pStealthed] = 1;
    return SendClientMessage(playerid, GREY, " You are now hidden.");
    }
    if(PlayerInfo[playerid][pStealthed] == 1)
    {
    PlayerInfo[playerid][pStealthed] = 0;
    return SendClientMessage(playerid, GREY, " You are no longer hidden.");
    }
    }
    }
    }

    Muss das so bleiben?

  • Das schreiben wir lieber so, sieht schöner aus und ist besser lesbar.
    if(strcmp(cmd, "/stats", true) == 0)
    {
    if(IsPlayerConnected(playerid))
    {
    if(gPlayerLogged[playerid] != 0) ShowStats(playerid,playerid);
    else SendClientMessage(playerid, GREY, " You are not Logged in.");
    }
    return 1;
    }
    if(strcmp(cmd, "/stealth", true) == 0)
    {
    if(IsPlayerConnected(playerid))
    {
    if(PlayerInfo[playerid][pAdmin] >= 3)
    {
    if(PlayerInfo[playerid][pStealthed] == 0)
    {
    PlayerInfo[playerid][pStealthed] = 1;
    return SendClientMessage(playerid, GREY, " You are now hidden.");
    }
    if(PlayerInfo[playerid][pStealthed] == 1)
    {
    PlayerInfo[playerid][pStealthed] = 0;
    return SendClientMessage(playerid, GREY, " You are no longer hidden.");
    }
    }
    }
    }

    Ansonsten sollte es passen.


  • Habe das nun so gemacht.
    Nur mit den strings noch nicht.
    Habe das erstmal so übernommen.
    Aber es wird nicht mal die hälfte ingame angezeigt.
    Als Dialog funktioniert es schon mal.


    Hier der Screen: http://de.tinypic.com/view.php?pic=9kupmd&s=8#.U-0ZWfl_vuM

  • do.de - Domain-Offensive - Domains für alle und zu super Preisen
  • Ok. Du musst die Größe von "string" erhöhen.


    So wie bei dem hier:
    new whostats[48];
    steht irgndwo vor ^dem sowas:


    new string[HIER_EINE_ZAHL];


    Das HIER_EINE_ZAHL ist bei dir irgendeine Zahl, die musst du erhöhen, am besten so:
    new string[1024];


    Dann solltest du alles sehen.