Raised This Month: $ Target: $400
 0% 

Get player touch with different player on death


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 04-15-2013 , 13:50   Re: Get player touch with different player on death
Reply With Quote #1

Thaks you very much guys, but it's not all.
The issue is more complex =) How to get the duration of touch with last entity (player)?
FromTheFuture is offline
didoWEE
Senior Member
Join Date: Oct 2012
Location: Bulgaria
Old 04-15-2013 , 14:41   Re: Get player touch with different player on death
Reply With Quote #2

Try this way, again not tested !
PHP Code:
#include <amxmodx>
#include <engine>
#include <cstrike>
#include <hamsandwich>

new const FRAMES 2;
// maybe the frames must be more

new bool:g_bTouched[33];
new 
g_Frames[33];

public 
plugin_init()
{
    
RegisterHam(Ham_Player_PreThink"player""HookThink"1);
    
RegisterHam(Ham_Killed"player""HookKill"1);
    
register_touch("player""player""HookTouch");
}

public 
client_authorised(id)
{
    
g_bTouched[id] = false;
    
g_Frames[id] = 0;
}

public 
HookTouch(touchedtoucher)
{
    if(
cs_get_user_team(touched) == cs_get_user_team(toucher))
    {
        
g_Frames[touched] = FRAMES;
        
g_bTouched[touched] = true;
    }
}
    
public 
HookThink(id)
{
    if(
g_bTouched[id])
    {
        
g_Frames[id]--;
        if(!
g_Frames[id]) g_bTouched[id] = false;
    }
}

public 
HookKill(victimkiller)
{
    if(
g_bTouched[victim])
    {
        
// do sth if teammates are touched together
    
}
    else
    {
        
// do sth if teammates are not touched together
    
}

didoWEE is offline
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 04-15-2013 , 15:13   Re: Get player touch with different player on death
Reply With Quote #3

Quote:
Originally Posted by didoWEE View Post
Try this way, again not tested !
Thank you again (: I want to choose better method, my method you can see below.
I want to make the punishment the player, who break me track when i'm was under fire (:

Look.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>

#define PLUGIN "Breakers Punishment"
#define VERSION "1.0"
#define AUTHOR "FromTheFuture"

#define TIME_AFTER_TOUCH 0.1
#define PUNISH_FPS 50

#define ID_PLAYER 0
#define FPS 1

new Floatg_fTouchedTime[33];
new 
g_iTouchedID[33][2], g_iTeam[33];

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_touch("player""player""SaveToucher")
    
register_event("Damage""Event_Damage""b""2!0""3=0""4!0")
    
register_event("TeamInfo""JoinTeam""a")
}

public 
SaveToucher(idPlayer)
{
    if(
g_iTeam[id] == g_iTeam[Player])
    {
        if(
g_iTouchedID[id][ID_PLAYER] != Player)
        
g_iTouchedID[id][FPS] = 0;
        
        
g_iTouchedID[id][ID_PLAYER] = Player;
        
g_iTouchedID[id][FPS]++;
        
g_fTouchedTime[id] = get_gametime();
    }
}

public 
Event_Damage(id)
{
    static 
Float:fTimefTime get_gametime();
    
    if(
fTime g_fTouchedTime[id] <= TIME_AFTER_TOUCH)
    {
        if(
task_exists(id)) 
        return 
PLUGIN_CONTINUE;
        
        if(
g_iTouchedID[id][FPS] < PUNISH_FPS)
        return 
PLUGIN_CONTINUE;
        
        
set_task(3.0"ClearFloodBlock"id// task for block chat flood about breaks
        
new szName[32], szNameBreaker[32];
        
get_user_name(idszName31);
        
get_user_name(g_iTouchedID[id][ID_PLAYER], szNameBreaker31);
        
client_print(0print_chat"Player %s break %s"szNameBreakerszName);
        
log(fTimeszNameszNameBreaker); // now only logs, after will be punish.
    
}
    
    return 
PLUGIN_CONTINUE;
}

public 
JoinTeam()
{
    new 
idszTeam[2]

    
id read_data(1)
    
read_data(2szTeam1)

    switch(
szTeam[0])
    {
        case 
'T'g_iTeam[id] = 1
        
case 'C'g_iTeam[id] = 2
        
default:  g_iTeam[id] = 3
    
}

    return 
PLUGIN_CONTINUE
}

public 
ClearFloodBlock(id) {}

public 
client_disconnect(id)
{
    
g_iTeam[id] = 0
}

log(FloatfTimeszName[], szNameBreaker[])
{
    new 
text[128];
    
formatex(text127"%0.2f %s break %s"fTimeszNameBreakerszName);
    
write_file("addons/amxmodx/breaks.log"text, -1);

How this can be optimized and can be more correctly?

Last edited by FromTheFuture; 04-15-2013 at 15:17.
FromTheFuture is offline
didoWEE
Senior Member
Join Date: Oct 2012
Location: Bulgaria
Old 04-15-2013 , 15:30   Re: Get player touch with different player on death
Reply With Quote #4

Quote:
Originally Posted by FromTheFuture View Post
the player, who break me track when i'm was under fire
What you want to say ?

if(g_iTouchedID[id][FPS] < PUNISH_FPS) return PLUGIN_CONTINUE; what's the problem with the low FPS ?

Last edited by didoWEE; 04-15-2013 at 15:30.
didoWEE is offline
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 04-15-2013 , 15:34   Re: Get player touch with different player on death
Reply With Quote #5

Quote:
Originally Posted by didoWEE View Post
What you want to say ?

if(g_iTouchedID[id][FPS] < PUNISH_FPS) return PLUGIN_CONTINUE; what's the problem with the low FPS ?
Punish those who blocked the way.
It's not real FPS, just touches count, but it's a problem. I must get ~real client FPS and convert it to time.
Need to use ClientThink forward, right? Oww, I hate Think forwards, because it's a bad for server CPU

Last edited by FromTheFuture; 04-15-2013 at 15:40.
FromTheFuture is offline
didoWEE
Senior Member
Join Date: Oct 2012
Location: Bulgaria
Old 04-15-2013 , 15:44   Re: Get player touch with different player on death
Reply With Quote #6

I think you do not need to get any fps. I mean you only need the time.
didoWEE is offline
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 04-15-2013 , 15:48   Re: Get player touch with different player on death
Reply With Quote #7

Quote:
Originally Posted by didoWEE View Post
I think you do not need to get any fps. I mean you only need the time.
How?
FromTheFuture is offline
didoWEE
Senior Member
Join Date: Oct 2012
Location: Bulgaria
Old 04-15-2013 , 15:48   Re: Get player touch with different player on death
Reply With Quote #8

PHP Code:
#define TIME_AFTER_TOUCH 0.1
#define PUNISH_FPS 50

#define ID_PLAYER 0
#define FPS 1

new Floatg_fTouchedTime[33];
new 
g_iTouchedID[33][2], g_iTeam[33];

public 
SaveToucher(idPlayer)
{
    if(
g_iTeam[id] == g_iTeam[Player])
    {
        if(
g_iTouchedID[id][ID_PLAYER] != Player)
        
g_iTouchedID[id][FPS] = 0;
        
        
g_iTouchedID[id][ID_PLAYER] = Player;
        
g_iTouchedID[id][FPS]++;
        
g_fTouchedTime[id] = get_gametime();
    }
}

public 
Event_Damage(id)
{
    static 
Float:fTimefTime get_gametime();
    
    if(
fTime g_fTouchedTime[id] <= TIME_AFTER_TOUCH)
    {
        if(
task_exists(id)) 
        return 
PLUGIN_CONTINUE;
        
        if(
g_iTouchedID[id][FPS] < PUNISH_FPS)
        return 
PLUGIN_CONTINUE;
        
        
set_task(3.0"ClearFloodBlock"id// task for block chat flood about breaks
        
new szName[32], szNameBreaker[32];
        
get_user_name(idszName31);
        
get_user_name(g_iTouchedID[id][ID_PLAYER], szNameBreaker31);
        
client_print(0print_chat"Player %s break %s"szNameBreakerszName);
        
log(fTimeszNameszNameBreaker); // now only logs, after will be punish.
    
}
    
    return 
PLUGIN_CONTINUE;
}




----->




#define TIME_AFTER_TOUCH 0.1

new Float:g_fTouchedTime[33];
new 
g_iTeam[33];

public 
SaveToucher(idPlayer)
    if(
g_iTeam[id] == g_iTeam[Player])
        
g_fTouchedTime[id] = get_gametime();

public 
Event_Damage(id)
{
    static 
Float:fTime;
    
fTime get_gametime();

    if(
fTime g_fTouchedTime[id] <= TIME_AFTER_TOUCH)
    {
        if(
task_exists(id)) 
        return 
PLUGIN_CONTINUE;
    
        
set_task(3.0"ClearFloodBlock"id// task for block chat flood about breaks
    
}
    
    return 
PLUGIN_CONTINUE;

I think the time must NOT be float (not sure)

BTW, going to sleep, cya tomorrow

Last edited by didoWEE; 04-15-2013 at 15:52.
didoWEE is offline
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 04-15-2013 , 15:54   Re: Get player touch with different player on death
Reply With Quote #9

Quote:
Originally Posted by didoWEE View Post
PHP Code:
#define TIME_AFTER_TOUCH 0.1
#define PUNISH_FPS 50

#define ID_PLAYER 0
#define FPS 1

new Floatg_fTouchedTime[33];
new 
g_iTouchedID[33][2], g_iTeam[33];

public 
SaveToucher(idPlayer)
{
    if(
g_iTeam[id] == g_iTeam[Player])
    {
        if(
g_iTouchedID[id][ID_PLAYER] != Player)
        
g_iTouchedID[id][FPS] = 0;
        
        
g_iTouchedID[id][ID_PLAYER] = Player;
        
g_iTouchedID[id][FPS]++;
        
g_fTouchedTime[id] = get_gametime();
    }
}

public 
Event_Damage(id)
{
    static 
Float:fTimefTime get_gametime();
    
    if(
fTime g_fTouchedTime[id] <= TIME_AFTER_TOUCH)
    {
        if(
task_exists(id)) 
        return 
PLUGIN_CONTINUE;
        
        if(
g_iTouchedID[id][FPS] < PUNISH_FPS)
        return 
PLUGIN_CONTINUE;
        
        
set_task(3.0"ClearFloodBlock"id// task for block chat flood about breaks
        
new szName[32], szNameBreaker[32];
        
get_user_name(idszName31);
        
get_user_name(g_iTouchedID[id][ID_PLAYER], szNameBreaker31);
        
client_print(0print_chat"Player %s break %s"szNameBreakerszName);
        
log(fTimeszNameszNameBreaker); // now only logs, after will be punish.
    
}
    
    return 
PLUGIN_CONTINUE;
}




----->




#define TIME_AFTER_TOUCH 0.1

new Float:g_fTouchedTime[33];
new 
g_iTeam[33];

public 
SaveToucher(idPlayer)
    if(
g_iTeam[id] == g_iTeam[Player])
        
g_fTouchedTime[id] = get_gametime();

public 
Event_Damage(id)
{
    static 
Float:fTime;
    
fTime get_gametime();

    if(
fTime g_fTouchedTime[id] <= TIME_AFTER_TOUCH)
    {
        if(
task_exists(id)) 
        return 
PLUGIN_CONTINUE;
    
        
set_task(3.0"ClearFloodBlock"id// task for block chat flood about breaks
    
}
    
    return 
PLUGIN_CONTINUE;

I think the time must NOT be float (not sure)

BTW, going to sleep, cya tomorrow
Noooo = D, if I touch another player or will not touch?
FromTheFuture is offline
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 04-15-2013 , 15:55   Re: Get player touch with different player on death
Reply With Quote #10

Quote:
Originally Posted by didoWEE View Post
[php]
BTW, going to sleep, cya tomorrow
Bye! (:
FromTheFuture 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 10:55.


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