AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   executing code in wrong order (https://forums.alliedmods.net/showthread.php?t=6484)

karlos 10-04-2004 03:08

executing code in wrong order
 
i have the following code (Natural-Selection)
Code:
public pugin_init(){     register_logevent("createcc",1) } public createcc(){     new i     ccindex[0] = 0     ccindex[1] = 0     ccindex[2] = 0     ccindex[3] = 0     // code part a     for ( i = 1; i <= ns_get_build("team_command",1,0); i++){         ccindex[pev(ns_get_build("team_command",1,i),pev_team)] = ns_get_build("team_command",1,i)     }     if (!ccindex[2]){         remove_entity(ccindex[2])     }         // code part b     pev(ccindex[3],pev_origin,cclocation)     entity_set_origin(ccindex[3],cclocation)     new Float:temporigin[3]={9999.9,9999.9,9999.9}     entity_set_origin(ccindex[3],temporigin)         ccindex[2] = create_entity("team_command")     spawn(ccindex[2])     copy_pev(ccindex[3],ccindex[2])     set_pev(ccindex[2],pev_team,2)     entity_set_origin(ccindex[2],cclocation) }
the problem is now that code part b is executed before code part a, but only when server loads (server start/mapchange plugin gets initialized)
than it works normal
why is it so?

fsfod 10-04-2004 10:08

ah mansawe's mvm fix script

maybe if you checked how many times it was called

Code:

L 10/04/2004 - 14:58:12: -------- Mapchange --------
[AMXX] Loaded 1 admin from file
L 10/04/2004 - 14:58:13: [mvm.amxx] enter initializecc
L 10/04/2004 - 14:58:13: [mvm.amxx] enter createcc
L 10/04/2004 - 14:58:13: [mvm.amxx] enter createcc
Executing AMX Mod X Configuration File
Scrolling message displaying frequency: 10:00 minutes
L 10/04/2004 - 14:58:13: [mvm.amxx] enter createcc
No auth servers parsed
Disabling Valve Authentication.
Adding master server 207.173.177.11:27010
Adding master server 69.28.151.178:27010
restart
L 10/04/2004 - 15:01:50: -------- Mapchange --------
[AMXX] Loaded 1 admin from file
L 10/04/2004 - 15:01:50: [mvm.amxx] enter initializecc
L 10/04/2004 - 15:01:50: [mvm.amxx] enter createcc
L 10/04/2004 - 15:01:50: [mvm.amxx] enter createcc
Executing AMX Mod X Configuration File
Scrolling message displaying frequency: 10:00 minutes


karlos 10-04-2004 10:17

its only a rip from mansawe's mvm fix
it should not matter how often it is called, cause with amxx 0.16 it worked

fsfod 10-04-2004 11:20

ns_get_build("team_command",1,0)
did you ever think that cc may not be set to built when the map starts up
and there was no ns_get_build in 0.16 or ns module, so this script would not work in amxx 0.16

karlos 10-04-2004 11:45

i fixed it by calling this func lfrom another func

i used ns2amx for 0.16, it has this command (called get_ent(classname[],Value) [ here i used get_ent("team_command",0) ])

also with amx i could use this in plugin_precache()
Code:
if ( is_combat() && ( get_ent("team_command",0) > 1 ) )
with amxx 0.16 and 0.2 only is_combat() works

fsfod 10-04-2004 16:52

i find this works better than "register_logevent("createcc",1)"

Code:

public plugin_log(){
 
  if(!Is_MvM)return

  new szArg1[32]
         
          read_logargv(0,szArg1,31)

        if(equali(szArg1, "Game reset complete.") == 1){
          //log_amx("enter plugin_log with agumanet Game reset complete.")
          createcc()
        }
}



All times are GMT -4. The time now is 17:24.

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