Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tutorial How to use variables as long as server runs
#1
Well basically you can edit globallogic to change all the exitlevel(false) to exitlevel(true). But that has one drawback; it keeps all the persistent variables ( like score, kills and deaths ). Therefore i made this function to delete all the unnecessary game[] and self.pers[] variables:
Code:
DeletePersistentExceptSome()
{
    gamepers = getArrayKeys( game );
    for(i=0;i<gamepers.size;i++)
        if( gamepers[i] != "pers" )
            game[gamepers[i]] = undefined;
    if( isdefined( level.players ))
    {
        for(i=0;i<level.players.size;i++)
        {
            /* //Doesn't work properly. Looks like you can't do it the same way as on game[].
            playerpers = getArrayKeys( level.players[i].pers );
            for(x=0;x<playerpers.size;x++)
                if( playerpers[x] != "pers" )
                    level.players[i].pers[playerpers[x]] = undefined;
            */
            
            //It works like this though:
            //put here the self.pers[] vars you want to delete.
            level.players[i].pers["team"] = undefined;
            level.players[i].pers["kills"] = undefined;
            level.players[i].pers["assists"] = undefined;
            level.players[i].pers["deaths"] = undefined;
            level.players[i].pers["score"] = undefined;
            level.players[i].pers["weapon"] = undefined;
            level.players[i].pers["savedmodel"] = undefined;
            level.players[i].pers["primary"] = undefined;
            level.players[i].pers["weapon"] = undefined;
            level.players[i].pers["guidid"] = undefined;
            level.players[i].pers["CheckedSame"] = undefined;
        }
    }
}
So just change all te exitlevel(false) to exitlevel(true) and do this function before the exitlevel. Like this:
Code:
DeletePersistentExceptSome();
exitlevel(true);
Now you can use game["pers"] & self.pers[ (the ones you didn't undefine) ] for as long as the server is running.
Reply

#2
Good job, Cool
Reply

#3
(08-28-2011, 15:26)Justin Wrote:
Code:
DeletePersistentExceptSome();
exitlevel(true);
Right?
Reply

#4
(08-28-2011, 16:20)SuperNovaAO Wrote:
(08-28-2011, 15:26)Justin Wrote:
Code:
DeletePersistentExceptSome();
exitlevel(true);
Right?
Yeh, my mistake xD
Reply

#5
lol, Just noticed this. Thanks. Just what i do need in my new mod.
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  [Release] Windows 8.1 Fix for MW3 Server Addon master131 16 18,198 09-29-2014, 23:08
Last Post: SuperNovaAO
Brick [Release] MW3 Server Administration Addon iRoNinja 5 9,013 11-10-2013, 15:46
Last Post: Casper
Exclamation Help cmdlist, dvarlist server crash Nerus 17 11,917 11-09-2013, 23:54
Last Post: Nerus
  Our Level Fastfile is Different from the Server. CheeseToast 6 11,322 11-03-2013, 17:52
Last Post: CheeseToast
  Dedicated Server External (public) IP Nerus 3 5,902 11-02-2013, 14:16
Last Post: Casper
  MW3 Server Version superg1973 7 12,749 10-28-2013, 01:15
Last Post: kotyra972
  Help how to turn off map in dedicated server pero123 8 7,136 10-15-2013, 19:00
Last Post: Nekochan
  Issue with server addon and NAT dimitrifrom31 3 5,084 10-08-2013, 18:11
Last Post: iRoNinja
  GETTING SERVER ONLINE raym 6 5,716 09-28-2013, 22:42
Last Post: Nekochan
  advanced Server Config Poorya56 9 7,019 09-11-2013, 03:45
Last Post: trasto

Forum Jump:


Users browsing this thread:
2 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.