Szerző Téma: XP Rendszer  (Megtekintve 3017 alkalommal)

XP Rendszer
« Válasz #15 Dátum: 2014. Április 08. - 10:29:12 »
0 Show voters
Nekem nem jeleniti meg a textdrawot

Nem elérhető KovaNovik

  • 1121
  • KovaNovik
    • Profil megtekintése
XP Rendszer
« Válasz #16 Dátum: 2014. Április 08. - 11:54:52 »
0 Show voters
Jó lett! Kaptál tõlem (is) egy pluszt!
Én még annyit elmondanék, hogy ezt a sok ifet jobb lenne helyettesíteni casekkel, vagy csak simán egy szorzót használni hozzá. Mindjárt írok részleteket.
Elsõ megoldás (switch, case):
 

forward XP_Level(playerid);
public XP_Level(playerid)
{
switch(GetPVarInt(playerid, \"XP\"))
{
case 0..100: SetPVarInt(playerid, \"xplvl\", 1);
case 100..250: SetPVarInt(playerid, \"xplvl\", 2);
case 250..500: SetPVarInt(playerid, \"xplvl\", 3);
case 500..800: SetPVarInt(playerid, \"xplvl\", 4);
case 800..1200: SetPVarInt(playerid, \"xplvl\", 5);
case 1200..1800: SetPVarInt(playerid, \"xplvl\", 6);
case 1800..2500: SetPVarInt(playerid, \"xplvl\", 7);
case 2500..3200: SetPVarInt(playerid, \"xplvl\", 8);
case 3200..4000: SetPVarInt(playerid, \"xplvl\", 9);
case 4000..4800: SetPVarInt(playerid, \"xplvl\", 10);
case 4800..5900: SetPVarInt(playerid, \"xplvl\", 11);
case 5900..7000: SetPVarInt(playerid, \"xplvl\", 12);
case 7000..9000: SetPVarInt(playerid, \"xplvl\", 13);
case 9000..11000: SetPVarInt(playerid, \"xplvl\", 14);
case 11000..13500: SetPVarInt(playerid, \"xplvl\", 15);
case 13500..16000: SetPVarInt(playerid, \"xplvl\", 16);
case 16000..17000: SetPVarInt(playerid, \"xplvl\", 17);
case 17000..20000: SetPVarInt(playerid, \"xplvl\", 18);
case 20000..23000: SetPVarInt(playerid, \"xplvl\", 19);
case 23000..28000: SetPVarInt(playerid, \"xplvl\", 20);
case 28000..35000: SetPVarInt(playerid, \"xplvl\", 21);
case 35000..40000: SetPVarInt(playerid, \"xplvl\", 22);
case 40000..45000: SetPVarInt(playerid, \"xplvl\", 23);
case 45000..50000: SetPVarInt(playerid, \"xplvl\", 24);
case 50000..52000: SetPVarInt(playerid, \"xplvl\", 25);
case 52000..58000: SetPVarInt(playerid, \"xplvl\", 26);
case 58000..62000: SetPVarInt(playerid, \"xplvl\", 27);
case 62000..70000: SetPVarInt(playerid, \"xplvl\", 28);
case 70000..80000: SetPVarInt(playerid, \"xplvl\", 29);
case 80000..100000: SetPVarInt(playerid, \"xplvl\", 30);
default:/*Ha semelyik nem igaz rá (<0 vagy >100000)*/SetPVarInt(playerid, \"xplvl\", 9999);
}
}

 
Második megoldás (ciklusos):
 

forward XP_Level(playerid);
public XP_Level(playerid)
{
new szinthatar[] =
{0, 100, 250, 500, 800, 1200, 1800, 2500, 3200, 4000, 4800, 5900,
7000, 9000, 11000, 13500, 16000, 17000, 20000, 23000, 28000, 35000,
40000, 45000, 50000, 52000, 58000, 62000, 70000, 80000, 100000};
for(new a = 0; a < sizeof(szinthatar), a++)
{
if(szinthatar[a] <= GetPVarInt(playerid, \"XP\") < szinthatar[a+1]) SetPVarInt(playerid, \"xplvl\", a);
}
}

 
Harmadik megoldás (coming soon, valami misztikus szorzóval lesz megoldva 1-2 sorban):
 

forward XP_Level(playerid);
public XP_Level(playerid)
{
new xplvl = GetPVarInt(playerid, \"xplvl\"), XP = GetPVarInt(playerid, \"XP\"), kelloxp = (floatround(floatsqroot(XP)*xplvl/(XP/12)*XP);
if(XP >= kelloxp) SetPVarInt(playerid, \"xplvl\", xplvl+1);
}

 
... vagy valami hasonló. :D Remélem nem írtam oltári nagy hülyeséget, a vége felé már nagyon bekavarodtam, de azért felteszem, hátha hasznát veszi valaki.
Mindenesetre sok szerencsét, további jó scriptelést(és még 1000 ilyen (kis hasznos) scriptet)! :thumbsup:
U.i.: Helyes code tag:
 
[ c o d e = p a w n ]  [ / c o d e ]
« Utoljára szerkesztve: 2014. Április 08. - 13:11:26 írta KovaNovik »

Nem elérhető Thomas_Jonson

  • 560
  • Thomas_Jonson
    • Profil megtekintése
XP Rendszer
« Válasz #17 Dátum: 2014. Április 08. - 13:53:16 »
0 Show voters
Tetszik. :)

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal