←  Pytania

AMXX.pl: Support AMX Mod X i SourceMod

»

Zmiana damage deagla / kontynuacja

  • +
  • -
Filip1512 - zdjęcie Filip1512 20.09.2012

Cześć,
nawiązując do tego tematu ( http://amxx.pl/topic...-damage-deagla/ ), chciałbym się dowiedzieć, jak zrobić, żeby ta zmiana dmg działała tylko podczas rozgrzewki?

Zrobiłem tak:

stworzyłem zmienną

new bool:dgldmg;


Następnie w public TakeDamage zrobiłem tak:

public TakeDamage(this, idinflictor, idattacker, Float:damage, damagebits, id){
if(dgldmg == true){

if ((!is_user_alive(idattacker) || !is_user_alive(this)) && idattacker != this) return HAM_IGNORED;

new weapon = get_user_weapon(idattacker);

if(weapon == CSW_DEAGLE)
damage *= 100; // ile razy ma mnozyc

SetHamParamFloat(4, damage);

return HAM_HANDLED;
}
}


Oraz w public Restart tak:

public restart()
{
//unpausing plugins
server_cmd("amx_pausecfg enable lokalizator.amxx");
g_is_warmup = false;
dgldmg = false;
remove_task(4567);
remove_task(2345);

server_cmd("sv_restart 1");
new Players[32], playerCount;
get_players(Players, playerCount);
for (new i=0; i<playerCount; i++)
{
new id = Players[i];
if(cs_get_user_bpammo(id, CSW_HEGRENADE))
cs_set_user_bpammo(id, CSW_HEGRENADE, 0);
}
}



Jest to plugin Ultimate WarmUp, tylko, że trochę zaedytowany. Po tym jak to zrobiłem wyskakuje mi błąd:

Warning: Function "TakeDamage" should return a value on line 146


Co to oznacza?
I jeszcze pytanie ze starego tematu - do czego służy #pragma ?
Użytkownik `NN edytował ten post 20.09.2012 14:51
Odpowiedz

  • +
  • -
K!113r - zdjęcie K!113r 20.09.2012

Jeżeli w if'ie coś zwracasz to bez if'a też.
Dodaj za if'em return HAM_HANDLED
Odpowiedz

  • +
  • -
Filip1512 - zdjęcie Filip1512 20.09.2012

Ok działa, a co to jest ta cała #pragma ?

benio, liczę na to, że tutaj zajrzysz.
Użytkownik `NN edytował ten post 20.09.2012 15:59
Odpowiedz

  • +
  • -
K!113r - zdjęcie K!113r 20.09.2012

Ajj, pisałem na szybko i myślałem co innego, napisałem co innego, powinno być return HAM_IGNORED

mały cytat z wiki o dyrektywach preprocesora

Zapobiega ona ponownemu załączeniu treści całego pliku, w którym została użyta. Metoda ta jednak nie ma oparcia w oficjalnym standardzie. Podobnie, jak wszystkie użycia dyrektywy #pragma, jej ewentualna obsługa jest rozszerzeniem wprowadzonym przez dany kompilator i nie jest przenośna pomiędzy różnymi narzędziami.


Użytkownik K!113r edytował ten post 20.09.2012 16:34
Odpowiedz

  • +
  • -
Filip1512 - zdjęcie Filip1512 20.09.2012

Ale odziwo return HAM_HANDLED; też działa :P
A można podać jakiś przykład co do pragmy? Bo z tej definicji jednak mało rozumiem...
Odpowiedz

  • +
  • -
K!113r - zdjęcie K!113r 20.09.2012

Spotkałem się z nią tylko w bibliotekach (pliki .inc)

#if defined _engine_included
#endinput
#endif
#define _engine_included

#include <engine_const>

#if AMXX_VERSION_NUM >= 175
#pragma reqlib engine
#if !defined AMXMODX_NOAUTOLOAD
#pragma loadlib engine
#endif
#else
#pragma library engine
#endif


może to Ci coś pomoże http://amxx.pl/topic/20034-natywy/
Odpowiedz

  • +
  • -
Filip1512 - zdjęcie Filip1512 20.09.2012

Już bardziej, ale z tego co widzę, to nie przyda mi się to. bo spotkałem się z pragmą tylko 1 raz i to tylko w 1 pluginie ;P Dzięki, do zamknięcia
Odpowiedz

Gość_21977_* 16.10.2012

if ((!is_user_alive(idattacker) || !is_user_alive(this)) && idattacker != this) return HAM_IGNORED;
zmień na
if (g_is_warmup && ((!is_user_alive(idattacker) || !is_user_alive(this)) && idattacker != this)) return HAM_IGNORED;


pragma to informacja dla parsera, która pozwala sprecyzować dodatkowe ustawienia, manual:

[quote]#pragma extra information
A “pragma” is a hook for a parser to specify additional settings,
such as warning levels or extra capabilities. Common #pragmas are:
#pragma align
Aligns the next declaration to the offset set with the alignment
compiler option. Some (native) functions may perform
better with parameters that are passed by reference when
these are on boundaries of 8, 16, or even 32 bytes. Alignment
requirements are dependent of the host applications.
Putting the #pragma align line in front of a declaration
of a global or a static variable aligns this variable to the
boundary set with the compiler option. This #pragma aligns
only the variable that immediately follows the #pragma. The
alignment of subsequent variables depends on the size and
alignment of the variables that precede it. For example,
if a global array variable of 2 cells is aligned on a 16-byte
boundary and a cell is 4 bytes, the next global variable is
located 8 bytes further.
Putting the #pragma align line in front of a declaration of
a function will align the stack frame of that function to the
boundary specified earlier, with the result that the first local,
non-“static”, variable is aligned to that boundary. The
alignment of subsequent variables depends on the size and
alignment of the variables that precede it. In practice, to
align a local non-static variable, you must align the function’s
stack frame and declare that variable before any other
variables.
#pragma amxlimit value
Sets the maximum size, in bytes, that the compiled script
may grow to. This pragma is useful for (embedded) environments
where the maximum size of a script is bound to a
hard upper limit.
If there is no setting for the amount of RAM for the data
and stack (see the pragma amxram), this refers to the total
memory requirements; if the amount of RAM is explicitly
set, this value only gives the amount of memory needed for
the code and the static data.
Directives
Odpowiedz