←  Multilingual

AMXX.pl: Support AMX Mod X i SourceMod

»

Can you help me with this ?

  • +
  • -
MasamuneDate - zdjęcie MasamuneDate 21.04.2020

Hey, i just want to ask something from this code.

 

So basicly, the thing i want is, when you headshot people, you instantly recover 50 HP, and those HP can accumulate regardless of your max health. So let say, you have 100 max health, but you managa to headshot somebody 5 times without a miss and without being hit. So that put your hp into 100 + 250 -> so you will have 350 HP

 

I Compiled everything fine, but when i headshot people, my HP doesnt recover. Anyone can help ?

Odpowiedz

  • +
  • -
MasamuneDate - zdjęcie MasamuneDate 21.04.2020

I forgot to attach the file

Załączone pliki

Odpowiedz

  • +
  • -
MasamuneDate - zdjęcie MasamuneDate 22.04.2020

 

its not HP / killing, but HP for each shots.

 

EDIT : ok i see the error on my health recovery. Aside that, does my code for headshot already correct ?


Użytkownik MasamuneDate edytował ten post 22.04.2020 07:59
Odpowiedz

  • +
  • -
dasiek - zdjęcie dasiek 22.04.2020


 I havent written any class or plugin for amxx for a long time, but I have few comments -  have a Where you find the code to detect headshot?  I think you can move logic from `func_TraceAttack` to `TakeDamage`, just like that:
 

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fun>
#include <fakemeta>
#include <codmod>
#include <colorchat>
#include <hamsandwich>

#define PLUGIN 		"Black Ops Commander"
#define VERSION 	"1.0"
#define AUTHOR 		"MasamuneDate"

new const nazwa[]   = "Black Ops Commander";
new const opis[]    = "Restore 30 HP for each headshot";
new const bronie    = 1<<CSW_TMP | 1<<CSW_G3SG1 | 1<<CSW_FIVESEVEN ;
new const zdrowie   = 25;
new const kondycja  = 10;
new const inteligencja = 0;
new const wytrzymalosc = 0;

new bool:ma_klase[33];
new hitbox[33];

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR);
	cod_register_class(nazwa, opis, bronie, zdrowie, kondycja, inteligencja, wytrzymalosc);
	RegisterHam(Ham_TakeDamage, "player", "TakeDamage");
}

public cod_class_enabled(id)
{
	ColorChat(id, GREEN, "Created by MasamuneDate",  nazwa);
	ma_klase[id] = true;
}

public cod_class_disabled(id)
{	
	ma_klase[id] = false;
}

public TakeDamage(id, idattacker, Float:damage, Float:direction[3], traceresult, damagebits)
{
	
	if(!is_user_connected(idattacker)) {
		return HAM_IGNORED; 
	}
	
	if(!ma_klase[idattacker]) {
		return HAM_IGNORED; 
	}
		
	new hitbox = get_tr2(traceresult, TR_iHitgroup);

	if(hitbox == HIT_HEAD)
	{
		new cur_health = get_user_health(idattacker);
		new max_health = 100+cod_get_user_health(idattacker);

		new new_health = cur_health+50;
		if(new_health > max_health) {
			new_health = max_health;
		}
		set_user_health(idattacker, new_health);
	}
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1041\\ f0\\ fs16 \n\\ par }
*/

Odpowiedz

  • +
  • -
MasamuneDate - zdjęcie MasamuneDate 22.04.2020

 

 I havent written any class or plugin for amxx for a long time, but I have few comments - have a Where you find the code to detect headshot? I think you can move logic from `func_TraceAttack` to` TakeDamage`, just like that:
 

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fun>
#include <fakemeta>
#include <codmod>
#include <colorchat>
#include <hamsandwich>

#define PLUGIN "Black Ops Commander"
#define VERSION "1.0"
#define AUTHOR "MasamuneDate"

new const name [] = "Black Ops Commander";
new const description [] = "Restore 30 HP for each headshot";
new const weapons = 1 << CSW_TMP | 1 << CSW_G3SG1 | 1 << CSW_FIVESEVEN;
new const health = 25;
new const condition = 10;
new const intelligence = 0;
new const strength = 0;

new bool: ma_klase [33];
new hitbox [33];

public plugin_init ()
{
	register_plugin (PLUGIN, VERSION, AUTHOR);
	cod_register_class (name, description, weapons, health, condition, intelligence, endurance);
	RegisterHam (Ham_TakeDamage, "player", "TakeDamage");
}

public cod_class_enabled (id)
{
	ColorChat (id, GREEN, "Created by MasamuneDate", name);
	ma_klase [id] = true;
}

public cod_class_disabled (id)
{	
	ma_klase [id] = false;
}

public TakeDamage (id, idattacker, Float: damage, Float: direction [3], traceresult, damagebits)
{
	
	if (! is_user_connected (idattacker)) {
		return HAM_IGNORED; 
	}
	
	if (! ma_klase [idattacker]) {
		return HAM_IGNORED; 
	}
		
	new hitbox = get_tr2 (traceresult, TR_iHitgroup);

	if (hitbox == HIT_HEAD)
	{
		new cur_health = get_user_health (idattacker);
		new max_health = 100 + cod_get_user_health (idattacker);

		new new_health = cur_health + 50;
		if (new_health> max_health) {
			new_health = max_health;
		}
		set_user_health (idattacker, new_health);
	}
}
/ * AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
* {\\ rtf1 \\ ansi \\ deff0 {\\ fonttbl {\\ f0 \\ fnil Tahoma;}} \ n \\ viewkind4 \\ uc1 \\ pard \\ lang1041 \\ f0 \\ fs16 \ n \\ par}
* /

to be honest i dont know either. I look at some plugins on alliedmodder, and try to do it myself. Because, i really dont have a basic skill, i just try to learn it by practicing, and understanding them as best as i could.
 

Note 1: I think my code for heal is alright(?) i really dont know, cause the base heal code i got from killing enemy, now i try to change it to when it doesnt kill
Note 2: Im still confused about the headshot code, because this is the first time i try it after looking at serveral similiar code on alliedmodder forum.

Odpowiedz

  • +
  • -
MasamuneDate - zdjęcie MasamuneDate 01.05.2020

up

Odpowiedz