Raised This Month: $ Target: $400
 0% 

Please help code dosent works


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xDoctor
Member
Join Date: Jul 2013
Old 07-05-2014 , 12:37   Please help code dosent works
Reply With Quote #1

i builted a Power Attack for basebuilder.

when some one is the last human he gets +10% bonus damage for each kill

maximum 200%

i tested the plugin in my home private server with cmd.

the debug show non errors then why the plugin dosent work ?


Code :

PHP Code:
/* Plugin generated by AMXX-Studio */

#include < amxmodx >
#include < cstrike >
#include < fakemeta >
#include < hamsandwich >

new iHumanKills[33 ], IsLast 33 ];

public 
plugin_init()
{
    
register_plugin"Power Attack""1.0""Xdoctor" )
    
    
RegisterHamHam_TakeDamage"player""FwdHamTakeDamage" );
    
    
register_logevent"EventRoundStart"2"1=Round_Start" );
    
    
register_event"DeathMsg""evDeathMsg""a" );
    
    
register_forwardFM_PlayerPreThink"fw_Player_PreThink" )
}

public 
client_putinserverclient )    iHumanKillsclient ] = 0;

public 
client_disconnectclient )    iHumanKillsclient ] = 0;

public 
EventRoundStartclient )
    return 
iHumanKillsclient ] = 0;
    
    
public 
fw_Player_PreThinkclient )
{
    new 
Players32 ], iNum;
    
    
get_playersPlayersiNum"aceh""CT" );
    
    if( 
iNum == )
        return 
IsLastclient ] = true;
    else
        return 
IsLastclient ] = false;
        
    if( !
is_user_aliveclient ) || !IsLastclient ] )
        return 
1;
    
    if( 
is_user_aliveclient ) )
    {
        if( 
IsLastclient ] )
        {
            
set_hudmessage025500.300.7806.01.0 )
                    
            
show_hudmessageclient"Power Attack [ %i% ]^n [ %s%s%s%s%s%s%s%s%s%s ]"100 iHumanKillsclient ] * 10,
            
iHumanKillsclient ] < "-" "+",
            
iHumanKillsclient ] < "-" "+",
            
iHumanKillsclient ] < "-" "+",
            
iHumanKillsclient ] < "-" "+",
            
iHumanKillsclient ] < "-" "+",
            
iHumanKillsclient ] < "-" "+",
            
iHumanKillsclient ] < "-" "+",
            
iHumanKillsclient ] < "-" "+",
            
iHumanKillsclient ] < "-" "+",
            
iHumanKillsclient ] < 10 "-" "+" )

        }
    }
    
    return 
1;
}

public 
evDeathMsgclient )
{
    new 
iAttacker read_data);
    
    new 
iVictim read_data);
    
    if( !
is_user_connectediAttacker ) || !is_user_connectediVictim ) || !is_user_aliveiAttacker ) )
        return 
1;
        
    if( 
is_user_botiVictim ) || is_user_hltviVictim ) )
        return 
1;
        
    if( 
cs_get_user_teamiAttacker ) == CS_TEAM_CT && cs_get_user_teamiVictim ) == CS_TEAM_T )
    {
        if( 
IsLastiAttacker ] )
        {
            if( 
iHumanKillsiAttacker ] <= )
            {
                
iHumanKillsiAttacker ] += 1;
                
                
ColorChatiAttacker"You recived^4 10%^3 damage bonus^1 for ^3for^1 killing a^4 Zombie." );
            }
        }
    }
    
    return 
1;
}

public 
FwdHamTakeDamageiVictimInflicatoriAttackerFloatfDamageDamageBits )
{
    if( 
IsLastiAttacker ] && cs_get_user_teamiAttacker ) == CS_TEAM_CT )
    {
        if( 
iHumanKillsiAttacker ] <= 10 )
        {
            
SetHamParamFloat4fDamage iHumanKillsiAttacker ] * 0.2 );
        }
    }
    
    return 
1;
}            

stock ColorChat( const client, const string[ ], { FloatSqlResul} :... )
{
        new 
msg191 ], players32 ], count 1;
       
        static 
lenlen formatexmsgcharsmax(msg), "^1[ ^4BaseBuilder^1 ] " );
        
vformatmsglen ], charsmaxmsg ) - lenstring);
       
        if( 
client )  players] = client;
        else    
get_playersplayers,count"ch" );
       
        for( new 
0counti++ )
        {
                if( 
is_user_connectedplayers] ) )
                {
                        
message_beginMSG_ONE_UNRELIABLEget_user_msgid"SayText" ),_players] );
                        
write_byteplayers] );
                        
write_stringmsg );
                        
message_end( );
                }
        }

xDoctor is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 07-05-2014 , 14:29   Re: Please help code dosent works
Reply With Quote #2

There are wrong things in your code all over the place. I wrote you a example, where you can get some thoughts of. It's not testet nor compiled by me, you have to test it yourself.

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

new iLastCTKillsiLastCT

public plugin_init() 
{
    
RegisterHam(Ham_Killed"player""hamKilledPost"true)
    
RegisterHam(Ham_TakeDamage"player""hamTakeDamagePre"false)

    
register_logevent("eventRoundStart"2"1=Round_Start")
}

public 
eventRoundStart()
{
    
iLastCT = -1
    iLastCTKills 
0
}

public 
hamKilledPost(victimattackershouldgib)
{
    if(
iLastCT == -&& cs_get_user_team(victim) == CS_TEAM_CT)
    {
        new 
iPlayers[32], iNum
        get_players
(iPlayersiNum"ae""CT")

        if(
iNum == 1)
        {
            
iLastCT iPlayers[0]

            return 
HAM_IGNORED
        
}
    }

    if(
attacker == iLastCT && iLastCTKills 20 && cs_get_user_team(victim) == CS_TEAMS_T)
    {
        
iLastCTKills++
    }
}

public 
hamTakeDamagePre(const victim, const inflictor, const attackerFloat:damage, const iDamageType
{
    if(
victim == attacker)
    {
        return 
HAM_IGNORED
    
}

    if(
attacker != iLastCT)
    {
        return 
HAM_IGNORED
    
}
    
    
SetHamParamFloat(4damage * (iLastCTKills 0.1))
        
    return 
HAM_IGNORED

Normaly I wouldn't post code in this way, but since so much is wrong in your code, it may help you more.

Last edited by mottzi; 07-05-2014 at 16:25.
mottzi is offline
Send a message via MSN to mottzi
xDoctor
Member
Join Date: Jul 2013
Old 07-05-2014 , 14:45   Re: Please help code dosent works
Reply With Quote #3

Quote:
Originally Posted by mottzi View Post
There are wrong things in your code all over the place. I wrote you a example, where you can get some thought of. It's not testet not compiled by me, you have to test it yourself.

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

new iLastCTKillsiLastCT

public plugin_init() 
{
    
RegisterHam(Ham_Killed"player""hamKilledPost"true)
    
RegisterHam(Ham_TakeDamage"player""hamTakeDamagePre"false)

    
register_logevent("eventRoundStart"2"1=Round_Start")
}

public 
eventRoundStart()
{
    
iLastCT = -1
    iLastCTKills 
0
}

public 
hamKilledPost(victimattackershouldgib)
{
    if(
iLastCT == -&& cs_get_user_team(victim) == CS_TEAM_CT)
    {
        new 
iPlayers[32], iNum
        get_players
(iPlayersiNum"ae""CT")

        if(
iNum == 1)
        {
            
iLastCT iPlayers[0]

            return 
HAM_IGNORED
        
}
    }

    if(
attacker == iLastCT && iLastCTKills 20 && cs_get_user_team(victim) == CS_TEAMS_T)
    {
        
iLastCTKills++
    }
}

public 
hamTakeDamagePre(const victim, const inflictor, const attackerFloat:damage, const iDamageType
{
    if(
victim == attacker)
    {
        return 
HAM_IGNORED
    
}

    if(
attacker != iLastCT)
    {
        return 
HAM_IGNORED
    
}
    
    
SetHamParamFloat(4damage * (iLastCTKills 0.1))
        
    return 
HAM_IGNORED

Normaly I wouldn't post code in this way, but since so much is wrong in your code, it may help you more.
can you add the hudmessage ?

and you did only when some one die's

i want always

even at start round if is alone.


and the Bonus damage starts from 100% = Normal Damage.

200% = X2 Damage
xDoctor is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 07-05-2014 , 16:17   Re: Please help code dosent works
Reply With Quote #4

Quote:
Originally Posted by xDoctor View Post
can you add the hudmessage ?
Why? You posted in scripting help and I gave you an example. You could try to modify it yourself now. If things don't work you can ask again here.

Quote:
Originally Posted by xDoctor View Post
and you did only when some one die's

i want always

even at start round if is alone.
Then You need to do
PHP Code:
new iPlayers[32], iNum 
get_players
(iPlayersiNum"ae""CT"

if(
iNum == 1

    
iLastCT iPlayers[0

    
//return HAM_IGNORED 

on the newround event. You might also want do check for last CT on client_disconnect().


Quote:
Originally Posted by xDoctor View Post
and the Bonus damage starts from 100% = Normal Damage.

200% = X2 Damage
For each kill you get 10% bonus damage. You can get a max. of 200% bonus damage.

1 kill -> 1.1 * damage (110% damage)
2 kills -> 1.2 * damage (120% damage)
.
.
.
10 kills -> 2.0 * damage (200% damage)
.
.
.
19 kills -> 2.9 * damage (290%)
20 kills -> 3.0 * damage (300%)

You can modify it in this line:
PHP Code:
if(attacker == iLastCT && iLastCTKills 20 && cs_get_user_team(victim) == CS_TEAMS_T
mottzi is offline
Send a message via MSN to mottzi
xDoctor
Member
Join Date: Jul 2013
Old 07-05-2014 , 16:29   Re: Please help code dosent works
Reply With Quote #5

Quote:
Originally Posted by mottzi View Post
Why? You posted in scripting help and I gave you an example. You could try to modify it yourself now. If things don't work you can ask again here.


Then You need to do
PHP Code:
new iPlayers[32], iNum 
get_players
(iPlayersiNum"ae""CT"

if(
iNum == 1

    
iLastCT iPlayers[0

    
//return HAM_IGNORED 

on the newround event. You might also want do check for last CT on client_disconnect().



For each kill you get 10% bonus damage. You can get a max. of 200% bonus damage.

1 kill -> 1.1 * damage (110% damage)
2 kills -> 1.2 * damage (120% damage)
.
.
.
10 kills -> 2.0 * damage (200% damage)
.
.
.
19 kills -> 2.9 * damage (290%)
20 kills -> 3.0 * damage (300%)

You can modify it in this line:
PHP Code:
if(attacker == iLastCT && iLastCTKills 20 && cs_get_user_team(victim) == CS_TEAMS_T
is that alright ?

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

new iLastCTKillsiLastCT

public plugin_init() 
{
    
RegisterHam(Ham_Killed"player""hamKilledPost"true )
    
    
RegisterHam(Ham_TakeDamage"player""hamTakeDamagePre"false )

    
register_logevent("eventRoundStart"2"1=Round_Start")
}

public 
client_putinserverclient )
    
set_task1.0"Information"client );
    
public 
eventRoundStartclient )
{
    
iLastCT = -1
    
    iLastCTKills 
0
    
    
new iPlayers[32], iNum  
    
    get_players
(iPlayersiNum"ae""CT")  

    if(
iNum == 1)  
    {  
        
iLastCT iPlayers[0]  

    }
}

public 
hamKilledPost(victimattackershouldgib)
{
    if(
iLastCT == -&& cs_get_user_team(victim) == CS_TEAM_CT )
    {
        new 
iPlayers[32], iNum
        
        get_players
(iPlayersiNum"ae""CT")

        if(
iNum == 1)
        {
            
iLastCT iPlayers[0]

            return 
HAM_IGNORED
        
}
    }
    
    if( 
attacker == iLastCT && iLastCTKills 10 && cs_get_user_team(victim) == CS_TEAM_T )
    {
        
iLastCTKills += 1;
    }
    
    return 
1;
}

public 
hamTakeDamagePre(const victim, const inflictor, const attackerFloat:damage, const iDamageType
{
    if( 
victim == attacker )
        return 
HAM_IGNORED

    
if(attacker != iLastCT )
        return 
HAM_IGNORED
    
    SetHamParamFloat
(4damage * (iLastCTKills 0.1 ) )
        
    return 
HAM_IGNORED;
}  

public 
Informationclient )
{
    if( !
is_user_aliveclient ) )
        return 
1;
        
    if( 
client == iLastCT )
    {
        
set_hudmessage025500.300.7806.01.0 )
                    
        
show_hudmessageclient"Power Attack [ %i% ]^n [ %s%s%s%s%s%s%s%s%s%s ]"100 iLastCTKills 10,
        
iLastCTKills "-" "+",
        
iLastCTKills "-" "+",
        
iLastCTKills "-" "+",
        
iLastCTKills "-" "+",
        
iLastCTKills "-" "+",
        
iLastCTKills "-" "+",
        
iLastCTKills "-" "+",
        
iLastCTKills "-" "+",
        
iLastCTKills "-" "+",
        
iLastCTKills 10 "-" "+" )
    }
    
    else if( 
client != iLastCT )
    
    {
        
set_hudmessage025500.300.7806.01.0 )
        
        
show_hudmessageclient"Health: [ %i ]^n Armor: [ %i ]"get_user_healthclient ), get_user_armorclient ) );
    }
    
    return 
1;

xDoctor is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 07-05-2014 , 20:44   Re: Please help code dosent works
Reply With Quote #6

The newround event doesn't provide a client-parameter, stop adding one.
Also your else-if() is the same as a regular else() in this case.

I optimized some things for you. Every time a CT becomes the last CT or the last CT kills someone, he gets the hudmessage.

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

new iLastCTKillsiLastCT 

public plugin_init()  

    
RegisterHam(Ham_Killed"player""hamKilledPost"true 
     
    
RegisterHam(Ham_TakeDamage"player""hamTakeDamagePre"false 

    
register_logevent("eventRoundStart"2"1=Round_Start"


public 
searchLastCT()
{
    new 
iPlayers[32], iNum   
     
    get_players
(iPlayersiNum"ae""CT")   

    if(
iNum == 1)   
    {   
        
iLastCT iPlayers[0]  
        return 

    


    return 
0
}
     
public 
eventRoundStart() 

    
iLastCT = -
    iLastCTKills 

     
    
if(searchLastCT()) Information(iLastCT)


public 
client_disconnect(id)
{
    if(
cs_get_user_team(id) == CS_TEAM_CT)
    {
        if(
searchLastCT()) Information(iLastCT)
    }
}

public 
hamKilledPost(victimattackershouldgib

    if(
iLastCT == -&& cs_get_user_team(victim) == CS_TEAM_CT 
    {
        if(
searchLastCT()) Information(iLastCT)
    } 
     
    if( 
attacker == iLastCT && iLastCTKills 10 && cs_get_user_team(victim) == CS_TEAM_T 
    { 
        
iLastCTKills += 1
        
Information(iLastCT)
    } 
     
    return 
1


public 
hamTakeDamagePre(const victim, const inflictor, const attackerFloat:damage, const iDamageType)  

    if( 
victim == attacker 
        return 
HAM_IGNORED 

    
if(attacker != iLastCT 
        return 
HAM_IGNORED 
     
    SetHamParamFloat
(4damage * (iLastCTKills 0.1 ) ) 
         
    return 
HAM_IGNORED
}   

public 
Informationclient 

    if( !
is_user_aliveclient ) ) 
        return 
PLUGIN_CONTINUE
         
    new 
szBar[11]

    for(new 
0iLastCTKillsi++)
    {
        
szBar[i] = '+';
    }

    for(new 
iLastCTKills10i++)
    {
        
szBar[i] = '-';
    }

    
set_hudmessage025500.300.7806.01.0 )       
    
show_hudmessageclient"Power Attack [ %i%% ]^n [ %s ]"100 iLastCTKills 10szBar
     
    return 
PLUGIN_CONTINUE


Last edited by mottzi; 07-05-2014 at 20:45.
mottzi is offline
Send a message via MSN to mottzi
Old 09-09-2014, 15:54
Strick3n
This message has been deleted by YamiKaitou. Reason: spam/rude
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 21:14.


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