Raised This Month: $ Target: $400
 0% 

[HELP] infinite loop due to invalid value


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
HLM
Senior Member
Join Date: Apr 2008
Location: C:\WINDOWS\System32
Old 09-30-2009 , 14:53   [HELP] infinite loop due to invalid value
Reply With Quote #1

PHP Code:
public hook_KeyValue(entIdkvd_id)
{
    
server_print("[MedicMod] keyvalue has been hooked.. entity hooked is ^"%d^"",entId)
    new 
maxteams 0
    
if(!pev_valid(entId))
        return 
FMRES_HANDLED;
    
    new 
className[64];
    
pev(entIdpev_classnameclassName63);
    
    if(
containi(className"info_tfdetect") != -&& !tfdetectMade)
    {
        while (
maxteams != || maxteams != || maxteams != || maxteams != 4)
        {
            
get_keyvalue(entId"number_of_teams"szValuesizeof(szValue)-1)
            
maxteams str_to_num(szValue)
            
server_print("[MedicMod] Looping to get maxteams : %d"szValue)
            
        }
        
        
server_print("[MedicMod] About to remove entity, maxteams = ^"%d^"",maxteams)
        
engfunc(EngFunc_RemoveEntityentId);
        
        if(!
tfdetectMade)
        {
            switch(
maxteams)
            {
                case 
1:
                {
                    new 
entFloat:entOrg[3];
                    
tfdetectMade true;
                    
                    
// Make the new tfdetect entity
                    
ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_tfdetect"));
                    
engfunc(EngFunc_SetOriginententOrg);
                    
engfunc(EngFunc_SetSizeentFloat:{-1.0,-1.0,-1.0}, Float:{1.0,1.0,1.0});
                    
set_pev(entpev_classname"info_tfdetect");
                    
set_pev(entpev_solidSOLID_NOT);
                    
set_pev(entpev_movetypeMOVETYPE_FLY);
                    
                    
// Add the keys and values to the entity
                    
set_keyvalue(ent"number_of_teams""1");
                    
set_keyvalue(ent"team1_name""Team L33T!");
                    
//set_keyvalue(ent, "team2_name", "Team pWn0rs!");
                    //set_keyvalue(ent, "team3_name", "Team h4wt!");
                    //set_keyvalue(ent, "team4_name", "Team sm3xi!");
                    
set_keyvalue(ent"toggleflags""0");
                    
set_keyvalue(ent"maxammo_shells""1007");
                    
//set_keyvalue(ent, "maxammo_nails", "1007");
                    //set_keyvalue(ent, "maxammo_rockets", "1007");
                    //set_keyvalue(ent, "maxammo_cells", "1007");
                    
set_keyvalue(ent"team1_allies""0");
                    
//set_keyvalue(ent, "team2_allies", "0");
                    //set_keyvalue(ent, "team3_allies", "0");
                    //set_keyvalue(ent, "team4_allies", "0");
                
}
                case 
2:
                {
                    new 
entFloat:entOrg[3];
                    
tfdetectMade true;
                    
                    
// Make the new tfdetect entity
                    
ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_tfdetect"));
                    
engfunc(EngFunc_SetOriginententOrg);
                    
engfunc(EngFunc_SetSizeentFloat:{-1.0,-1.0,-1.0}, Float:{1.0,1.0,1.0});
                    
set_pev(entpev_classname"info_tfdetect");
                    
set_pev(entpev_solidSOLID_NOT);
                    
set_pev(entpev_movetypeMOVETYPE_FLY);
                    
                    
// Add the keys and values to the entity
                    
set_keyvalue(ent"number_of_teams""2");
                    
set_keyvalue(ent"team1_name""Team h4x~!");
                    
set_keyvalue(ent"team2_name""Team pWn0rs!");
                    
//set_keyvalue(ent, "team3_name", "Team h4wt!");
                    //set_keyvalue(ent, "team4_name", "Team sm3xi!");
                    
set_keyvalue(ent"toggleflags""0");
                    
set_keyvalue(ent"maxammo_shells""1007");
                    
set_keyvalue(ent"maxammo_nails""1007");
                    
//set_keyvalue(ent, "maxammo_rockets", "1007");
                    //set_keyvalue(ent, "maxammo_cells", "1007");
                    
set_keyvalue(ent"team1_allies""0");
                    
set_keyvalue(ent"team2_allies""0");
                    
//set_keyvalue(ent, "team3_allies", "0");
                    //set_keyvalue(ent, "team4_allies", "0");    
                
}
                case 
3:
                {
                    
log_amx("maxteams was logged to be %d",szValue)
                    
pause("ad","medicmod-cutsom.amxx")
                }
                case 
4:
                {
                    new 
entFloat:entOrg[3];
                    
tfdetectMade true;
                    
                    
// Make the new tfdetect entity
                    
ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_tfdetect"));
                    
engfunc(EngFunc_SetOriginententOrg);
                    
engfunc(EngFunc_SetSizeentFloat:{-1.0,-1.0,-1.0}, Float:{1.0,1.0,1.0});
                    
set_pev(entpev_classname"info_tfdetect");
                    
set_pev(entpev_solidSOLID_NOT);
                    
set_pev(entpev_movetypeMOVETYPE_FLY);
                    
                    
// Add the keys and values to the entity
                    
set_keyvalue(ent"number_of_teams""4");
                    
set_keyvalue(ent"team1_name""Team h4x~!");
                    
set_keyvalue(ent"team2_name""Team pWn0rs!");
                    
set_keyvalue(ent"team3_name""Team h4wt!");
                    
set_keyvalue(ent"team4_name""Team sm3xi!");
                    
set_keyvalue(ent"toggleflags""0");
                    
set_keyvalue(ent"maxammo_shells""1007");
                    
set_keyvalue(ent"maxammo_nails""1007");
                    
set_keyvalue(ent"maxammo_rockets""1007");
                    
set_keyvalue(ent"maxammo_cells""1007");
                    
set_keyvalue(ent"team1_allies""0");
                    
set_keyvalue(ent"team2_allies""0");
                    
set_keyvalue(ent"team3_allies""0");
                    
set_keyvalue(ent"team4_allies""0");    
                }
                
            }
        }
    }
    return 
FMRES_HANDLED;

it originally wouldnt loop, but now its looping because maxteams ALWAYS equals 0.. anyone know why this might be? I know for a fact it does NOT equal 0.. since maxteams needs to have atleast one team

did I leave anything out?
__________________
+|- KARMA Respectively


Last edited by HLM; 09-30-2009 at 17:46.
HLM is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 09-30-2009 , 18:44   Re: [HELP] infinite loop due to invalid value
Reply With Quote #2

No matter what maxteams equals the loop will never end. It's exactly like this one:
PHP Code:
new a=0
while(!= || != 2)
{
    
a++

Try checking conditions in few iterations and you will understand (if you have basic programming knowledge).
__________________
Impossible is Nothing
Sylwester is offline
HLM
Senior Member
Join Date: Apr 2008
Location: C:\WINDOWS\System32
Old 09-30-2009 , 20:01   Re: [HELP] infinite loop due to invalid value
Reply With Quote #3

not quite sure, I set it to while(maxteams = 0).. I just now noticed it lags the whole datacenter.. I dunno.. anyways im lost =/
__________________
+|- KARMA Respectively

HLM is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 10-01-2009 , 02:40   Re: [HELP] infinite loop due to invalid value
Reply With Quote #4

Maybe you want while(maxteams == 0) ?
Why do you use loop? It looks like it is not necessary there. I don't understand what are you trying to do with this plugin.

Before you continue you should read:
http://forums.alliedmods.net/showthread.php?t=91207
Especially "Part 3 - Conditional Statements".
__________________
Impossible is Nothing
Sylwester is offline
HLM
Senior Member
Join Date: Apr 2008
Location: C:\WINDOWS\System32
Old 10-01-2009 , 15:42   Re: [HELP] infinite loop due to invalid value
Reply With Quote #5

ahh, yes I did, and this code will get the uhh 'maxteams' key and then depending on what the value is, use a switch for when it creates the new entity, this is code from the medicmod plugin..

basically this plugin would originally create one type of entity 'info_tfdetect' that consisted of just two teams.. I want the ability for 1, 2, and 4 teams.. that is why im trying to get this working

edit: what other ways can I get the keyvalue, it seems to be looping with it equaling 0.. doesnt that mean its not getting a value?
__________________
+|- KARMA Respectively


Last edited by HLM; 10-01-2009 at 16:21.
HLM 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 22:39.


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