Raised This Month: $51 Target: $400
 12% 

Solved [ H3LP ] func_button + takedamage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 12-07-2017 , 08:56   [ H3LP ] func_button + takedamage
Reply With Quote #1

Hello, I tried to create a button that could hurt. The code is working, but the button becomes unusable while its flag is not DAMAGE_NO. So basically, if I set DAMAGE_YES/DAMAGE_AIM, the button cannot be used anymore. How can I fix it?

Code:
new ammo_box = rg_create_entity("func_button", true)     //set_entvar(ammo_box, var_targetname, g_szAmmoBoxEnt)     set_entvar(ammo_box, var_solid, SOLID_BBOX)     set_entvar(ammo_box, var_movetype, MOVETYPE_TOSS)     set_entvar(ammo_box, var_origin, origin)     // If I set DAMAGE_YES/DAMAGE_AIM, the button can't be used anymore     set_entvar(ammo_box, var_takedamage, DAMAGE_NO)     set_entvar(ammo_box, var_health, get_pcvar_float(cvar_ammo_box_health))     entity_set_model(ammo_box, model_ammobox)     new Float:mins[3] = { -5.0, -5.0, -1.0 }     new Float:maxs[3] = { 5.0, 5.0, 6.0 }     entity_set_size(ammo_box, mins, maxs)

Last edited by CrazY.; 12-07-2017 at 16:18.
CrazY. is offline
killerZM
Senior Member
Join Date: Sep 2016
Old 12-07-2017 , 12:21   Re: [ H3LP ] func_button + takedamage
Reply With Quote #2

if i understand right you need button that when user touch the user get damaged or ......
killerZM is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 12-07-2017 , 12:43   Re: [ H3LP ] func_button + takedamage
Reply With Quote #3

No, basically, it's a box of ammo. The player presses +USE to get the ammo and the other team can destroy that box.

And the problem is: from the moment I enable the damage in this box, it is no longer possible to use the +USE to get the ammo, because the box passes to be like another entity and not func_button. I hope you understand.
CrazY. is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 12-07-2017 , 15:18   Re: [ H3LP ] func_button + takedamage
Reply With Quote #4

PHP Code:
    new ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"func_healthcharger"));
    
    if(!
ent) return;
    
    new 
Float:fOrigin[3], Float:fOrigin2[3], Float:fVelocity[3];
    
velocity_by_aim(id250fVelocity)
    
pev(idpev_originfOrigin)
    
pev(idpev_view_ofsfOrigin2)
    
xs_vec_add(fOriginfOrigin2fOrigin)
    
    
engfunc(EngFunc_SetOriginentfOrigin);
    
engfunc(EngFunc_SetModelentMEDKIT_W_MDL);
    
dllfunc(DLLFunc_Spawnent);
    
engfunc(EngFunc_SetSizeentFloat:{-5.0,-5.0,-5.0}, Float:{5.0,5.0,5.0});
    
set_pev(entpev_velocityfVelocity);
    
fVelocity[0] = 0.0fVelocity[2] = 0.0fVelocity[1] = !random(1) ? -360.0:360.0;
    
set_pev(entpev_avelocityfVelocity);
    
set_pev(entpev_friction1.4);
    
set_pev(entpev_globalnameg_medkit_name);
    
set_pev(entpev_ownerid);
    
set_pev(entpev_takedamage1.0);
    
set_pev(entpev_health100.0);
    
set_pev(entpev_dmg_take25.0)
    
set_pev(entpev_solidSOLID_BBOX);
    
set_pev(entpev_movetypeMOVETYPE_BOUNCE); 
my code for destructable medkit.. take a look..
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
E1_531G
Senior Member
Join Date: Dec 2017
Old 12-07-2017 , 15:27   Re: [ H3LP ] func_button + takedamage
Reply With Quote #5

You can try to do this:
- make an invisible func_breakable around your button.
- set health to func_breakable.
- when func_breakable get broken disable button.
E1_531G is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 12-07-2017 , 16:17   Re: [ H3LP ] func_button + takedamage
Reply With Quote #6

Solved.

Quote:
Originally Posted by PRoSToTeM@ View Post
Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <hamsandwich>

public plugin_init() {
	register_clcmd("say /createEnt", "OnClientCmdSayCreateEntReceive");
	
	RegisterHam(Ham_Use, "info_target", "MyClass_Used", .Post = true);
	RegisterHam(Ham_ObjectCaps, "info_target", "MyClass_GettingObjectCaps", .Post = false);
}

public MyClass_Used(entity, user) {
	new classname[32];
	pev(entity, pev_classname, classname, charsmax(classname));
	if (!equal(classname, "MyClass")) {
		return;
	}
	
	if (is_user_alive(user)) {
		client_print(user, print_chat, "You used MyClass entity");
	}
}

public MyClass_GettingObjectCaps(entity) {
	new classname[32];
	pev(entity, pev_classname, classname, charsmax(classname));
	if (!equal(classname, "MyClass")) {
		return HAM_IGNORED;
	}
	
	SetHamReturnInteger(FCAP_IMPULSE_USE);
	return HAM_OVERRIDE;
}

public OnClientCmdSayCreateEntReceive(player) {
	new entity = create_entity("info_target");
	set_pev(entity, pev_classname, "MyClass");
	new Float:origin[3];
	pev(player, pev_origin, origin);
	origin[0] += 40.0;
	entity_set_origin(entity, origin);
	entity_set_model(entity, "models/player.mdl");
	set_pev(entity, pev_solid, SOLID_BBOX);
	entity_set_size(entity, Float:{-16.0, -16.0, -36.0}, Float:{16.0, 16.0, 36.0});
}
https://forums.alliedmods.net/showthread.php?p=2475643
CrazY. is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:16.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode