Raised This Month: $ Target: $400
 0% 

Coding Help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Stars
Junior Member
Join Date: Nov 2007
Old 11-06-2007 , 21:59   Coding Help
Reply With Quote #1

Okay, basically what i want to do, is make a plugin that runs when you take any damage.

What happens is... based on the damage taken, and your health after the damage, you will bleed for a certain time, or heal for a certain time...

Its quite simple, and Pawn is very easy to understand... im just having a lot of trouble linking in the HL commands.... such as:
-Starting a function when damage is taken
-Pauses in code (wait 1 second)
-Knowing Damage taken
-Knowing current hp
-and so on

(I first decided to look into AMX Mod X Scripting yesterday, so be nice)

I designed it below in Java, to help.







int HP;
int time;
int damage_taken;

public Bleed_Heal(int HP, damage_taken)
{
int dam_mult;

if (damage_taken > 75)
dam_mult = 2;

else if (damage_taken < 25)
dam_mult = 4;

else
dam_mult = 3;
if (50-HP > 0 )
{
time = (3(50-HP))

while (time > 0)
{
if (time%dam_mult == 0)
{
HP--;
}
wait 1 second;
time--;
}
}

else
{
time = (3(50-(100-HP)))
while (time > 0)
{
if (time%dam_mult == 0)
{
HP++;
}
wait 1 second;
time--;
}
}
}
Stars is offline
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 11-06-2007 , 22:20   Re: Coding Help
Reply With Quote #2

Quote:
Originally Posted by Stars View Post
-Starting a function when damage is taken
register_event("Damage", "hook_Damage", "be", "2>0");

Quote:
Originally Posted by Stars View Post
-Knowing Damage taken
The 2nd argument of the damage message you are hooking above.

Quote:
Originally Posted by Stars View Post
-Pauses in code (wait 1 second)
set_task(1.0, "function_to_start");

Quote:
Originally Posted by Stars View Post
-Knowing current hp
new health = pev(id, pev_health);
hlstriker is offline
Stars
Junior Member
Join Date: Nov 2007
Old 11-06-2007 , 23:02   Re: Coding Help
Reply With Quote #3

Thankyou, but im still confused...

How do i implement this?
register_event("Damage", "hook_Damage", "be", "2>0");
Stars is offline
Stars
Junior Member
Join Date: Nov 2007
Old 11-07-2007 , 02:21   Re: Coding Help
Reply With Quote #4

set_task(1.0, "function_to_start");


Does this literally just pause for one second?

Or does it go back to the start of the function in 1 second?
Stars is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-07-2007 , 00:12   Re: Coding Help
Reply With Quote #5

Insert in plugin_init() function.
__________________
Arkshine is offline
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 11-07-2007 , 00:13   Re: Coding Help
Reply With Quote #6

This is not tested but I'm pretty sure it should work.

PHP Code:
public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_event("Damage""hook_Damage""be""2>0");
}

public 
hook_Damage(id)
{
    new 
damage read_data(2);
    new 
name[32];
    
    
get_user_name(idname31);
    
client_print(0print_chat"%s took %i damage."namedamage);

hlstriker is offline
Stars
Junior Member
Join Date: Nov 2007
Old 11-07-2007 , 02:01   Re: Coding Help
Reply With Quote #7

how would i make someone squirt out a little bit of blood.
Stars is offline
Stars
Junior Member
Join Date: Nov 2007
Old 11-07-2007 , 02:04   Re: Coding Help
Reply With Quote #8

moreso just drip blood to the ground below them, rather than squirt.
Stars is offline
Stars
Junior Member
Join Date: Nov 2007
Old 11-07-2007 , 02:08   Re: Coding Help
Reply With Quote #9

Quote:
Originally Posted by hlstriker View Post
This is not tested but I'm pretty sure it should work.

PHP Code:
public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_event("Damage""hook_Damage""be""2>0");
}

public 
hook_Damage(id)
{
    new 
damage read_data(2);
    new 
name[32];
    
    
get_user_name(idname31);
    
client_print(0print_chat"%s took %i damage."namedamage);


PS, thanks that was really useful.
Stars is offline
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 11-07-2007 , 05:30   Re: Coding Help
Reply With Quote #10

It will go to that function in 1 second

Pausing wouldn't be too useful in embedded code
purple_pixie 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 01:16.


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