Raised This Month: $ Target: $400
 0% 

Plugin doesnt register event.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Pantheon
Member
Join Date: Jan 2011
Old 01-07-2011 , 11:45   Plugin doesnt register event.
Reply With Quote #1

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

new bool:bTransfer false

public plugin_init() {
    
register_plugin("Mod","0.0.1","Pantheon")
    
register_clcmd("say !team","Event_TeamCheck",0," prints how many players in each team.")
    
register_logevent("RoundStart",2,"1=Round_Start")
    
register_event("CTransfer""Transfer""a")
}

public 
GetTeamCounts( &TCount , &CTCount )    {
    new 
iMaxPlayers get_maxplayers()
    
TCount 0
    CTCount 
0

    
for ( new <= iMaxPlayers i++ )    {
        if ( !
is_user_connected) )
            continue

        switch ( 
cs_get_user_team) )    {
            case 
CS_TEAM_TTCount++
            case 
CS_TEAM_CTCTCount++
        }
    }
}

public 
RoundStart() {
    new 
iTs iCTs
    GetTeamCounts
iTs iCTs )
    
client_printprint_center "Teams are being arranged. Stay Patient.")
    if (
iTs 1) {
        
bTransfer true
    
}else{
        
set_task(3.0,"Transfer_NoAction"0)
    }
}

public 
Transfer() {
    
client_print(0print_chat"LoL!!!")
    while (
bTransfer) {
        new 
zUser[32], i
        
if (cs_get_user_team(zUser[i])==CS_TEAM_T)
            
cs_set_user_team(zUser[i], CS_TEAM_CTCS_DONTCHANGE)
        else
            
set_task(3.0,"Transfer_NoAction"0)
    }
}

public 
Transfer_NoAction() {
    
client_print(0print_center"No Action was taken!")
}

public 
Event_TeamCheck() {
    new 
iTs iCTs
    GetTeamCounts
iTs iCTs )
    
client_printprint_chat "Terrorist=%d Counter Terrorist=%d" iTs iCTs )

Quote:
Teams are being arranged. Stay Patient.
is being printed. As well as:
Quote:
No Action was taken!
What am i doing wrong?
Pantheon is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-07-2011 , 11:57   Re: Plugin doesnt register event.
Reply With Quote #2

"CTransfer" event doesn't exist.

You have put that randomly or what?
__________________
Arkshine is offline
Pantheon
Member
Join Date: Jan 2011
Old 01-07-2011 , 12:01   Re: Plugin doesnt register event.
Reply With Quote #3

Quote:
Originally Posted by Arkshine View Post
"CTransfer" event doesn't exist.

You have put that randomly or what?
No, i thought the second parameter was the event name.
Pantheon is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 01-07-2011 , 12:22   Re: Plugin doesnt register event.
Reply With Quote #4

http://amxmodx.org/funcwiki.php?sear...vent&go=search
The first param is the name of the event, you can find the events here
the second parameter is the name of the function that's being called when the event is fired.

example:
PHP Code:
register_event("TeamInfo""Event_TeamInfo""a");

public 
Event_TeamInfo()
    
client_print(0print_chat"event TeamInfo is called"); 
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Pantheon
Member
Join Date: Jan 2011
Old 01-07-2011 , 14:16   Re: Plugin doesnt register event.
Reply With Quote #5

I get these errors:
PHP Code:
L 01/07/2011 20:14:13: [CSTRIKEPlayer out of range (0)
L 01/07/2011 20:14:13: [AMXXDisplaying debug trace (plugin "mod.amxx")
L 01/07/2011 20:14:13: [AMXXRun time error 10native error (native "cs_get_user_team")
L 01/07/2011 20:14:13: [AMXX]    [0assassinsmod.sma::Event_TeamInfo (line 38
PHP Code:
#include <amxmodx>
#include <cstrike>

public plugin_init() {
    
register_plugin("Mod","0.0.1","Pantheon")
    
register_clcmd("say !team","Event_TeamCheck",0," prints how many players in each team.")
    
register_logevent("RoundStart",2,"1=Round_Start")
    
register_event("TeamInfo""Event_TeamInfo""a")
}

public 
GetTeamCounts( &TCount , &CTCount )    {
    new 
iMaxPlayers get_maxplayers()
    
TCount 0
    CTCount 
0

    
for ( new <= iMaxPlayers i++ )    {
        if ( !
is_user_connected) )
            continue

        switch ( 
cs_get_user_team) )    {
            case 
CS_TEAM_TTCount++
            case 
CS_TEAM_CTCTCount++
        }
    }
}

public 
RoundStart() {
    new 
iTs iCTs
    GetTeamCounts
iTs iCTs )
    
client_printprint_center "Teams are being arranged. Stay Patient.")
    if (
iTs 2)
        
set_task(3.0,"Transfer_NoAction"0)
}

public 
Event_TeamInfo() {
    
client_print(0print_chat"Success!")
    new 
zUser[32], i
    
if (cs_get_user_team(zUser[i])==CS_TEAM_T)
        
cs_set_user_team(zUser[i], CS_TEAM_CTCS_DONTCHANGE)
    else
        
set_task(3.0,"Transfer_NoAction"0)
}

public 
Transfer_NoAction() {
    
client_print(0print_center"No Action was taken!")
}

public 
Event_TeamCheck() {
    new 
iTs iCTs
    GetTeamCounts
iTs iCTs )
    
client_printprint_chat "Terrorist=%d Counter Terrorist=%d" iTs iCTs )


Last edited by Pantheon; 01-07-2011 at 14:24.
Pantheon is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 01-07-2011 , 14:25   Re: Plugin doesnt register event.
Reply With Quote #6

PHP Code:
public Event_TeamInfo() {
    
client_print(0print_chat"Success!")

    new 
id read_data(1);
    if (
cs_get_user_team(id)==CS_TEAM_T)
        
cs_set_user_team(idCS_TEAM_CTCS_DONTCHANGE)
    else
        
set_task(3.0,"Transfer_NoAction"0)

__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Pantheon
Member
Join Date: Jan 2011
Old 01-07-2011 , 15:15   Re: Plugin doesnt register event.
Reply With Quote #7

Quote:
Originally Posted by drekes View Post
PHP Code:
public Event_TeamInfo() {
    
client_print(0print_chat"Success!")

    new 
id read_data(1);
    if (
cs_get_user_team(id)==CS_TEAM_T)
        
cs_set_user_team(idCS_TEAM_CTCS_DONTCHANGE)
    else
        
set_task(3.0,"Transfer_NoAction"0)

Thanks, i did some minor changes myself.

And it still doesnt work.

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

new bool:bTransfer false

public plugin_init() {
    
register_plugin("Assassins Creed Mod","0.0.1","Pantheon")
    
register_clcmd("say !team","Event_TeamCheck",0," prints how many players in each team.")
    
register_logevent("RoundStart",2,"1=Round_Start")
    
register_event("TeamInfo""Event_TeamInfo""a")
}

public 
GetTeamCounts( &TCount , &CTCount )    {
    new 
iMaxPlayers get_maxplayers()
    
TCount 0
    CTCount 
0

    
for ( new <= iMaxPlayers i++ )    {
        if ( !
is_user_connected) )
            continue

        switch ( 
cs_get_user_team) )    {
            case 
CS_TEAM_TTCount++
            case 
CS_TEAM_CTCTCount++
        }
    }
}

public 
RoundStart() {
    new 
iTs iCTs
    GetTeamCounts
iTs iCTs )
    
client_printprint_center "Teams are being arranged. Stay Patient.")
    if (
iTs 1) {
        
bTransfer true
    
}else{
        
bTransfer false
        set_task
(3.0,"Transfer_NoAction"0)
    }
}

public 
Event_TeamInfo() {
    
client_print(0print_chat"Success!")
    while (
bTransfer) {
        new 
id read_data(1);
        if (
cs_get_user_team(id)==CS_TEAM_T)
            
cs_set_user_team(idCS_TEAM_CTCS_DONTCHANGE)
        else
            
set_task(3.0,"Transfer_NoAction"0)
    }
}

public 
Transfer_NoAction() {
    
client_print(0print_center"No Action was taken!")
}

public 
Event_TeamCheck() {
    new 
iTs iCTs
    GetTeamCounts
iTs iCTs )
    
client_printprint_chat "Terrorist=%d Counter Terrorist=%d" iTs iCTs )

Pantheon is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 01-07-2011 , 16:10   Re: Plugin doesnt register event.
Reply With Quote #8

That's because at roundstart you set the bool true, but you don't use it until a player changes team.
The code only sets the player to CS_TEAM_T if there is more then 1 terrorist at the moment a player switches team.

What you need to do is make a new function that holds the code to change a player's team.
And at roundstart and the TeamInfo event check if there is more then 1 T, if so call the function.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Pantheon
Member
Join Date: Jan 2011
Old 01-07-2011 , 16:17   Re: Plugin doesnt register event.
Reply With Quote #9

Quote:
Originally Posted by drekes View Post
That's because at roundstart you set the bool true, but you don't use it until a player changes team.
The code only sets the player to CS_TEAM_T if there is more then 1 terrorist at the moment a player switches team.

What you need to do is make a new function that holds the code to change a player's team.
And at roundstart and the TeamInfo event check if there is more then 1 T, if so call the function.
Im sorry to seem a little slow, but i have a easier time learning with examples.

So if you please..
Pantheon is offline
Pantheon
Member
Join Date: Jan 2011
Old 01-07-2011 , 18:39   Re: Plugin doesnt register event.
Reply With Quote #10

Nevermind, fixed it.

Thanks for all your support!
Pantheon 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 08:06.


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