AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Code not working correctly (https://forums.alliedmods.net/showthread.php?t=221281)

connoisseur 07-20-2013 05:28

Code not working correctly
 
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.

ConnorMcLeod 07-20-2013 05:49

Re: Code not working correctly
 
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.

connoisseur 07-20-2013 06:32

Re: Code not working correctly
 
Quote:

Originally Posted by ConnorMcLeod (Post 1994944)
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 (Post 1994944)
Also, seems that your code is a bit hazardous, you should double check its logic and behavior.

:oops:
I'm new at scripting.
Though other functions are working the way they should.

ConnorMcLeod 07-20-2013 07:47

Re: Code not working correctly
 
for ( new i = 0 ; i < 32 ; i++)

->

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

else you encounter the same problem

connoisseur 07-20-2013 09:42

Re: Code not working correctly
 
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 07-20-2013 09:46

Re: Code not working correctly
 
Quote:

Originally Posted by ConnorMcLeod (Post 1994944)
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.

ConnorMcLeod 07-20-2013 13:30

Re: Code not working correctly
 
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.

connoisseur 07-24-2013 10:23

Re: Code not working correctly
 
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.

ConnorMcLeod 07-24-2013 11:43

Re: Code not working correctly
 
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.

zi443r 07-24-2013 14:34

Re: Code not working correctly
 
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



All times are GMT -4. The time now is 06:20.

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