Raised This Month: $ Target: $400
 0% 

Code not working correctly


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
connoisseur
Senior Member
Join Date: Jan 2012
Old 07-20-2013 , 05:28   Code not working correctly
Reply With Quote #1

Compiles without error (1 warning though, but it works)
Some code taken from Auto Join on Connect by VEN
Spoiler


It seems like set_task in plugin_init isn't working at all.
Also game description doesn't change.

Last edited by connoisseur; 07-28-2013 at 02:15.
connoisseur is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-20-2013 , 05:49   Re: Code not working correctly
Reply With Quote #2

Dunno about game desc, try to see if it's still for other updated servers, code is ok though.

About task, nothing is executed because plugin is throwing an error on line :
Code:
        if( CS_TEAM_T <= cs_get_user_team(i) <= CS_TEAM_CT

Do never loop like this, use get_players to fill an array with connected players indexes, then loop that array.

Also, seems that your code is a bit hazardous, you should double check its logic and behavior.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
connoisseur
Senior Member
Join Date: Jan 2012
Old 07-20-2013 , 06:32   Re: Code not working correctly
Reply With Quote #3

Quote:
Originally Posted by ConnorMcLeod View Post
About task, nothing is executed because plugin is throwing an error on line :
Code:
        if( CS_TEAM_T <= cs_get_user_team(i) <= CS_TEAM_CT

Do never loop like this, use get_players to fill an array with connected players indexes, then loop that array.
Code:
new players[32],num     get_players(players,num,"ch")     for ( new i = 0 ; i < 32 ; i++)         if( CS_TEAM_T <= cs_get_user_team(players[i]) <= CS_TEAM_CT )       //dont start if players already in any team             return PLUGIN_CONTINUE
still not working.
Quote:
Originally Posted by ConnorMcLeod View Post
Also, seems that your code is a bit hazardous, you should double check its logic and behavior.

I'm new at scripting.
Though other functions are working the way they should.
connoisseur is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-20-2013 , 07:47   Re: Code not working correctly
Reply With Quote #4

for ( new i = 0 ; i < 32 ; i++)

->

for ( new i = 0 ; i < num ; i++)

else you encounter the same problem
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
connoisseur
Senior Member
Join Date: Jan 2012
Old 07-20-2013 , 09:42   Re: Code not working correctly
Reply With Quote #5

Nope, still nothing.

This time I tested one thing:
Code:
public create_match() {     client_print(0, print_chat, "create match executed")     if(!get_pcvar_num(g_startcvar))         return PLUGIN_CONTINUE     if( g_qnum < 2 )                        return PLUGIN_CONTINUE     new players[32],num     get_players(players,num,"ch")     for ( new i = 0 ; i < num ; i++)         if( CS_TEAM_T <= cs_get_user_team(players[i]) <= CS_TEAM_CT )       //dont start if players already in any team             return PLUGIN_CONTINUE     cs_set_user_team(g_qid[1], CS_TEAM_CT)                  //put first 2 players in ct and t     cs_set_user_team(g_qid[2], CS_TEAM_T)     g_qnum = g_qnum - 2                         // reduce queue length by 2     client_print(g_qid[1], print_chat, "Live after 1 restart !!")     client_print(g_qid[1], print_chat, "Live after 1 restart !!")     client_print(g_qid[2], print_chat, "Live after 1 restart !!")     client_print(g_qid[2], print_chat, "Live after 1 restart !!")     set_cvar_num("sv_restart", 5)     set_task(5.2,"give_live")     return PLUGIN_HANDLED }
Atleast the first line of the function should get executed right?
But even that not coming in chat.
connoisseur is offline
connoisseur
Senior Member
Join Date: Jan 2012
Old 07-20-2013 , 09:46   Re: Code not working correctly
Reply With Quote #6

Quote:
Originally Posted by ConnorMcLeod View Post
Dunno about game desc, try to see if it's still for other updated servers, code is ok though.
btw I'm testing on my steam dedicated server, so that's up to date I guess.
connoisseur is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-20-2013 , 13:30   Re: Code not working correctly
Reply With Quote #7

Puts debugs (prints or something) at each steps of the function and see where it is exit.

Anyway, i doubt there can be 2 connected players 5 secs after map change.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
connoisseur
Senior Member
Join Date: Jan 2012
Old 07-24-2013 , 10:23   Re: Code not working correctly
Reply With Quote #8

sry for late reply.
Code:
public create_match() {     client_print(0, print_chat, "create match executed")     return PLUGIN_HANDLED }

Just for testing I removed all the matter out of that function except the printing, and it still won't print.
I don't have any idea why its not working when there is no error while compiling.
Please help.
connoisseur is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-24-2013 , 11:43   Re: Code not working correctly
Reply With Quote #9

Add something like this :

PHP Code:
log_amx("create_match CALLED, connected players %d, connecting %d"get_playersnum(), get_playersnum(1)-get_playersnum()); 
And then open amxx logs.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
zi443r
Senior Member
Join Date: Mar 2009
Location: Braila,Romania
Old 07-24-2013 , 14:34   Re: Code not working correctly
Reply With Quote #10

PHP Code:
L 07/24/2013 21:29:46: Function "Ev_TeamScore" was not found
L 07
/24/2013 21:29:46: [AMXXDisplaying debug trace (plugin "match.amxx")
L 07/24/2013 21:29:46: [AMXXRun time error 19: function not found 
L 07
/24/2013 21:29:46: [AMXX]    [0match.sma::plugin_init (line 35
__________________
zi443r is offline
Reply


Thread Tools
Display Modes

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 06:20.


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