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

MoneyBonus[ Solved ] Crash [ Solved ]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Baws
Veteran Member
Join Date: Oct 2012
Old 10-13-2013 , 13:45   MoneyBonus[ Solved ] Crash [ Solved ]
Reply With Quote #1

Okay so in my latest plugin on this forum is crashing my server that i have the plugin on and what is the problem is that people who suicide or anyone who suicide makes the server crash. I asked for many help as i can before posting this post but nothing works. So please, i need this very badly! I need help! Here is the code. What i tested before posting is that i remove the DamageBonus part and no crashes so i think it's from there. But look please! Btw, bonus should only be for VIP_ACCESS flag. Thank you in advanced! Please!


PHP Code:
#include < amxmodx >
#include < amxmisc >
#include < fakemeta >
#include < fun >
#include < geoip >
#include < cstrike >
#include < colorchat >
#include < hamsandwich >

#define PLUGIN "Simple Surf Vip"
#define VERSION "1.0"

#define CN_SOUND    "buttons/bell1.wav"    // Connect sound 
#define DC_SOUND    "fvox/blip.wav"        // Disconnect sound 

#define XO_PLAYER            5
#define m_flFlashedUntil     514
#define m_flFlashedAt        515
#define m_flFlashHoldTime    516
#define m_flFlashDuration    517
#define m_iFlashAlpha        518

#define ALPHA_FULLBLINDED    255

#define VIP_ACCESS    ADMIN_LEVEL_E

#define is_vip(%1)    ( get_user_flags(%1) & VIP_ACCESS )

/* Here you can edit the '100' to w/e you want the VIP to have at spawn or round start. It's his health */
#define VIP_HEALTH    ( 100 )

new g_pCvarHsBonusg_pCvarKillBonus
new g_pCvarHpPerHeadShotg_pCvarHpPerKill

public plugin_init( )
{
    
register_pluginPLUGINVERSION"Baws" )
    
    
register_cvar"surfvip_version"VERSIONFCVAR_SERVER FCVAR_SPONLY );
    
set_cvar_string"surfvip_version"VERSION );
    
    
register_messageget_user_msgid"SayText" ), "VipTag" );
    
    
RegisterHamHam_Spawn"player""VipSpawn"true );
    
    
register_event("Damage","DamageBonus","b")
    
register_event"DeathMsg""eDeathMsg""a" );
    
register_logevent"eRoundStart"2"1=Round_Start" )
    
    
g_pCvarHpPerHeadShot register_cvar"surfvip_hp_per_hs""30" //Health added with a head shot kill from vip.
    
g_pCvarHpPerKill register_cvar"surfvip_hp_per_kill""15" //Health added with a normal kill from vip.
    
g_pCvarHsBonus register_cvar"surfvip_money_per_hs""500" //Money added for headshot kill from vip.
    
g_pCvarKillBonus register_cvar"surfvip_money_per_kill""200" //Money added for normal kill from vip.
    
    /* Vip who's online commands */
    
register_clcmd"say /vip""showvips_online" )
    
register_clcmd"say_team /vip""showvips_online" )
    
register_clcmd"say /vips""showvips_online" )
    
register_clcmd"say_team /vips""showvips_online" )
    
    
/* MOTD Vip help commands */
    
register_clcmd"say /wantvip""VipInfo" )
    
register_clcmd"say_team /wantvip""VipInfo" )
    
register_clcmd"say /viphelp""VipInfo" )
    
register_clcmd"say_team /viphelp""VipInfo" )
}

public 
showvips_onlineid )
{
    new 
iPlayers32 ], iNumiPlayerIdszName32 ]
    
get_playersiPlayersiNum"ch" )
    
    new 
iLenszMessage[ ( sizeof iPlayers ) * charsmaxszName ) ]
    
    
iLen formatexszMessagecharsmaxszMessage ), "^x04Vips Online:" )
    
    for( new 
iiNumi++ )
    {
        
iPlayerId iPlayers]
        if( 
is_vipiPlayerId ) )
        {
            
get_user_nameiPlayerIdszName31 )
            
iLen += formatexszMessageiLen ], charsmaxszMessage ) - iLen" %s%s"szNameiLen "," "" )
        }
    }
    
ColorChatidGREENszMessage )
}

public 
VipInfoid )
{
   
show_motdid"vipinfo.txt""Surf Vip Information" )
}

public 
client_putinserverid )
{
    if( !
is_user_botid ) )
    {
        new 
szName32 ], szCountry46 ];
        
get_user_nameidszName31 );
        
szCountry get_user_countryid );
         
        if( 
get_user_flagsid ) & VIP_ACCESS )
        {
            
ColorChat0GREEN"^x04* ^x01Surf Vip^x04 %s (%s)^x01 has Connected ^x04*"szNameszCountry );
            
client_cmd0"spk %s"CN_SOUND )
        }
    }
}
 
public 
client_disconnectid )
{
    if( !
is_user_botid ) ) 
    {
        new 
szName32 ], szCountry46 ];
        
get_user_nameidszName31 );
        
szCountry get_user_countryid );
         
        if( 
get_user_flagsid ) & VIP_ACCESS )
        {
            
ColorChat0GREEN"^x04* ^x01Surf Vip^x04 %s (%s)^x01 has Disconnected ^x04*"szNameszCountry );
            
client_cmd0"spk %s"DC_SOUND )
        }
    }
}

public 
VipSpawnid )
{
    if( 
is_user_aliveid ) && get_user_flagsid ) & VIP_ACCESS )
    {
        
set_user_healthidVIP_HEALTH );
    }
}

public 
get_user_countryindex 

    static 
szIP32 ], szCountry46 ]; 
    
get_user_ipindexszIP31 ); 
    
geoip_countryszIPszCountry ); 

    if( 
equalszCountry"error" ) ) 
    { 
    if( !
containszIP"192.168." ) || !containszIP"10. " ) || !containszIP"172." ) || equalszIP"127.0.0.1" ) ) 
    
szCountry "LAN"

    else if( 
equalszIP"loopback" ) ) 
    
szCountry "ListenServer User";
    
    else
    
szCountry "Unknown Country";
    }
    return 
szCountry;
}

public 
VipTagmsgIdmsgDestmsgEnt )
{
    new 
id get_msg_arg_int);
    
    if( 
is_user_connectedid ) && get_user_flagsid ) & VIP_ACCESS )
    {
        new 
szTmp256 ],
            
szTmp2256 ];
            
        
get_msg_arg_string2szTmpcharsmaxszTmp ) );
        
        new 
szPrefix64 ] = "^x01[ ^x04VIP ^x01]";
        
        if( !
equalszTmp"#Cstrike_Chat_All" ) )
        {
            
addszTmp2charsmaxszTmp2 ), szPrefix );
            
addszTmp2charsmaxszTmp2 ), " " );
            
addszTmp2charsmaxszTmp2 ), szTmp );
        }
        else
        {
            
addszTmp2charsmaxszTmp2 ), szPrefix );
            
addszTmp2charsmaxszTmp2 ), "^x03 %s1^x01 :  %s2" );
        }
        
set_msg_arg_string2szTmp2 );
    }
    return 
PLUGIN_CONTINUE;
}

public 
eRoundStart( )
{
    new 
players32 ], iCountiPlayer
    get_players
playersiCount"ch" )
    
    for( new 
iiCounti++ )
    {
        
iPlayer players]
        if( 
is_vipiPlayer ) && is_user_aliveiPlayer ) )
        {
            new 
Weapons32 ], iNum
            
new iWepBitSum /**/~/**/get_user_weaponsiPlayerWeaponsiNum )
            
            if( 
iWepBitSum & ( 1<<CSW_HEGRENADE ) )
                
give_itemiPlayer"weapon_hegrenade" )
                
            if( 
iWepBitSum & ( 1<<CSW_FLASHBANG ) )
                
give_item(iPlayer"weapon_flashbang" )
                
            if( 
iWepBitSum & ( 1<<CSW_SMOKEGRENADE ) )
                
give_itemiPlayer"weapon_smokegrenade" )
        }
    }    
}

public 
eDeathMsg( )
{
    new 
hp_added64 ];
    static 
iHeadShotiVictimiKillerId
    iKillerId 
read_data)
    
iVictim read_data)
    
iHeadShot read_data)
    
    if( 
iVictim == iKillerId )
    {
            return 
PLUGIN_HANDLED;
    }
    if( 
is_vipiKillerId ) )
    {
        if( 
iHeadShot )
        {
            new 
nHpHs_add get_pcvar_numg_pCvarHpPerHeadShot )
            if( 
get_user_healthiKillerId ) > )
            
set_user_healthiKillerIdget_user_healthiKillerId ) + nHpHs_add )
            if( 
get_user_healthiKillerId ) )
            {
                
formathp_addedsizeofhp_added ), "Nice HeadShot! Healed +%d HP!"nHpHs_add )
                
set_hudmessage02550, -1.00.1501.01.00.10.1, -)
                
show_hudmessageiKillerIdhp_addednHpHs_add )
            }
            if( !
get_user_flashediKillerId ) )
            {
                
message_beginMSG_ONEget_user_msgid"ScreenFade" ), { 0,0,}, iKillerId )
                
write_short1<<10 )
                
write_short1<<10 )
                
write_short0x0000 )
                
write_byte)
                
write_byte)
                
write_byte200 )
                
write_byte75 )
                
message_end( )
            }
        }
        else
        {
            new 
nHp_add get_pcvar_numg_pCvarHpPerKill )
            if( 
get_user_healthiKillerId ) > )
            
set_user_healthiKillerIdget_user_healthiKillerId ) + nHp_add )
            if( 
get_user_healthiKillerId ) )
            {
                
formathp_addedsizeofhp_added ), "Nice Kill! Healed +%d HP!"nHp_add )
                
set_hudmessage02550, -1.00.1501.01.00.10.1, -)
                
show_hudmessageiKillerIdhp_addednHp_add )
            }
            if( !
get_user_flashediKillerId ) )
            {
                
message_beginMSG_ONEget_user_msgid"ScreenFade" ), { 0,0,}, iKillerId )
                
write_short1<<10 )
                
write_short1<<10 )
                
write_short0x0000 )
                
write_byte)
                
write_byte)
                
write_byte200 )
                
write_byte75 )
                
message_end( )
            }
        }
    }
    return 
PLUGIN_HANDLED;
}

public 
DamageBonusid )
{
    new 
HitzoneWeaponAttacker get_user_attackeridWeaponHitzone )
    new 
Players32 ], Aid;
    
get_playersPlayersAid )
    if( 
Attacker <= Aid && is_user_aliveAttacker ) && Attacker != id && !is_user_aliveid ) )
    {
        
cs_set_user_moneyAttackercs_get_user_moneyAttacker ) + get_pcvar_numg_pCvarKillBonus ) )
        if(  
Hitzone == )
                
cs_set_user_moneyAttackercs_get_user_moneyAttacker ) + get_pcvar_numg_pCvarHsBonus ) )
        }
}

get_user_flashedid, &iPercent=)
{
    new 
Float:flFlashedAt get_pdata_floatidm_flFlashedAtXO_PLAYER )

    if( !
flFlashedAt )
    {
        return 
0
    
}

    new 
Float:flGameTime get_gametime( )
    new 
Float:flTimeLeft flGameTime flFlashedAt
    
new Float:flFlashDuration get_pdata_floatidm_flFlashDurationXO_PLAYER )
    new 
Float:flFlashHoldTime get_pdata_floatidm_flFlashHoldTimeXO_PLAYER )
    new 
Float:flTotalTime flFlashHoldTime flFlashDuration

    
if( flTimeLeft flTotalTime )
    {
        return 
0
    
}

    new 
iFlashAlpha get_pdata_intidm_iFlashAlphaXO_PLAYER )

    if( 
iFlashAlpha == ALPHA_FULLBLINDED )
    {
        if( 
get_pdata_floatidm_flFlashedUntilXO_PLAYER) - flGameTime 0.0 )
        {
            
iPercent 100
        
}
        else
        {
            
iPercent 100-floatround( ( ( flGameTime - ( flFlashedAt flFlashHoldTime ) )*100.0 )/flFlashDuration )
        }
    }
    else
    {
        
iPercent 100-floatround( ( ( flGameTime flFlashedAt )*100.0 )/flTotalTime )
    }

    return 
iFlashAlpha

__________________
Like my clean plugins and work?

Last edited by Baws; 10-19-2013 at 00:51.
Baws is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 10-13-2013 , 16:36   Re: Bonus = Server Crash = Shutting Down
Reply With Quote #2

if ( ! is_user_connected(iKillerId) ) return PLUGIN_CONTINUE;

Don't know if it will help with the crash issue, but I'm guessing it will.
__________________
Black Rose is offline
Baws
Veteran Member
Join Date: Oct 2012
Old 10-13-2013 , 19:25   Re: Bonus = Server Crash = Shutting Down
Reply With Quote #3

Quote:
Originally Posted by Black Rose View Post
if ( ! is_user_connected(iKillerId) ) return PLUGIN_CONTINUE;

Don't know if it will help with the crash issue, but I'm guessing it will.
So far on the tested server ( PUB ) it worked but still going to see if it works on the surf server. I will edit this post.


*Is it possible to do like on death to earn money? example: not on every shot 200+ or 500+ i want like on kill you get 200+ on normal and hs 500+. What i tried is this:

PHP Code:
public DamageBonusid 

    new 
HitzoneWeaponAttacker get_user_attackeridWeaponHitzone 
    new 
Players32 ], Aid
    
get_playersPlayersAid 
    if( 
Attacker <= Aid && is_user_aliveAttacker ) && Attacker != id && is_vipAttacker ) )
    { 
    
cs_set_user_moneyAttackercs_get_user_moneyAttacker ) + get_pcvar_numg_pCvarKillBonus ) ) 
    if(  
Hitzone == 
    
cs_set_user_moneyAttackercs_get_user_moneyAttacker ) + get_pcvar_numg_pCvarHsBonus ) ) 
    }

But this only gives money on every shot i do.
__________________
Like my clean plugins and work?
Baws is offline
dark_style
Senior Member
Join Date: Jul 2009
Location: Bulgaria
Old 10-14-2013 , 00:50   Re: Bonus = Server Crash = Shutting Down
Reply With Quote #4

Quote:
*Is it possible to do like on death to earn money? example: not on every shot 200+ or 500+ i want like on kill you get 200+ on normal and hs 500+. What i tried is this:
Yes, it is. Do it on DeathMsg event.
__________________




Last edited by dark_style; 10-14-2013 at 00:51.
dark_style is offline
Baws
Veteran Member
Join Date: Oct 2012
Old 10-14-2013 , 12:53   Re: Bonus = Server Crash = Shutting Down
Reply With Quote #5

But the Money bonus is in the DamageBonus event. And it work good with the code above it's just gives money on every shot.
__________________
Like my clean plugins and work?
Baws 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 02:14.


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