Raised This Month: $ Target: $400
 0% 

How to detect


Post New Thread Reply   
 
Thread Tools Display Modes
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 06-22-2010 , 16:19   Re: How to detect
Reply With Quote #21

Oh well, just opened again my server that was unused a very long time, and guess what? The plugin works fine... -.-
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
zombieplague
Veteran Member
Join Date: Apr 2009
Old 06-24-2010 , 09:29   Re: How to detect
Reply With Quote #22

Quote:
Originally Posted by Alka View Post
Oh well, just opened again my server that was unused a very long time, and guess what? The plugin works fine... -.-
My mistake, but, can you fix the the max heath ?

Yea, it stopped at 200+ but, can make it stop it 200 instead of 200 + ??
zombieplague is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 06-24-2010 , 10:57   Re: How to detect
Reply With Quote #23

Ok. Code updated, take a look...
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
Old 06-24-2010, 11:11
Hawk552
This message has been deleted by Hawk552.
Old 06-24-2010, 11:24
abdul-rehman
This message has been deleted by Hawk552.
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 06-24-2010 , 16:37   Re: How to detect
Reply With Quote #24

Maye this can help

PHP Code:
#include <amxmodx>
#include <engine>
#include <hamsandwich>

#define DELAY   3.0
#define MAXHEALTH       100.0

new Float:g_origin[33][3]
new 
Float:g_nextheal[33]

public 
plugin_init()
{
        
RegisterHam(Ham_TakeDamage"player""ham_TakeDamagePost"1)
}

public 
ham_TakeDamagePost(victiminflictorattackerFloat:damagedamagebits)
{
        if(
is_user_alive(victim))
        {
                
g_nextheal[victim] = halflife_time() + DELAY
                entity_get_vector
(victimEV_VEC_origing_origin[victim])
        }
}

public 
client_PreThink(id)
{
        new 
Float:health
        health 
entity_get_float(idEV_FL_health)
        if(
is_user_alive(id) && (health MAXHEALTH) && (halflife_time() > g_nextheal[id]))
        {
                new 
Float:origin[3]
                
entity_get_vector(idEV_VEC_originorigin)
                if(
origin[0] != g_origin[id][0] || origin[1] != g_origin[id][1] || origin[2] != g_origin[id][2])
                {
                        
g_nextheal[id] = halflife_time() + DELAY
                        entity_get_vector
(idEV_VEC_origing_origin[id])
                }
                else
                {
                        
server_print("Heal the man!!!");
                }
        }

__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
5c0r-|3i0
Veteran Member
Join Date: Nov 2008
Location: Việt Nam
Old 06-24-2010 , 19:57   Re: How to detect
Reply With Quote #25

@zombieplague: Show your code zombieplague .And we'll try to look at it !
@joropito:
PHP Code:
stock bool:CheckMovement(id)    // xero's :)
{
    if(
get_user_button(id)&(IN_JUMP|IN_FORWARD|IN_BACK|IN_MOVELEFT|IN_MOVERIGHT))
        return 
true
    
return false

To check player's movement , there are lots of methods , I think..
1) Check player speed ?
2) Check if player press any button involve to movement ?
3) Check user origin is the same with the previous origin ??
....
I wonder if there is a good way for this, >"<
__________________

Last edited by 5c0r-|3i0; 06-24-2010 at 20:02.
5c0r-|3i0 is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 06-25-2010 , 07:31   Re: How to detect
Reply With Quote #26

Quote:
Originally Posted by Hawk552 View Post
stop. using. static. for. everything.
Eh? do you like s?

I prefer mine anyway
__________________
Still...lovin' . Connor noob! Hello

Last edited by Alka; 06-25-2010 at 07:35.
Alka is offline
Old 06-25-2010, 09:14
Hawk552
This message has been deleted by Hawk552.
Old 06-25-2010, 09:21
joropito
This message has been deleted by Hawk552.
Old 06-25-2010, 09:24
Hawk552
This message has been deleted by Hawk552.
Old 06-25-2010, 11:48
Alka
This message has been deleted by Hawk552.
Old 06-25-2010, 12:06
Hawk552
This message has been deleted by Hawk552.
Old 06-25-2010, 12:32
Alka
This message has been deleted by Hawk552.
Old 06-25-2010, 12:34
Hawk552
This message has been deleted by Hawk552.
Old 06-25-2010, 12:42
Alka
This message has been deleted by Hawk552.
Old 06-25-2010, 12:49
Hawk552
This message has been deleted by Hawk552.
Old 06-25-2010, 12:51
Alka
This message has been deleted by Hawk552.
Old 06-25-2010, 14:16
zombieplague
This message has been deleted by Hawk552.
Old 06-25-2010, 14:22
Alka
This message has been deleted by Hawk552.
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 06-25-2010 , 14:44   Re: How to detect
Reply With Quote #27

Quote:
Originally Posted by Alka View Post
I see useful only the posts about my code that you made above, others are useless talk.

EDIT:After reading all your comments, just to feel better i rewrited the mess (err... plugin), let's see now.
This is still completely wrong...

I laid out exactly how to do it, too. Well, here's my implementation:

PHP Code:
#include <amxmodx>
#include <engine>
#include <xs>

#define PLUGIN "Health Regen"
#define VERSION "1.0"
#define AUTHOR "Alka"

#define HEAL_WAIT_TIME 3.0
#define HEAL_AMOUNT 10.0
#define MAX_HEAL 200.0

new g_iMaxPlayers;

new 
Float:g_vOldOrigin[33][3];

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
g_iMaxPlayers get_maxplayers();
    
    
set_task(HEAL_WAIT_TIME"task_CheckHeal", .flags="b");
}

public 
task_CheckHeal()
{
    for(new 
id id <= g_iMaxPlayers id++)
    {
        if(!
is_user_alive(id))
        {
            continue;
        }
        
        new 
Float:vOrigin[3];
        
entity_get_vector(idEV_VEC_originvOrigin);
        
        if(
xs_vec_equal(vOriging_vOldOrigin[id]))
        {            
            new 
Float:fHealth entity_get_float(idEV_FL_health);
            
            if(
fHealth MAX_HEAL)
            {
                
//fHealth = floatmin(fHealth + HEAL_AMOUNT, MAX_HEAL);
                // Following expression has better performance, but not as consistent.
                // In general, it would be better to compare before
                // setting, but the case where this happens is relatively
                // infrequent compared to the player's health being
                // either lower ten units lower or right on the max heal.
                
if ( ( fHealth += HEAL_AMOUNT ) > MAX_HEAL )
                    
fHealth MAX_HEAL

                entity_set_float
(idEV_FL_healthfHealth);
                
                
set_hudmessage(02550, -1.00.906.01.0, .channel=1);
                
show_hudmessage(id"Regeneration in progress...");
            }
        }
        
xs_vec_copy(vOriging_vOldOrigin[id]);
    }

Again: fast, robust, effective. Another tip: stop using HN. Also, you should probably use fun for the health setting stuff. I only objected to your use of fakemeta over engine, not to your use of both fakemeta and fun.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 06-25-2010 , 14:59   Re: How to detect
Reply With Quote #28

Ah, i see, just 2 things. He wanted to start the heal after 3 seconds since when he stopped. And what means HN :-)
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 06-25-2010 , 15:07   Re: How to detect
Reply With Quote #29

Quote:
Originally Posted by Alka View Post
Ah, i see, just 2 things. He wanted to start the heal after 3 seconds since when he stopped.
Yeah, it'll do that.

Quote:
Originally Posted by Alka View Post
And what means HN :-)
Hungarian Notation. It's when you include tags in variable names, such as g_fLastTime as opposed to g_LastTime (although the g_ tag is also HN, it's somewhat useful).
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 06-25-2010 , 15:14   Re: How to detect
Reply With Quote #30

Ah yea, i like to keep the track of variables type, i just don't like random names in plugin "health, VectorLength, last_time", anyway that depends on user coding style and anyone can understand it as long as it has a descriptive name, no matter of prefixes/tags.
__________________
Still...lovin' . Connor noob! Hello
Alka 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 19:53.


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