AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   help me edit a script!! (https://forums.alliedmods.net/showthread.php?t=325007)

mikaelnatan13 06-04-2020 19:08

help me edit a script!!
 
I was wondering if you could help me with a script

wanted to show adding up all the hits to know how much total damage I gave

script

PHP Code:

#include <amxmodx>

#define PLUGIN "CS Revo: Danos causados"
#define VERSION "1.0"
#define AUTHOR "Wilian M."

new xMsgSync[2]

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event("Damage""xOnDamage""b""2!0""3=0""4!0")    
    
    
xMsgSync[0] = CreateHudSyncObj()    
    
xMsgSync[1] = CreateHudSyncObj()
}

public 
xOnDamage(id)
{
    static 
xAttackerxDamage
    
    xAttacker 
get_user_attacker(id)
    
xDamage read_data(2)
    
    
set_hudmessage(255000.450.5000.13.00.10.1)
    
ShowSyncHudMsg(idxMsgSync[1], "%i"xDamage)    
    
    if(
is_user_connected(xAttacker))
    {
        
set_hudmessage(0100200, -1.00.5500.13.00.020.02)
        
ShowSyncHudMsg(xAttackerxMsgSync[0], "%i"xDamage)        
    }



Bugsy 06-04-2020 19:55

Re: help me edit a script!!
 
Please use php tags when posting code.

mikaelnatan13 06-04-2020 22:37

Re: help me edit a script!!
 
Quote:

Originally Posted by Bugsy (Post 2703990)
Please use php tags when posting code.

ok

Bugsy 06-04-2020 22:48

Re: help me edit a script!!
 
Here are some tips:

Define xDamage globally, as an array, sized using MAX_PLAYERS + 1.

In xOnDamage, you would do xDamage[ id ] += read_data( 2 ).

Set the slot value to 0 on client_disconnect(). Or at new round if that is when you want it reset. If you want to reset everyone, you can use arrayset().

mikaelnatan13 06-04-2020 22:56

Re: help me edit a script!!
 
Quote:

Originally Posted by Bugsy (Post 2704020)
Here are some tips:

Define xDamage globally, as an array, sized using MAX_PLAYERS + 1.

In xOnDamage, you would do xDamage[ id ] += read_data( 2 ).

Set the slot value to 0 on client_disconnect(). Or at new round if that is when you want it reset. If you want to reset everyone, you can use arrayset().

sorry i'm very new to this script business and i didn't understand very well

Bugsy 06-04-2020 23:06

Re: help me edit a script!!
 
You should have posted in Suggestions/Requests if you are not trying to code this yourself.

Here's what I just said, see if you can figure out where it goes.
PHP Code:

//Make this global (placed towards the top of the plugin, delete xDamage in the xOnDamage function
new xDamageMAX_PLAYERS 

//Replace 
xDamage read_data(2)
//with
xDamagexAttacker ] += read_data


mikaelnatan13 06-04-2020 23:22

Re: help me edit a script!!
 
Quote:

Originally Posted by Bugsy (Post 2704025)
You should have posted in Suggestions/Requests if you are not trying to code this yourself.

Here's what I just said, see if you can figure out where it goes.
PHP Code:

//Make this global (placed towards the top of the plugin, delete xDamage in the xOnDamage function
new xDamageMAX_PLAYERS 

//Replace 
xDamage read_data(2)
//with
xDamagexAttacker ] += read_data


it would look something like this

PHP Code:

#include <amxmodx>

#define PLUGIN "CS Revo: Danos causados"
#define VERSION "1.0"
#define AUTHOR "Wilian M."

new xMsgSync[2]
new 
xDamageMAX_PLAYERS ]

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event("Damage""xOnDamage""b""2!0""3=0""4!0")    
    
    
xMsgSync[0] = CreateHudSyncObj()    
    
xMsgSync[1] = CreateHudSyncObj()
}

public 
xOnDamage(id)
{
    static 
xAttackerxDamage
    
    xAttacker 
get_user_attacker(id)
    
xDamagexAttacker ] += read_data
    
    
set_hudmessage(255000.450.5000.13.00.10.1)
    
ShowSyncHudMsg(idxMsgSync[1], "%i"xDamage)    
    
    if(
is_user_connected(xAttacker))
    {
        
set_hudmessage(0100200, -1.00.5500.13.00.020.02)
        
ShowSyncHudMsg(xAttackerxMsgSync[0], "%i"xDamage)        
    }



Bugsy 06-04-2020 23:27

Re: help me edit a script!!
 
You forgot to delete xDamage in xOnDamge. "static xAttacker , xDamage" , delete ", xDamage"

And everywhere else you see xDamage in xOnDamage, you need to change it to xDamage[ xAttacker ]. This will reflect the total damage issued, not the single amount of damage.

mikaelnatan13 06-04-2020 23:35

Re: help me edit a script!!
 
Quote:

Originally Posted by Bugsy (Post 2704029)
You forgot to delete xDamage in xOnDamge. "static xAttacker , xDamage" , delete ", xDamage"

And everywhere else you see xDamage in xOnDamage, you need to change it to xDamage[ xAttacker ]. This will reflect the total damage issued, not the single amount of damage.

like this
PHP Code:

#include <amxmodx>

#define PLUGIN "CS Revo: Danos causados"
#define VERSION "1.0"
#define AUTHOR "Wilian M."

new xMsgSync[2]
new 
xDamageMAX_PLAYERS ]

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event("Damage""xOnDamage""b""2!0""3=0""4!0")    
    
    
xMsgSync[0] = CreateHudSyncObj()    
    
xMsgSync[1] = CreateHudSyncObj()
}

public 
xOnDamage(id)
{
    static 
xAttacker
    
    xAttacker 
get_user_attacker(id)
    
xDamagexAttacker ] += read_data
    
    
set_hudmessage(255000.450.5000.13.00.10.1)
    
ShowSyncHudMsg(idxMsgSync[1], "%i"xDamage [xAttacker])    
    
    if(
is_user_connected(xAttacker))
    {
        
set_hudmessage(0100200, -1.00.5500.13.00.020.02)
        
ShowSyncHudMsg(xAttackerxMsgSync[0], "%i"xDamage [xAttacker])        
    }



mikaelnatan13 06-04-2020 23:40

Re: help me edit a script!!
 
the code would look like this?


All times are GMT -4. The time now is 16:57.

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