Datum anzeigen?

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
  • So sieht es bei mir aus:


    forward datum();


    dann den new Text: Jahr; für Textdraw



    Textdraw
    Jahr =TextDrawCreate(542.000000, 37.000000, "03.06.2015");
    TextDrawBackgroundColor (Jahr, 255);
    TextDrawFont (Jahr, 1);
    TextDrawLetterSize (Jahr, 0.500000, 1.000000);
    TextDrawColor (Jahr, -16776961);
    TextDrawSetOutline (Jahr, 0);
    TextDrawSetProportional (Jahr, 1);




    so steht alles bei mir im Public:
    public datum()
    new string[128];
    for(new i=0; i<MAX_PLAYERS; i++)
    format(string,sizeof(string),"%datum:"datum);
    getdate(year,month,day);
    format(string,sizeof(string),"%02d:%02d%",year,month,day);
    TextDrawSetString(Jahr,string)



    Ich hoffe man kann mir hier helfen.

  • static datum();
    public datum(){
    new string[30], year, month;
    getdate(year,month),
    format(string,sizeof(string),"%02d:%02d%",day,month),
    TextDrawSetString(Jahr,string);
    return;
    }


    Schreibe das ganze mal so! (Das Forward bitte euch entfernen)


    mfg :thumbup:

  • forward sekunde();
    forward datum();


    //new
    new Text:uhrzeitLabel;
    new Text: Jahr;


    so wie:
    //Textdraws:
    uhrzeitLabel =TextDrawCreate(549.000000, 46.000000, "22:30");
    TextDrawBackgroundColor (uhrzeitLabel, 255);
    TextDrawFont (uhrzeitLabel, 0);
    TextDrawLetterSize (uhrzeitLabel, 0.569999, 1.000000);
    TextDrawColor (uhrzeitLabel, 16711935);
    TextDrawSetOutline (uhrzeitLabel, 0);
    TextDrawSetProportional (uhrzeitLabel, 1);


    Jahr =TextDrawCreate(542.000000, 37.000000, "03.06.2015");
    TextDrawBackgroundColor (Jahr, 255);
    TextDrawFont (Jahr, 1);
    TextDrawLetterSize (Jahr, 0.500000, 1.000000);
    TextDrawColor (Jahr, -16776961);
    TextDrawSetOutline (Jahr, 0);
    TextDrawSetProportional (Jahr, 1);



    und:


    public sekunde()
    {
    new string[128];
    for(new i=0; i<MAX_PLAYERS; i++)
    {
    if(!IsPlayerConnected(i))continue;
    if(!IsPlayerInAnyVehicle(i))continue;
    format(string,sizeof(string),"%ikm/h",Spielergeschwindigkeit(i));
    GameTextForPlayer(i,string,1000,3);
    }
    new hour,minute,second;
    gettime(hour,minute,second);
    format(string,sizeof(string),"%02d:%02d",hour,minute,second);
    TextDrawSetString(uhrzeitLabel,string);
    return 1;
    }
    static datum();
    {
    new string[30], year, month;
    getdate(year,month),
    format(string,sizeof(string),"%02d:%02d%",day,month),
    TextDrawSetString(Jahr,string);
    return;
    }


    voll am durch drehen:


    Fehlermeldeung:

  • static datum();
    {
    new string[30], year, month;
    getdate(year,month),
    format(string,sizeof(string),"%02d:%02d%",day,month),
    TextDrawSetString(Jahr,string);
    return;
    }


    zu


    static datum();
    public datum()
    {
    new string[30], year, month;
    getdate(year,month),
    format(string,sizeof(string),"%02d:%02d%",day,month),
    TextDrawSetString(Jahr,string);
    return;
    }


    mfg :thumbup:

  • also ich habe es jetzt so:


    static datum();
    public datum()
    {
    new string[30], year, month;
    getdate(year,month),
    format(string,sizeof(string),"%02d:%02d%",day,month),
    TextDrawSetString(Jahr,string);
    return;
    }




    es kommt aber folgendes:

    PHP
    samplernen.p(482) : error 021: symbol already defined: "datum"
    samplernen.p(484) : error 021: symbol already defined: "datum"
    samplernen.p(486 -- 487) : error 017: undefined symbol "day"
  • Da ist ein Fehler drin der sich bis zu dir runtergezogen hat


    public datum() {
    new string[64], year, month, day;
    getdate(Year, Month, Day);
    format(string,sizeof(string),"%02d:%02d:%d",day,month,Year);
    TextDrawSetString(Jahr,string);
    return 1;
    }



    Falls der Bug noch nicht behoben sein sollte, eventuell nochmals


    TextDrawShowForAll(Jahr);


    aufrufen

  • Laut den Fehlermeldungen in den folgenden Bereichen:
    forword OnUserCheck(playerid);


    Teil1:
    public OnUserCheck(playerid)
    {
    new num_rows,num_fields;
    cache_get_data(num_rows,num_fields,dbhandle);
    if(num_rows==0)
    {
    //Register
    ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Account Erstellung","Gebe bitte nun dein gewünschtes Passwort ein!","Registrieren","Abbrechen");
    }
    else
    {
    //Login
    ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Anmelden","Gebe bitte dein Passwort ein.","Anmleden","Abbrechen");
    }
    return 1;
    }


    public OnPlayerConnect(playerid)
    {
    new nachricht[128];
    format(nachricht,sizeof(nachricht),"Du bist mit der ID %i verbunden.",playerid);
    SendClientMessage(playerid,rot,nachricht);
    //Login/Register:
    new name[MAX_PLAYER_NAME],query[128];
    GetPlayerName(playerid,name,sizeof(name));
    format(query,sizeof(query),"SELECT id FROM user WHERE username='%s' ",name);
    mysql_function_query(dbhandle,query,true,"OnUserCheck","i",playerid);
    SendClientMessage(playerid,grün,"Willkommen auf Reallife Version 1.0! Wir wünschen euch ein angenhmen Spiel spaß bei uns!");


    //removebildings:
    RemoveBuildingForPlayer(playerid, 8420, 2397.3906, 1663.2266, 9.8438, 0.25);
    RemoveBuildingForPlayer(playerid, 8433, 2437.3906, 1663.2344, 14.0781, 0.25);
    RemoveBuildingForPlayer(playerid, 710, 2412.6406, 1700.6172, 25.4375, 0.25);
    RemoveBuildingForPlayer(playerid, 710, 2420.3984, 1626.6406, 25.4375, 0.25);
    RemoveBuildingForPlayer(playerid, 710, 2435.0781, 1626.6406, 25.4375, 0.25);
    RemoveBuildingForPlayer(playerid, 8736, 2437.3906, 1663.2344, 14.0781, 0.25);
    RemoveBuildingForPlayer(playerid, 8773, 2474.8906, 1663.2266, 9.8438, 0.25);
    RemoveBuildingForPlayer(playerid, 8966, 2435.2578, 1662.9063, 14.0703, 0.25);
    RemoveBuildingForPlayer(playerid, 9062, 2474.8906, 1663.2266, 9.8438, 0.25);
    RemoveBuildingForPlayer(playerid, 9063, 2397.3906, 1663.2266, 9.8438, 0.25);
    RemoveBuildingForPlayer(playerid, 747, 2380.5000, 1626.2109, 10.0625, 0.25);
    RemoveBuildingForPlayer(playerid, 681, 2382.2813, 1624.6328, 9.9453, 0.25);
    RemoveBuildingForPlayer(playerid, 681, 2379.4063, 1629.1406, 9.9453, 0.25);
    RemoveBuildingForPlayer(playerid, 634, 2399.1406, 1624.9063, 9.9219, 0.25);
    RemoveBuildingForPlayer(playerid, 1231, 2435.4688, 1642.1406, 12.5391, 0.25);
    RemoveBuildingForPlayer(playerid, 1231, 2397.3750, 1663.2266, 12.6719, 0.25);
    RemoveBuildingForPlayer(playerid, 996, 2391.7891, 1663.1719, 10.6797, 0.25);
    RemoveBuildingForPlayer(playerid, 996, 2409.5156, 1663.1719, 10.6797, 0.25);
    RemoveBuildingForPlayer(playerid, 1231, 2417.2188, 1663.2266, 12.5391, 0.25);
    RemoveBuildingForPlayer(playerid, 1215, 2423.6250, 1668.6172, 10.3516, 0.25);
    RemoveBuildingForPlayer(playerid, 1215, 2423.6250, 1656.8438, 10.3516, 0.25);
    RemoveBuildingForPlayer(playerid, 8550, 2435.2578, 1662.9063, 14.0703, 0.25);
    RemoveBuildingForPlayer(playerid, 1215, 2441.2969, 1651.6484, 10.3516, 0.25);
    RemoveBuildingForPlayer(playerid, 1215, 2428.9688, 1651.6484, 10.3516, 0.25);
    RemoveBuildingForPlayer(playerid, 1231, 2435.4688, 1682.6094, 12.5469, 0.25);
    RemoveBuildingForPlayer(playerid, 1215, 2428.9688, 1673.7734, 10.3516, 0.25);
    RemoveBuildingForPlayer(playerid, 1215, 2441.2969, 1673.7734, 10.3516, 0.25);
    RemoveBuildingForPlayer(playerid, 8563, 2434.7266, 1702.3281, 13.9844, 0.25);
    RemoveBuildingForPlayer(playerid, 747, 2440.4922, 1698.5781, 10.0625, 0.25);
    RemoveBuildingForPlayer(playerid, 634, 2449.1016, 1701.4922, 9.9219, 0.25);
    RemoveBuildingForPlayer(playerid, 1215, 2447.4922, 1656.8438, 10.3516, 0.25);
    RemoveBuildingForPlayer(playerid, 1215, 2447.4922, 1668.6172, 10.3516, 0.25);
    RemoveBuildingForPlayer(playerid, 1231, 2453.3359, 1663.2266, 12.5391, 0.25);
    RemoveBuildingForPlayer(playerid, 996, 2471.9609, 1663.1719, 10.6797, 0.25);
    RemoveBuildingForPlayer(playerid, 634, 2459.0703, 1624.9063, 9.9219, 0.25);
    RemoveBuildingForPlayer(playerid, 620, 2454.9297, 1701.5938, 9.8438, 0.25);
    RemoveBuildingForPlayer(playerid, 1231, 2477.3984, 1663.2266, 12.6719, 0.25);
    RemoveBuildingForPlayer(playerid, 620, 2475.3125, 1628.6094, 9.8438, 0.25);
    RemoveBuildingForPlayer(playerid, 681, 2475.2422, 1624.6328, 9.9453, 0.25);
    RemoveBuildingForPlayer(playerid, 8551, 2479.9453, 1624.3203, 13.9844, 0.25);
    RemoveBuildingForPlayer(playerid, 996, 2489.6953, 1663.1719, 10.6797, 0.25);
    RemoveBuildingForPlayer(playerid, 746, 2494.8906, 1626.1719, 10.0625, 0.25);
    RemoveBuildingForPlayer(playerid, 681, 2494.6641, 1628.7734, 9.9453, 0.25);
    }



    Teil2:
    forward sekunde();
    forward datum();
    public sekunde()
    {
    new string[128];
    for(new i=0; i<MAX_PLAYERS; i++)
    {
    if(!IsPlayerConnected(i))continue;
    if(!IsPlayerInAnyVehicle(i))continue;
    format(string,sizeof(string),"%ikm/h",Spielergeschwindigkeit(i));
    GameTextForPlayer(i,string,1000,3);
    }
    new hour,minute,second;
    gettime(hour,minute,second);
    format(string,sizeof(string),"%02d:%02d",hour,minute,second);
    TextDrawSetString(uhrzeitLabel,string);
    return 1;

    public datum()
    {
    new string[64];
    getdate(Year, Month, Day);
    format(string,sizeof(string),"%02d:%02d:%d",day,month,Year);
    TextDrawSetString(Jahr,string);
    return 1;
    }


    Teil 3:
    gehört noch zu Spielerverbinden
    //textdraws anzeigen:
    TextDrawShowForPlayer(playerid,Text:uhrzeitLabel);
    TextDrawShowForAll(Jahr);
    return 1;



    Fehlermeldung:


  • Du kannst keine Funktion in einer Funktion haben



    so sollte das aussehen und die zwei Funktionen werden nicht aufgerufen oder verwendest du Timer


    public sekunde()
    {
    new string[128];
    for(new i=0; i<MAX_PLAYERS; i++)
    {
    if(!IsPlayerConnected(i))continue;
    if(!IsPlayerInAnyVehicle(i))continue;
    format(string,sizeof(string),"%ikm/h",Spielergeschwindigkeit(i));
    GameTextForPlayer(i,string,1000,3);
    }
    new hour,minute,second;
    gettime(hour,minute,second);
    format(string,sizeof(string),"%02d:%02d:%02d",hour,minute,second);
    TextDrawSetString(uhrzeitLabel,string);
    return 1;
    }
    public datum()
    {
    new string[64];
    getdate(Year, Month, Day);
    format(string,sizeof(string),"%02d:%02d:%d",day,month,Year);
    TextDrawSetString(Jahr,string);
    return 1;
    }