←  Pluginy

AMXX.pl: Support AMX Mod X i SourceMod

»

Modyfikacja
Drobna przeróbka pluginu HP za zabicie

  • +
  • -
maaciek_ - zdjęcie maaciek_ 31.10.2011

Witajcie,

Ogólną wiedzę na temat PAWN i ANSI C mam, ale jakoś mi nie wychodzi ;) Mianowicie, mam plugin, którego kod przedstawiam poniżej:

#include <amxmodx>
#include <fun>
#define ADMIN_FLAG_X (1<<23)
new const VERSION[] = "0.1"
public plugin_init() {
register_plugin("HP za Zabicie", VERSION, "Muzzi");
register_event("DeathMsg", "DeathMsg", "a")
}
public DeathMsg()
{
new kid = read_data(1) //zabojca
new vid = read_data(2);
new hs = read_data(3) // HeadShot (1 == true)

if(is_user_alive(kid) && is_user_connected(vid) && get_user_team(kid) != get_user_team(vid))
{
new health = get_user_health(kid), dodaj = hs ? 20 : 15, limit = 100;
set_user_health(kid, health+dodaj > limit ? limit : health+dodaj);
Display_Fade(kid,2600,2600,0,0,255,0,15)
}
}
stock Display_Fade(id,duration,holdtime,fadetype,red,green,blue,alpha)
{
message_begin( MSG_ONE, get_user_msgid("ScreenFade"),{0,0,0},id )
write_short( duration ) // Duration of fadeout
write_short( holdtime ) // Hold time of color
write_short( fadetype ) // Fade type
write_byte ( red ) // Red
write_byte ( green ) // Green
write_byte ( blue ) // Blue
write_byte ( alpha ) // Alpha
message_end()
}



Plugin ten powoduje dodanie HP graczowi, który zabił. Chcę jednak, by działał tylko na fladze "x". Wiem, co trzeba zrobić, by dodać taką zależność, ale niekoniecznie mi chce to działać. Proszę więc Was o wstawienie tych kilku linijek do kodu (jak widać deklaracja flagi "x" jest już wklejona).


Pozdrawiam
Odpowiedz

  • +
  • -
pixel - zdjęcie pixel 31.10.2011




#include <amxmodx>

#include <fun>

#define ADMIN_FLAG_X (1<<23)

new const VERSION[] = "0.1"

public plugin_init() {

    register_plugin("HP za Zabicie", VERSION, "Muzzi");

    register_event("DeathMsg", "DeathMsg", "a")

}

public DeathMsg()

{

            new kid = read_data(1)  //zabojca

            new vid = read_data(2);

            new hs = read_data(3)   // HeadShot (1 == true)



            if (is_user_alive(kid) && (get_user_flags(vid) & ADMIN_LEVEL_H) &&  is_user_connected(vid) && get_user_team(kid) != get_user_team(vid))

            {

                            new health = get_user_health(kid), dodaj = hs ? 20 : 15, limit = 100;

                            set_user_health(kid, health+dodaj > limit ? limit : health+dodaj);

                            Display_Fade(kid,2600,2600,0,0,255,0,15)

            }

}

stock Display_Fade(id,duration,holdtime,fadetype,red,green,blue,alpha)

{

    message_begin( MSG_ONE, get_user_msgid("ScreenFade"),{0,0,0},id )

    write_short( duration )    // Duration of fadeout

    write_short( holdtime )    // Hold time of color

    write_short( fadetype )    // Fade type

    write_byte ( red )      // Red

    write_byte ( green )            // Green

    write_byte ( blue )     // Blue

    write_byte ( alpha )    // Alpha

    message_end()

}

Odpowiedz