GTAvision.com - Forum - Grand Theft Auto News, Downloads, Community and more...

Position: Grand Theft Auto: San Andreas » Multiplayer » TextDraw Flughöhe Anzeigen » Druckansicht
Jermuk, 24.10.2008, 21:18
Warum funzt folgendes Script nicht?
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
forward Flughoehe();
public Flughoehe()
{
    new Text:anzeige;
    for (new i; i < MAX_PLAYERS; i++)
    {
       if(IsPlayerConnected(i))
       {
           if(IsPlayerInPlane(i))
           {
             new Float:x,Float:y,Float:z;
             GetPlayerPos(i,x,y,z);
             new string[256];
             format(string, sizeof(string),"Flughoehe: %d Meter", z );
             TextDrawDestroy(anzeige);
             anzeige = TextDrawCreate(50.0, 420.0, string);
             TextDrawLetterSize(anzeige, 0.5, 2.5);
             TextDrawShowForPlayer(i,anzeige);
             textdrawwahr[i] = 1;
           }
           else if(textdrawwahr[i] == 1)
           {
               TextDrawDestroy(anzeige);
               textdrawwahr[i] = 0;
         }
       }
    }
}

forward IsPlayerInPlane(playerid);
public IsPlayerInPlane(playerid)
{
   new heli[10] = {417, 425, 447, 465, 469, 487, 488, 497, 548, 563};
   new plane[12] = {460, 464, 476, 511, 512, 513, 519, 520, 553, 577, 592, 593};
   new model = GetVehicleModel(GetPlayerVehicleID(playerid));
   for(new i=0; i < 10; i++)
      if(model == heli[i])
         return 1;
    for(new i=0; i < 12; i++)
      if(model == plane[i])
         return 1;
   return 0;
}


Weil es nämlich unheimlich hohe Zahlen anzeigt, z.B. Flughoehe: 1100000000 Meter
Was habe ich falsch gemacht?

Gruß Jermuk
dödel, 24.10.2008, 21:22
Wenn du Float verwendest, kannst du nicht versuchen eine ganz normale Zahl auszugeben, also mach
einfach aus
Code:
1
format(string, sizeof(string),"Flughoehe: %d Meter", z );

den hier
Code:
1
format(string, sizeof(string),"Flughoehe: %.2f Meter", z );
Jermuk, 24.10.2008, 21:26
Danke!!
Funzt!
Kannst du mir das mal erklären, was es mit dem %.2f auf sich hat?
Will ja auch was lernen!
Danke im Voraus,
Gruß Jermuk
Recycler, 24.10.2008, 21:40
Erstmal bedeutet %f, dass ein Float erwartet wird. Die angehängte Zahl gibt an, wieviele Stellen
nach dem Komma noch angezeigt werden.

MfG
Recycler
GTAvision.com :: Forumregeln :: FAQ :: Impressum :: Kontakt :: RDRvision.com :: LANOIREvision.com :: MaxPayneVision.com
NetVisionWork.NET
.: © 2006-2014 by GTAvision.com :.

Rockstar GamesTake-Two Interactive Deutschland

Free Grand Theft Auto Downloads