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

Show Damage Plus


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Berkio
New Member
Join Date: Dec 2021
Old 10-06-2022 , 03:22   Show Damage Plus
Reply With Quote #1

SHOW DAMAGE PLUS RESET / TIME PROBLEM
Hi friends, there is a combo and hits plugin in this plugin
I want the Combo and Hits to be reset, but I can't

Combo : Will be reset after 2 seconds
but every time we do damage for 2 seconds, it will go back to 2 seconds again

Hits : When we move to the new round, we will clear everyone Hits

PHP Code:
/*
| =============================
| Generated by Berk
| Made in Turkey
| Keep It Ready
| =============================
*/

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Show Damage Plus"
#define VERSION "1.0"
#define AUTHOR "Berk"

new iCombo[33] , iHits[33]
new 
iTimeout[33]
new 
g_Maxplayers

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("Damage","event_damage","b","2!0","3=0","4!0")
    
register_event("HLTV""event_new_round""a""1=0""2=0"
}

public 
client_connected(idattacker)
{
    
set_task(1.0"ComboControl"attacker__"b")
}

public 
event_damage(id)
{
    new 
attacker get_user_attacker(id)
    new 
iDamage read_data(2)
    
    
iTimeout[attacker] = 2
    iCombo
[attacker]++
    
iHits[attacker]++
    
    
set_hudmessage(0255255, -1.00.704.01.02.0__, -1)
    
show_hudmessage(attacker"%i^n(Combo %dx) (Hit's %d)"iDamageiCombo[attacker], iHits[attacker])
    
}

public 
ComboControl(idattacker)
{
    if(
iTimeout[attacker] >= 0)
    {
        
iTimeout[attacker] -= 1
    
}
    
    if(
iTimeout[attacker] == 0)
    {
        
iCombo[attacker] = 0
    
}
}

public 
event_new_round()
{
    for(new 
player;player<g_Maxplayers;player++)
     
iHits[32]= 0;

note: Please write the reason for the problem, thank you.

Last edited by Berkio; 10-06-2022 at 03:33.
Berkio is offline
zXCaptainXz
Member
Join Date: May 2017
Old 10-06-2022 , 16:20   Re: Show Damage Plus
Reply With Quote #2

PHP Code:
public client_connected(idattacker)
{
    
set_task(1.0"ComboControl"attacker__"b")

->
PHP Code:
public client_putinserver(id)
{
    
set_task(1.0"ComboControl"id__"b")

client_connected doesn't even exist, client_connect (would recommend client_putinserver since it makes sure the client is "connected" not "connecting") is the correct function and it only takes one argument, which is the id of the connecting player.

PHP Code:
public ComboControl(idattacker)
{
    if(
iTimeout[attacker] >= 0)
    {
        
iTimeout[attacker] -= 1
    
}
    
    if(
iTimeout[attacker] == 0)
    {
        
iCombo[attacker] = 0
    
}

->
PHP Code:
public ComboControl(id)
{
    if(
iTimeout[id] >= 0)
    {
        
iTimeout[id] -= 1
    
}
    
    if(
iTimeout[id] == 0)
    {
        
iCombo[id] = 0
    
}

When you set the task with the id, the first argument is the one that's used as ID, not the second like you did.

In all cases, that's not what I would do, since it would not guarantee that 2 seconds would pass between combo resets, it could take between 1 and 2 seconds inconsistently. I would do this instead:
PHP Code:
/*
| =============================
| Generated by Berk
| Made in Turkey
| Keep It Ready
| =============================
*/

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Show Damage Plus"
#define VERSION "1.0"
#define AUTHOR "Berk"

new iCombo[33] , iHits[33]
new 
g_Maxplayers

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("Damage","event_damage","b","2!0","3=0","4!0")
    
register_event("HLTV""event_new_round""a""1=0""2=0"
}

public 
event_damage(id)
{
    new 
attacker get_user_attacker(id)
    new 
iDamage read_data(2)
    
    
remove_task(attacker// Remove the task if it already exists to reset after 2 seconds
    
set_task(2.0attacker"reset_damage"//Set a task after 2 seconds to reset
    
iCombo[attacker]++
    
iHits[attacker]++
    
    
set_hudmessage(0255255, -1.00.704.01.02.0__, -1)
    
show_hudmessage(attacker"%i^n(Combo %dx) (Hit's %d)"iDamageiCombo[attacker], iHits[attacker])
    
}

public 
reset_damage(id)
{
    
iCombo[id] = 0
}

public 
event_new_round()
{
    for(new 
player;player<g_Maxplayers;player++)
     
iHits[32]= 0;


Last edited by zXCaptainXz; 10-06-2022 at 16:29. Reason: Forgot to delete unnecessary code
zXCaptainXz is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 10-06-2022 , 21:32   Re: Show Damage Plus
Reply With Quote #3

You don't need set_task for this.
Use get_gametime and check if the time is larger than current time or not

PHP Code:
/*
| =============================
| Generated by Berk
| Made in Turkey
| Keep It Ready
| =============================
*/

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Show Damage Plus"
#define VERSION "1.0"
#define AUTHOR "Berk"

#define TIMEOUT 2.0 //How long will the combo reset

new iCombo[33] , iHits[33]
new 
Float:fTimeout[33]
new 
g_Maxplayers

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("Damage","event_damage","b","2!0","3=0","4!0")
    
register_event("HLTV""event_new_round""a""1=0""2=0"
}

public 
event_damage(id)
{
    new 
attacker get_user_attacker(id)
    new 
iDamage read_data(2)
    
    
//Check to reset combo
    
if(fTimeout[attacker] >= get_gametime())
       
iCombo[attacker] = 0

    fTimeout
[attacker] = get_gametime() + TIMEOUT //Set next timeout
    
iCombo[attacker]++
    
iHits[attacker]++
    
    
set_hudmessage(0255255, -1.00.7004.01.0__, -1)
    
show_hudmessage(attacker"%i^n(Combo %dx) (Hit's %d)"iDamageiCombo[attacker], iHits[attacker])
    
}

public 
event_new_round()
{
    for(new 
player;player<g_Maxplayers;player++)
        
iHits[32]= 0;

__________________
My plugin:

Last edited by Celena Luna; 10-09-2022 at 02:01.
Celena Luna is offline
SoulWeaver16
Senior Member
Join Date: May 2021
Location: Uruguay
Old 10-08-2022 , 02:25   Re: Show Damage Plus
Reply With Quote #4

Quote:
Originally Posted by Celena Luna View Post
You don't need set_task for this.
Use get_gametime and check if the time is larger than current time or not

PHP Code:
/*
| =============================
| Generated by Berk
| Made in Turkey
| Keep It Ready
| =============================
*/

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Show Damage Plus"
#define VERSION "1.0"
#define AUTHOR "Berk"

#define TIMEOUT 2.0 //How long will the combo reset

new iCombo[33] , iHits[33]
new 
fTimeout[33]
new 
g_Maxplayers

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("Damage","event_damage","b","2!0","3=0","4!0")
    
register_event("HLTV""event_new_round""a""1=0""2=0"
}

public 
event_damage(id)
{
    new 
attacker get_user_attacker(id)
    new 
iDamage read_data(2)
    
    
//Check to reset combo
    
if(fTimeout[attacker] >= get_gametime())
       
iCombo[attacker] = 0

    fTimeout
[attacker] = get_gametime() + TIMEOUT //Set next timeout
    
iCombo[attacker]++
    
iHits[attacker]++
    
    
set_hudmessage(0255255, -1.00.704.01.02.0__, -1)
    
show_hudmessage(attacker"%i^n(Combo %dx) (Hit's %d)"iDamageiCombo[attacker], iHits[attacker])
    
}

public 
event_new_round()
{
    for(new 
player;player<g_Maxplayers;player++)
        
iHits[32]= 0;

Code:
// C:\Program Files (x86)\Steam\steamapps\common\Half-Life\czero\addons\amxmodx\scripting\Show_Damage_Plus.sma(37 -- 38) : warning 213: tag mismatch
// C:\Program Files (x86)\Steam\steamapps\common\Half-Life\czero\addons\amxmodx\scripting\Show_Damage_Plus.sma(41) : warning 213: tag mismatch
__________________
Extended Arm Weapon Skin v2.1 {16/Apr/23}
(Detect which class is and associate it with the corresponding arms)
SideWeapons v0.2 {01/Sep/22}
(New version of Back Weapons v1.87)

SoulWeaver16 is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 10-09-2022 , 02:03   Re: Show Damage Plus
Reply With Quote #5

Quote:
Originally Posted by SoulWeaver16 View Post
Code:
// C:\Program Files (x86)\Steam\steamapps\common\Half-Life\czero\addons\amxmodx\scripting\Show_Damage_Plus.sma(37 -- 38) : warning 213: tag mismatch
// C:\Program Files (x86)\Steam\steamapps\common\Half-Life\czero\addons\amxmodx\scripting\Show_Damage_Plus.sma(41) : warning 213: tag mismatch
PHP Code:
new fTimeout[33]

set_hudmessage(0255255, -1.00.704.01.02.0__, -1
=>
PHP Code:
new Float:fTimeout[33]

set_hudmessage(0255255, -1.00.7004.01.0__, -1
I forget to add Float: there
The set_message he didn't add efffets parameter on the original code but I didn't check

Edited of the other post
__________________
My plugin:
Celena Luna is offline
Reply


Thread Tools
Display Modes

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 02:41.


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