←  Pytania

AMXX.pl: Support AMX Mod X i SourceMod

»

Float - zbyt dużo zer :/

Locked

  • +
  • -
camilost's Photo camilost 24.07.2010

Edytuje sobie teraz plugin ZP i postanowiłem dodać info przy infekcji, że coś tam ma dana klasa. W jednej klasie HP się regeneruje, więc chciałem dodać info co ile i ile HP.
CVARy w float są zrobione więc i pobieranie musiałem dać float: ;P Ale gdy wysyła wiadomość jest okropnie dużo zer po kropce, i tu pytanie:

Da się jakoś usunąć te zera? Najlepiej jakby było samo bez reszty po kropce.

Potrzebna część sma
	g_healing_delay = register_cvar("zp_healing_zombie_delay", "3.0")
g_healing_amount = register_cvar("zp_healing_zombie_amount", "50.0")

public zp_user_infected_post(player, infector)
{
new Float:h12del = get_pcvar_float(g_healing_delay)
new Float:hl2amo = get_pcvar_float(g_healing_amount)
if ((zp_get_user_zombie_class(player) == g_zclass_healing) && !zp_get_user_nemesis(player))
{

client_print(player, print_chat, "[ZP] Your health is regenerated at %f sec by %f HP", h12del, hl2amo)
}
return PLUGIN_CONTINUE
}


Wiadomość wysyłana wygląda tak:

[ZP] Your health is regenerated at 6.000000 sec by 100.000000 H


Edited by camilost, 24.07.2010 10:56.
Quote

  • +
  • -
Ortega's Photo Ortega 24.07.2010

Zamień
%f

na
%.1f


W efekcie będzie jedna cyfra po przecinku. (nie testowałem)
Edited by Ortega, 24.07.2010 13:03.
Quote

  • +
  • -
camilost's Photo camilost 24.07.2010

Dzięki, może też tak być :P

[ZP] Your health is regenerated at 6.0 sec by 100.0 HP


Jeszcze mam problem z get_pcvar_num (pokazuje same zera :D)

    g_invisible_amount = register_cvar("zp_ghost_invisibility", "10")

public zp_user_infected_post(player, infector)
{
invisam = get_pcvar_num(g_invisible_amount)

if((zp_get_user_zombie_class(player) == g_zclass_ghost) && !zp_get_user_nemesis(player))
client_print(player, print_chat, "[ZP] Your invisibility is %f.", invisam)
}


[ZP] Your invisibility is 0.000000

Nie mam pojęcia co dać zamiast %f, jedynie z tym coś wyświetlało(liczby) I to dodatkowo nie float :/
Quote

  • +
  • -
DarkGL's Photo DarkGL 24.07.2010

czy zmienna invisam to float czy całkowita ?
jeśli float to zmień na samo new i daj %d
Quote

  • +
  • -
camilost's Photo camilost 24.07.2010

Invisam zwykła liczba nie float
        set_es(es_handle, ES_RenderAmt, get_pcvar_num(g_invisible_amount))
w innej części pluga :P

Pytanie do regeneracji:
Czemu tag mismatch jak daje tak:

public zp_user_infected_post(player, infector)
{
new Float:hl2del = get_pcvar_float(g_healing_delay)
new hl2amo = get_pcvar_float(g_healing_amount) // Tu mismatch
if ((zp_get_user_zombie_class(player) == g_zclass_healing) && !zp_get_user_nemesis(player))
{
client_print(player, print_chat, "[ZP] Your health is regenerated at %.1f sec by %d HP", hl2del, hl2amo)

}
return PLUGIN_CONTINUE
}

Zrobione tak jak napisałeś wyżej ;P
Edited by camilost, 24.07.2010 20:26.
Quote

  • +
  • -
DarkGL's Photo DarkGL 24.07.2010

get_pcvar_num(g_healing_amount) // Tu mismatch
Quote

  • +
  • -
camilost's Photo camilost 24.07.2010

get_pcvar_num(g_healing_amount) // Tu mismatch


omg:
new g_zclass_healing, g_healing_delay, g_healing_amount
new Float:g_heal_delay[33]

dałałem float bo myślałem przez cały dzień że g_healing_amount też było w floatku ^^ Mało spałem może temu :D I cały dzień się z tym męczyłem xD

Dobra:
Zombie Healthing

[ZP] Your health is regenerated at 6.0 sec by 100 HP


Zombie Ghost

[ZP] Your invisibility is 5.


Już wiem żeby większą uwagę zwracać na "new" : D

Więcej już sobie poradzę,dzięki i jak zawsze rep
Quote

Adminek AMXX.PL's Photo Adminek AMXX.PL 24.07.2010

Wiadomość wygenerowana automatycznie


Ten temat został zamknięty przez moderatora.

Powód: Pomoc udzielona

Jeśli się z tym nie zgadzasz, Dołączona grafika raportuj ten post, a moderator lub administrator rozpatrzy go ponownie.


Z pozdrowieniami,
Zespół AMXX.PL
Quote
Locked