Raised This Month: $32 Target: $400
 8% 

Solved if problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lexzor
Veteran Member
Join Date: Nov 2020
Old 01-30-2021 , 19:56   if problem
Reply With Quote #1

PHP Code:
#include <amxmodx>


#pragma tabsize 0

new my_data_2_store[3]
new 
Restarted

public plugin_init(){
    
register_event "SendAudio""t_win""a""2&%!MRAD_terwin" );
    
register_event "SendAudio""ct_win""a""2&%!MRAD_ctwin" );
    
register_event("HLTV""event_new_round""a""1=0""2=0")
    
register_event("TextMsg""eRestart""a""2&#Game_C""2&#Game_w")
    
set_task(1.0,"CheckPlayers",.flags="b")
}
public 
eRestart(){
    if(
Restarted 2)
    {
    
arrayset(my_data_2_store,0,charsmax(my_data_2_store))
    ++
Restarted
    
}
}
public 
event_new_round()    my_data_2_store[0]++
public 
t_win ( )    my_data_2_store ] ++;
public 
ct_win ( )    my_data_2_store ] ++;
public 
CheckPlayers ( ) {
    
set_dhudmessage 51102153, -1.00.0616.03.0 );
    
show_dhudmessage 0"Round: %s%d"my_data_2_store[0]>9?"":"0",my_data_2_store[0] );
        
    
set_dhudmessage 1562550, -1.00.0916.03.0 );
    
show_dhudmessage 0"T: %s%d         -         CT: %s%d"my_data_2_store[1] > "" "0"my_data_2_store ], my_data_2_store[2] > "" "0"my_data_2_store[2] );

what is wrong here ? if i try with
PHP Code:
if(Restarted 10
it's working but not with 2. i want to call that function 2 times per map: at game commencing and at first server restart.

Last edited by lexzor; 02-03-2021 at 14:07.
lexzor is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-30-2021 , 20:49   Re: if problem
Reply With Quote #2

Hmm that's weird, have you tried:

PHP Code:
if(Restarted++ < 2
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
lexzor
Veteran Member
Join Date: Nov 2020
Old 01-31-2021 , 09:17   Re: if problem
Reply With Quote #3

PHP Code:
#include <amxmodx>


#pragma tabsize 0

new my_data_2_store[3]
new 
Restarted

public plugin_init(){
    
register_event "SendAudio""t_win""a""2&%!MRAD_terwin" );
    
register_event "SendAudio""ct_win""a""2&%!MRAD_ctwin" );
    
register_event("HLTV""event_new_round""a""1=0""2=0")
    
register_event("TextMsg""eRestart""a""2&#Game_C""2&#Game_w")
    
set_task(1.0,"CheckPlayers",.flags="b")
}
public 
eRestart(){
    if(++
Restarted 2)    arrayset(my_data_2_store,0,charsmax(my_data_2_store))
}
public 
event_new_round()    my_data_2_store[0]++
public 
t_win ( )    my_data_2_store ] ++;
public 
ct_win ( )    my_data_2_store ] ++;
public 
CheckPlayers ( ) {
    
set_dhudmessage 51102153, -1.00.0616.03.0 );
    
show_dhudmessage 0"Round: %s%d"my_data_2_store[0]>9?"":"0",my_data_2_store[0] );
        
    
set_dhudmessage 1562550, -1.00.0916.03.0 );
    
show_dhudmessage 0"T: %s%d         -         CT: %s%d"my_data_2_store[1] > "" "0"my_data_2_store ], my_data_2_store[2] > "" "0"my_data_2_store[2] );

same thing..
lexzor is offline
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 01-31-2021 , 10:31   Re: if problem
Reply With Quote #4

Code:
public eRestart(){
    if(Restarted < 2)
    {
        arrayset(my_data_2_store,0,charsmax(my_data_2_store))
        Restarted += 1
    }
}
Try this way then
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-31-2021 , 15:07   Re: if problem
Reply With Quote #5

PHP Code:
if(Restarted 2
-->

PHP Code:
if(Restarted <= 2
__________________

Last edited by Napoleon_be; 01-31-2021 at 15:08.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-31-2021 , 16:21   Re: if problem
Reply With Quote #6

PHP Code:
public eRestart()
{
    if ( ++
Restarted <= 2)
        
arrayset(my_data_2_store,0,charsmax(my_data_2_store))

If this is a string, you can set only the first cell to EOS, being strings are null terminated...instead of using arrayset().
PHP Code:
my_data_2_store] = EOS
If this is an array of values, use sizeof() instead of charsmax().
__________________
Bugsy is online now
lexzor
Veteran Member
Join Date: Nov 2020
Old 02-01-2021 , 07:29   Re: if problem
Reply With Quote #7

PHP Code:
#include <amxmodx>


#pragma tabsize 0

new my_data_2_store[3]
new 
Restarted

public plugin_init(){
    
register_event "SendAudio""t_win""a""2&%!MRAD_terwin" );
    
register_event "SendAudio""ct_win""a""2&%!MRAD_ctwin" );
    
register_event("HLTV""event_new_round""a""1=0""2=0")
    
register_event("TextMsg""eRestart""a""2&#Game_C""2&#Game_w")
    
Restarted 0
    set_task
(1.0,"CheckPlayers",.flags="b")
}
public 
eRestart(){
    if(
Restarted <= 2)
    {
        
my_data_2_store[0] = 1
    my_data_2_store
[1] = 0
    my_data_2_store
[2] = 0
        Restarted 
+= 1
    
}
}
public 
event_new_round()    my_data_2_store[0]++
public 
t_win ( )    my_data_2_store ] ++;
public 
ct_win ( )    my_data_2_store ] ++;
public 
CheckPlayers ( ) {
    
set_dhudmessage 51102153, -1.00.0616.03.0 );
    
show_dhudmessage 0"Round: %s%d"my_data_2_store[0]>9?"":"0",my_data_2_store[0] );
        
    
set_dhudmessage 1562550, -1.00.0916.03.0 );
    
show_dhudmessage 0"T: %s%d         -         CT: %s%d"my_data_2_store[1] > "" "0"my_data_2_store ], my_data_2_store[2] > "" "0"my_data_2_store[2] );

still don't work :-s
lexzor is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 02-01-2021 , 11:23   Re: if problem
Reply With Quote #8

Any of these are correct:
Code:
if ( Restarted < 2 ) {     Restarted++; // Increased AFTER comparison }
Code:
if ( ++Restarted <= 2 ) // Increased BEFORE comparison { }
Code:
if ( Restarted++ < 2 ) // Increased AFTER comparison { }

If they don't work something else is wrong.
Debug it:
Code:
#include <amxmodx> #pragma tabsize 0 new my_data_2_store[3] new Restarted public plugin_init(){     log_amx("plugin_init() called");     register_event ( "SendAudio", "t_win", "a", "2&%!MRAD_terwin" );     register_event ( "SendAudio", "ct_win", "a", "2&%!MRAD_ctwin" );     register_event("HLTV", "event_new_round", "a", "1=0", "2=0");     register_event("TextMsg", "eRestart", "a", "2&#Game_C", "2&#Game_w");     Restarted = 0;     set_task(1.0,"CheckPlayers",.flags="b");     log_amx("plugin_init() end"); } public eRestart(){     log_amx("eRestart() called");     log_amx("Restarted: %d", Restarted);     if ( ++Restarted <= 2 )     {         log_amx("Check passed, setting data");         my_data_2_store[0] = 1         my_data_2_store[1] = 0         my_data_2_store[2] = 0     }     log_amx("eRestart() end"); } public event_new_round() {     log_amx("event_new_round() called");     my_data_2_store[0]++ } public t_win ( ) {     log_amx("t_win() called");     my_data_2_store [ 1 ] ++; } public ct_win ( ) {     log_amx("ct_win() called");     my_data_2_store [ 2 ] ++; } public CheckPlayers ( ) {     set_dhudmessage ( 51, 102, 153, -1.0, 0.06, 1, 6.0, 3.0 );     show_dhudmessage ( 0, "Round: %02d",my_data_2_store[0] );             set_dhudmessage ( 156, 255, 0, -1.0, 0.09, 1, 6.0, 3.0 );     show_dhudmessage ( 0, "T: %02d         -         CT: %02d", my_data_2_store [ 1 ], my_data_2_store[2] ); }
__________________

Last edited by Black Rose; 02-01-2021 at 11:40.
Black Rose is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 02-01-2021 , 11:58   Re: if problem
Reply With Quote #9

actually restarted should be 5. thanks you a lot!
lexzor is offline
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 02-01-2021 , 15:30   Re: if problem
Reply With Quote #10

Quote:
Originally Posted by Black Rose View Post
if ( Restarted < 2 ) { Restarted++; // Increased AFTER comparison }
*After successful comparison.


Quote:
Originally Posted by Black Rose View Post
if ( Restarted++ < 2 ) // Increased AFTER comparison { }

Increased after comparison, successful or not.

Last edited by redivcram; 02-01-2021 at 15:31. Reason: Why is the WYSIWYG so rarted?
redivcram 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 23:08.


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