Raised This Month: $ Target: $400
 0% 

need help understanding this.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FiVeTeNMontrail
Junior Member
Join Date: Aug 2006
Old 11-12-2007 , 21:59   need help understanding this.
Reply With Quote #1

i am trying to make a pluging so when you kill yourself like 4 times in one round, the server kicks you. It works but im trying to make it so when a new round starts, it resets everything. That is what im having trouble with. Which event would i use for a new round? I wasn't sure so i made it call 3 differen't events.. but when a new round starts, nothing is printed on the screen like i wanted it to. Any clue?

Code:
#include <amxmodx> 
#include <amxmisc> 
#include <engine>
#include <core>
new attacker
new Float:countup[32]
new Float:countupleft[32]
public plugin_init()
{
 register_plugin("Anti-Death Kicker","1.0","FiVeTeN") 
 register_event("Damage","tally","b")
 register_event("EndRound","endRound","a")
 register_event("RoundStat","roundStat","a")
 register_event("RndRes","roundRes","a")
}
public tally(id)
{
 attacker=get_user_attacker(id)
 if(is_user_alive(id)==0)
 {
  if(attacker>32)
  {
  countup[id]=countup[id]+1
  if(countup[id]==2)
  {
   client_print(id,print_chat,"[AMXX] Careful! You have 4 suicides left.",countupleft[id]);
  }
  else if(countup[id]==4)
  {
   client_print(id,print_chat,"[AMXX] Careful! You have 3 suicides left.",countupleft[id]);
  }
  else if(countup[id]==6)
  {
   client_print(id,print_chat,"[AMXX] Careful! You have 2 suicides left.",countupleft[id]);
  }
  else if(countup[id]==8)
  {
   client_print(id,print_chat,"[AMXX] Careful! You have 1 suicides left.",countupleft[id]);
  }
 }
 if(attacker==id)
 {
  countup[id]=countup[id]+1
  if(countup[id]==2){
   client_print(id,print_chat,"[AMXX] Careful! You have 4 suicides left.",countupleft[id]);
  }else if(countup[id]==4){
   client_print(id,print_chat,"[AMXX] Careful! You have 3 suicides left.",countupleft[id]);
  }else if(countup[id]==6){
   client_print(id,print_chat,"[AMXX] Careful! You have 2 suicides left.",countupleft[id]);
  }else if(countup[id]==8){
   client_print(id,print_chat,"[AMXX] Careful! You have 1 suicides left.",countupleft[id]);
  }
 }
 
 
 if(countup[id]>9)
 {
  new userid = get_user_userid(id)  ;
  server_cmd("banid 10 #%d kick",userid);
  countup[id]=0.0;
  countupleft[id]=0.0;
 }
 }
 return PLUGIN_HANDLED
}
public endRound()
{
 client_print(0,print_chat,"Round Ended");
 return PLUGIN_HANDLED
}
public roundStat()
{
 client_print(0,print_chat,"Round Status");
 return PLUGIN_HANDLED
}
public roundRes()
{
 client_print(0,print_chat,"Round RES?");
 return PLUGIN_HANDLED
}
FiVeTeNMontrail is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-12-2007 , 23:03   Re: need help understanding this.
Reply With Quote #2

I would do something like :

Code:
    #include <amxmodx>         #define MAX_CLIENTS 32     #define MAX_SUICIDE 10         new g_iSuicideCnt[ MAX_CLIENTS + 1 ] = { MAX_SUICIDE, ... };         public plugin_init()     {         register_plugin( "Anti-Death Kicker", "1.0", "FiVeTeN" );                 register_event( "DeathMsg", "onDeath", "a" );                                // Suicide         register_event( "TextMsg" , "eResetCount", "a", "2=#Game_will_restart_in" ); // Restart attempt         register_event( "HLTV"    , "eResetCount", "a", "1=0", "2=0" );              // New round     }         public onDeath()     {         new iKiller = read_data( 1 );         new iVictim = read_data( 2 );                 static sWeapon[6];         read_data( 4, sWeapon, sizeof sWeapon - 1 );                 if( iKiller == iVictim && equal( sWeapon, "world", 5 ) )         {             --g_iSuicideCnt[ iVictim ];                         if( !g_iSuicideCnt[ iVictim ] )                 server_cmd( "kick #%d Your message here", get_user_userid( iVictim ) );                         client_print( iVictim, print_chat, "[AMXX] Careful! You have %d suicide%s left.", g_iSuicideCnt[ iVictim ], g_iSuicideCnt[ iVictim ] < 2 ? "" : "s" );         }     }         public eResetCount()         arrayset( g_iSuicideCnt, MAX_SUICIDE, sizeof g_iSuicideCnt );         public client_disconnect( id )           g_iSuicideCnt[id] = MAX_SUICIDE;
__________________
Arkshine is offline
FiVeTeNMontrail
Junior Member
Join Date: Aug 2006
Old 11-13-2007 , 06:43   Re: need help understanding this.
Reply With Quote #3

Alright im not the best with coding so can you explain this?

What is this new iKiller = read_data( 1 );
i have never seen read_data.

This i also don't get

static sWeapon[6];
read_data( 4, sWeapon, sizeof sWeapon - 1 );

what does the read_data do on that part.
FiVeTeNMontrail is offline
M249-M4A1
I <3 Mac
Join Date: May 2005
Location: Not interested
Old 11-13-2007 , 07:36   Re: need help understanding this.
Reply With Quote #4

read_data reads the data returned by the message DeathMsg. read_data(1) will return the killer, and read_data(2) is the id of who died

Basically read_data does as it says
For more information:
http://www.amxmodx.org/funcwiki.php?go=func&id=132
__________________
M249-M4A1 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-13-2007 , 14:24   Re: need help understanding this.
Reply With Quote #5

Sorry I'm not good with explanations. -_-

Also DeathMsg event is called when a player is dead : http://wiki.alliedmods.net/Half-Life...vents#DeathMsg
__________________
Arkshine is offline
FiVeTeNMontrail
Junior Member
Join Date: Aug 2006
Old 11-13-2007 , 21:12   Re: need help understanding this.
Reply With Quote #6

The code does not work for some reason i changed this to see if the onDeath function is even called... and it doesn't seem like it is.


public onDeath()
{
client_print( 0, print_chat, "Testing yo");
new iKiller = read_data( 1 );
new iVictim = read_data( 2 );
static sWeapon[6];

It never prints out testing yo when anyone dies. so idk why this isn't working.
FiVeTeNMontrail is offline
M249-M4A1
I <3 Mac
Join Date: May 2005
Location: Not interested
Old 11-13-2007 , 21:28   Re: need help understanding this.
Reply With Quote #7

You need to hook the actual DeathMsg. Put this in your plugin_init()

PHP Code:
register_event"DeathMsg""onDeath""a" 
__________________
M249-M4A1 is offline
FiVeTeNMontrail
Junior Member
Join Date: Aug 2006
Old 11-13-2007 , 21:59   Re: need help understanding this.
Reply With Quote #8

I already have that, i was just posting part of the code.

Code:
 #include <amxmodx>
    
    #define MAX_CLIENTS 32
    #define MAX_SUICIDE 4
    
    new g_iSuicideCnt[ MAX_CLIENTS + 1 ] = { MAX_SUICIDE, ... };
    
    public plugin_init()
    {
        register_plugin( "Anti-Death Kicker", "1.0", "FiVeTeN" );
        
        register_event( "DeathMsg", "onDeath", "a" );                                // Suicide
        register_event( "TextMsg" , "eResetCount", "a", "2=#Game_will_restart_in" ); // Restart attempt
        register_event( "HLTV"    , "eResetCount", "a", "1=0", "2=0" );              // New round
    }
    
    public onDeath()
    {
 client_print( 0, print_chat, "Testing yo");
        new iKiller = read_data( 1 );
        new iVictim = read_data( 2 );
        static sWeapon[6]; 
        read_data( 4, sWeapon, sizeof sWeapon - 1 );
        
        if( iKiller == iVictim && equal( sWeapon, "world", 5 ))
        {
            --g_iSuicideCnt[ iVictim ];
            
            if( !g_iSuicideCnt[ iVictim ] )
                server_cmd( "kick #%d Your message here", get_user_userid( iVictim ) );
            
            client_print( iVictim, print_chat, "[AMXX] Careful! You have %d suicide%s left.", g_iSuicideCnt[ iVictim ], g_iSuicideCnt[ iVictim ] < 2 ? "" : "s" );
        }
    }
    
    public eResetCount()
        arrayset( g_iSuicideCnt, MAX_SUICIDE, sizeof g_iSuicideCnt );
    
    public client_disconnect( id )  
        g_iSuicideCnt[id] = MAX_SUICIDE;
FiVeTeNMontrail is offline
alien
Senior Member
Join Date: Aug 2005
Location: London || Slovakia
Old 11-13-2007 , 22:29   Re: need help understanding this.
Reply With Quote #9

It's working for me, mate ...
Make sure you have latest .amxx file in your plugins directory and server restarted.
__________________
alien is offline
Send a message via ICQ to alien
FiVeTeNMontrail
Junior Member
Join Date: Aug 2006
Old 11-13-2007 , 22:42   Re: need help understanding this.
Reply With Quote #10

Do you think it could be because im using this plugin for a mod called zombie panic?
FiVeTeNMontrail 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 01:20.


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