Szerző Téma: Taxióra km/h hiba  (Megtekintve 923 alkalommal)

Taxióra km/h hiba
« Dátum: 2018. Április 01. - 15:37:53 »
0
Sziasztok, készülő rpg szerveremnél lesz taxi frakció is és taxiórát csináltam éppen, a lényeg annyi hogy a taxisofőr megad egy útdíjat pl. /útdíj 50 (50$/km)
 
Amint elindítja a taxis a taxiórát egy textdraw jelzi hogy mennyit kell majd fizetnie összesen az utasnak és a megtett km-t jelzi
 
Ahogy elindul a kocsi a fizetendő összeg felugrik 100 millió felé és a megtett km is, mi lehet a hiba?
 
 
 
Taxióra parancs
 

CMD:taxiora(playerid, params[])
{
if(JatekosInfo[playerid][Frakcio] == 6)
{
    if(IsPlayerInVehicle(playerid,taxikocsi1) || IsPlayerInVehicle(playerid,taxikocsi2) || IsPlayerInVehicle(playerid,taxikocsi3) || IsPlayerInVehicle(playerid,taxikocsi4) || IsPlayerInVehicle(playerid,taxikocsi5) || IsPlayerInVehicle(playerid,taxikocsi6) || IsPlayerInVehicle(playerid,taxikocsi7) || IsPlayerInVehicle(playerid,taxikocsi8))
    {
        if(Szolgalatban[playerid] == true)
        {
           if(taxiora == false)
           {
              new string[128];
              format(string, sizeof(string),\"Elindítottad a taxiórát! Útdíj: %i$/km\", JatekosInfo[playerid][Utdij]);
                   cmd_me(playerid, \"elindítja a taxiórát.\");
                  SCM(playerid, -1, string);
              taxiora = true;
              TextDrawShowForPlayer(playerid,Text:Fizetendo);
              TextDrawShowForPlayer(playerid,Text:KM);
              TextDrawShowForPlayer(playerid,Text:Taxiora);
          }
          else
          {
                 new string[128];
            FizetendoTaxi = JatekosInfo[playerid][TaxiKM] * JatekosInfo[playerid][Utdij];
              format(string, sizeof(string),\"Taxióra megállítva! Fizetendő összeg: %d$\", FizetendoTaxi);
              SCM(playerid, -1, string);
              taxiora = false;
            TextDrawHideForPlayer(playerid,Text:Fizetendo);
                 TextDrawHideForPlayer(playerid,Text:KM);
                TextDrawHideForPlayer(playerid,Text:Taxiora);
                cmd_me(playerid, \"leállította a taxiórát.\");
                JatekosInfo[playerid][TaxiKM] = 0;
                FizetendoTaxi = 0;
          }
      }
      else
      {
          SCM(playerid, -1,\"{ff0000}Nem vagy szolgálatban!\");
      }
   }
    else
    {
        SCM(playerid, -1,\"{ff0000}Nem ülsz taxis kocsiban!\");
    }
}
else
{
    SCM(playerid, -1,\"{ffdd00}[S-ROLEPLAY] {ffffff}Ehhez a parancshoz nincs jogosultságod!\");
}
return 1;
}

 
OnPlayerUpdate
 

public OnPlayerUpdate(playerid)
{
if(taxiora == true)
{
    new string[128];
   FizetendoTaxi = JatekosInfo[playerid][TaxiKM] * JatekosInfo[playerid][Utdij];
   new Float:kmszamit;
   kmszamit = GetVehicleSpeed(GetPlayerVehicleID(playerid));
   JatekosInfo[playerid][TaxiKM] += kmszamit;
    format(string, sizeof(string),\"Fizetendo: %i$\", FizetendoTaxi);
         TextDrawSetString(Fizetendo, string);
    format(string, sizeof(string),\"KM: %i\", JatekosInfo[playerid][TaxiKM]);
   TextDrawSetString(KM, string);
}
if(JatekosInfo[playerid][Frakcio] == 6)
{
    if(taxiora == true)
    {
      if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
      {
         TextDrawHideForPlayer(playerid,Text:Fizetendo);
         TextDrawHideForPlayer(playerid,Text:KM);
         TextDrawHideForPlayer(playerid,Text:Taxiora);
         SCM(playerid,-1,\"{ff0000}A taxióra leállt!\");
         JatekosInfo[playerid][TaxiKM] = 0;
         FizetendoTaxi = 0;
         taxiora = false;
      }
   }
}
    return true;
}

 
Textdrawok
 

new Text:Fizetendo;
new Text:KM;
new Text:Taxiora;
 
Fizetendo = TextDrawCreate(162.000000, 340.000000, \"Fizetendo: 0$\");
TextDrawBackgroundColor(Fizetendo, 255);
TextDrawFont(Fizetendo, 2);
TextDrawLetterSize(Fizetendo, 0.600000, 2.200000);
TextDrawColor(Fizetendo, -1);
TextDrawSetOutline(Fizetendo, 1);
TextDrawSetProportional(Fizetendo, 1);
TextDrawSetSelectable(Fizetendo, 0);
KM = TextDrawCreate(162.000000, 360.000000, \"KM: 0\");
TextDrawBackgroundColor(KM, 255);
TextDrawFont(KM, 2);
TextDrawLetterSize(KM, 0.600000, 2.200000);
TextDrawColor(KM, -1);
TextDrawSetOutline(KM, 1);
TextDrawSetProportional(KM, 1);
TextDrawSetSelectable(KM, 0);
Taxiora = TextDrawCreate(161.000000, 318.000000, \"Taxi Ora\");
TextDrawBackgroundColor(Taxiora, 255);
TextDrawFont(Taxiora, 2);
TextDrawLetterSize(Taxiora, 0.600000, 2.200000);
TextDrawColor(Taxiora, -65281);
TextDrawSetOutline(Taxiora, 1);
TextDrawSetProportional(Taxiora, 1);
TextDrawSetSelectable(Taxiora, 0);

 
GetVehicleSpeed stock
 

stock GetVehicleSpeed( vehicleid )
{
    new
        Float:x,
        Float:y,
        Float:z,
        vel;
    GetVehicleVelocity( vehicleid, x, y, z );
    vel = floatround( floatsqroot( x*x + y*y + z*z ) * 180 );
    return vel;
}

 
 
« Utoljára szerkesztve: 2018. Április 01. - 15:39:24 írta Broocean »

Taxióra km/h hiba
« Válasz #1 Dátum: 2018. Április 01. - 16:53:22 »
+1
A megtett kilométer neked egyenlő a jármű sebességével? 1 sec alatt az onplayerupdate lefut vagy 7-8x, Ha a jármű megy 100km/h-val. akkor 1 sec alatt 7-8x lefut az update. tehát 700-800km lesz a megtett táv? Holott 1 sec alatt 1 km-t sem megy. Nem valami valós a számítás. Ha ezt még beszorozza az útdíjjal ami gondolom nem 1 egység, akkor nyilván felugrik milliókba pillanatok alatt. De ha jobban belegondolsz elég logikus szóval gondold át.

Taxióra km/h hiba
« Válasz #2 Dátum: 2018. Április 01. - 17:41:54 »
0
Oh tényleg, köszönöm szépen.. csak kicsit összekavarodtam :/ igazad van.

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal