AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   A few questions (https://forums.alliedmods.net/showthread.php?t=62905)

Stars 11-07-2007 02:30

A few questions
 
Alright, so this is my first ever Pawn program.... so dont laugh.

I need some help.

How do i increase/decease a players health by 1?
How do i make a small blood splurt?

Other than that, is this right so far?





#include <amxmodx>
#include <amxmisc> //This contains some useful functions
#include <fun> //This contains the function to change health

new PLUGIN[]="Bleed/Heal Mod"
new AUTHOR[]="Stars"
new VERSION[]="0.01"



public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
register_event("Damage", "hook_Damage", "be", "2>0");
}

public hook_Damage(id)
{
new damage = read_data(2);
new name[32];

get_user_name(id, name, 31);

new health = pev(id, pev_health);
new dam_mult = 3;
new time;



if (damage > 75)
{
dam_mult = 2;
}

else if (damage < 25)
{
dam_mult = 4;
}




if ((50-health)>0)
{
time = (3*(50-health))

while (time > 0)
{
set_task(1.0, func_dam(time, dam_mult, health));
time--;
}
}

else
{
time = (2*(50-(100-health));
while (time > 0)
{
set_task(1.0, func_heal(time, dam_mult, health));
time--;
}
}





func_heal(time, dam_mult, health)
{
if (time%dam_mult == 0)
{
*****HEALTH +1******
}
}



func_dam(time, dam_mult, health)
{
if (time%dam_mult == 0)
{
*****HEALTH -1******
*****BLOOD SPLURT******
}
}

return PLUGIN_HANDLED
}

Drak 11-07-2007 22:39

Re: A few questions
 
Well to give a player "1+ Health" would look similar to this:
Code:
new health = get_user_health(id); set_user_health(id,health+1);
Taking away the health should be obvious "set_user_health(id,health-1);"
NOTE: You can also do:
Code:
set_user_health(id,get_user_health(id)+1)
But if you're calling "set_user_health()" more then once, it's better the other way.
As for the blood 'splurts' that would mostlikely be accomplished by user messages. (Search for it)

Also, you have "functions in functions" You can't do this in Pawn/Small. So, i quickly went over the code abit, and commented it.
Code:
#include <amxmodx> #include <amxmisc> //This contains some useful functions #include <fun> //This contains the function to change health new PLUGIN[]="Bleed/Heal Mod" new AUTHOR[]="Stars" new VERSION[]="0.01" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR);     register_event("Damage", "hook_Damage", "be", "2>0"); } public hook_Damage(id) {     new damage = read_data(2);     new name[32];         get_user_name(id, name, 31);     //new health = pev(id, pev_health); // This is a Fakemeta native (You can use fun/engine modules to get this)     new health = get_user_health(id)     new dam_mult = 3;     //new time; // Time is a function/native, so your variable cannot be named this.     new szTime         if(damage > 75)         dam_mult = 2;     else if(damage < 25)         dam_mult = 4;             // I couldn't really make sence of that was below here.. S     if(50-health > 0 )     {     }     else     {     }     return PLUGIN_HANDLED } func_heal(id,szTime,dam_mult,health) {     if(szTime % dam_mult == 0)     {         // Heath + 1     } } func_dam(id,szTime,dam_mult,health) {     if(szTime % dam_mult == 0)     {         // Health         // Blood  Splurt     } }
I don't think that helps much.. but yeah..

Stars 11-07-2007 23:45

Re: A few questions
 
Thanks for clearing a few little things up :) ill fix it up a bit today, then demand more help :D!


All times are GMT -4. The time now is 01:17.

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