Szerző Téma: Elmagyarázná valaki?  (Megtekintve 702 alkalommal)

Nem elérhető zeteni

  • 1970
  • Ex-Scripter
    • Profil megtekintése
Elmagyarázná valaki?
« Dátum: 2012. Június 10. - 20:49:06 »
0 Show voters
stock GetPlayerSpeed(playerid)
{
new speed;
if(!IsPlayerInAnyVehicle(playerid)) return -1;
new Float:VelocityX;
new Float:VelocityY;
new Float:VelocityZ;
GetVehicleVelocity(GetPlayerVehicleID(playerid),VelocityX,VelocityY,VelocityZ);
speed = floatround(floatpower((VelocityX*VelocityX)+(VelocityY*VelocityY)+(VelocityZ*VelocityZ),0.5)*217.5);
return speed;
}

 
Sziasztok! Pedro-tól láttam ezt a stock-ot és akárhogy is nézem nem nagyon értem, hogy mi mit csinál. Azt értem, hogy sebességmérõ akar lenni, de valaki leírná, hogy mi micsoda mit csinák? :) Köszönöm!

Elmagyarázná valaki?
« Válasz #1 Dátum: 2012. Június 11. - 00:50:47 »
0 Show voters
Ez lekéri a jármû mozgását, és sebességgé alakítja
Használata egyszerû.
Szimplán beilleszted a sebességmérõdbe
 
new string[32];
format(string, sizeof(string), \"Sebesség: %d KM/h\", GetPlayerSpeed(playerid));
SendClientMessage(playerid, -1, string);

 
Hogy melyik Float mit csinál, azt ne kérdezd, mert fogalmam nincs (nem értek hozzá)
A GetVehicleVelocity pedig a gyorsulást méri le.
« Utoljára szerkesztve: 2012. Június 11. - 00:54:41 írta TengeriMalac »

Nem elérhető Norby

  • 1575
    • Profil megtekintése
Elmagyarázná valaki?
« Válasz #2 Dátum: 2012. Június 11. - 14:41:50 »
0 Show voters
floatround: egy lebegõpontos számot kerekít egész számmá.
floatpowe: ezt hatványozásra használjuk.

Elmagyarázná valaki?
« Válasz #3 Dátum: 2012. Június 11. - 15:17:30 »
0 Show voters
Idézetet írta: Norby date=1339418510\" data-ipsquote-contentapp=\"forums\" data-ipsquote-contenttype=\"forums\" data-ipsquote-contentid=\"22686\" data-ipsquote-contentclass=\"forums_Topic
floatround: egy lebegõpontos számot kerekít egész számmá.
floatpowe: ezt hatványozásra használjuk.
 
Akkor a floatroundot jól tippeltem :)

Kovacs_Bela

  • Vendég
Elmagyarázná valaki?
« Válasz #4 Dátum: 2012. Június 11. - 17:31:23 »
0 Show voters

#include <a_samp>
new Text:seb = TextDrawCreate(200,200,\"sebesseg\");
new timer[MAX_PLAYERS];
public OnPlayerEnterVehicle(playerid,vehicleid)
{
    new str[128];
    format(str,128,\"%d\",GetPlayerSpeed(playerid));
    TextDrawSetString(seb,str);
    TextDrawShowForPlayer(playerid,seb);
    timer[playerid] = SetTimerEx(\"timercar\",500,true,\"d\",playerid);
    return 1;
}
public OnPlayerExitVehicle(playerid,vehicleid)
{
    KillTimer(timer[playerid]);
    TextDrawHideForPlayer(playerid);
    return 1;
}
public timercar(playerid);
public timercar(playerid)
{
    new str[128];
    format(str,128,\"%d\",GetPlayerSpeed(playerid));
    TextDrawSetString(seb,str);
}
    stock GetPlayerSpeed(playerid)
    {
            new speed;
     
            if(!IsPlayerInAnyVehicle(playerid)) return -1;
     
            new Float:VelocityX;
            new Float:VelocityY;
            new Float:VelocityZ;
     
            GetVehicleVelocity(GetPlayerVehicleID(playerid),VelocityX,VelocityY,VelocityZ);
            speed = floatround(floatpower((VelocityX*VelocityX)+(VelocityY*VelocityY)+(VelocityZ*VelocityZ),0.5)*217.5);
     
            return speed;
    }

Nem elérhető Pedró

  • 3341
  • 2014 © Az év Szkriptere
    • Profil megtekintése
Elmagyarázná valaki?
« Válasz #5 Dátum: 2012. Június 11. - 19:45:38 »
0 Show voters
Idézetet írta: zeteni date=1339354146\" data-ipsquote-contentapp=\"forums\" data-ipsquote-contenttype=\"forums\" data-ipsquote-contentid=\"22686\" data-ipsquote-contentclass=\"forums_Topic
Pedro
 
hmmm?? h-h tõlem?
amúgy lekérdezed a játékosnak a sebességét..

Nem elérhető zeteni

  • 1970
  • Ex-Scripter
    • Profil megtekintése
Elmagyarázná valaki?
« Válasz #6 Dátum: 2012. Június 11. - 21:02:19 »
0 Show voters
köszönöm mindenkinek. A norbyéra voltam kiváncsi

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal