Shadowflamez@Posted: Tue Sep 29, 2009 7:16 pm :
Is it possible to store player's information and restore it in for later time?And how I do it?Most of the functions are working only for the current map,when I change the level whit the console for an example (serverNextMap,servermaprestart...etc)
the variables are reseting to default again.I have tried to use this:
Code:
void idPlayer::SavePersistantInfo( void ) {
   idDict &playerInfo = gameLocal.persistentPlayerInfo[entityNumber];

   playerInfo.Clear();
   inventory.GetPersistantData( playerInfo );
   
   
   playerInfo.SetInt( "health", health );
   playerInfo.SetInt( "current_weapon", currentWeapon );                                               
   playerInfo.SetInt("inventory_weapons",inventory.weapons); //Added by me

  void idPlayer::RestorePersistantInfo( void ) {
   if ( gameLocal.isMultiplayer ) {
      gameLocal.persistentPlayerInfo[entityNumber].Clear();
   

   spawnArgs.Copy( gameLocal.persistentPlayerInfo[entityNumber] );
   }
   
   inventory.RestoreInventory( this, spawnArgs );
   health = spawnArgs.GetInt( "health", "100" );
   if ( gameLocal.isMultiplayer ) {
    idealWeapon = spawnArgs.GetInt( "current_weapon", "0" );
    inventory.weapons =  spawnArgs.GetInt("inventory_weapons","0") //Added by me
        
      
      
   }
}
   

When the mp game begins "idiealWeapon" eguals to current weapon that means the blaster_pistol.
I have tried to save the inventory weapons and load the again for the next level but nothing hapens.When I change the zero after "inventory_weapons" whit random number from 1 to 9 I'm recieving weapons from 1 to 9 every time even in the first game.Zero must be the default value (if I'm correct) like "current weapon" line.And this have to bring me all weapons in previous player persistant Info.But the game give them to me right now (I mean when the player spawns in the fist game).

I have another code that brings me current weapons after respawn but only for the current level.

Code:
   

            if ( health <= 0 ) {         
   
                      carryOverCurrentWeapon = currentWeapon;
            inventory.carryOverWeapons = inventory.weapons;
   }


        if( gameLocal.isMultiplayer )
   {
      // restore previous weapons
      inventory.weapons |= inventory.carryOverWeapons & CARRYOVER_WEAPONS_MASK;
      for( int weaponIndex = 0; weaponIndex < MAX_WEAPONS; weaponIndex++ )
      {
         if( inventory.weapons & ( 1 << weaponIndex ) )
         {
            int ammoIndex   = inventory.AmmoIndexForWeaponIndex( weaponIndex );
            inventory.ammo[ ammoIndex ] = inventory.StartingAmmoForWeaponIndex( weaponIndex );
                inventory.ammo[ ammoIndex ] *= 2;
         // Get the power weapons away when reborn
            
         }
         
      }


Looks like inventory.carryOverWeapons = 0; after level change.

Thanks.



Ivan_the_B@Posted: Wed Sep 30, 2009 9:03 am :
I did the same thing in D3 and it always worked.

Store data in idPlayer::SavePersistantInfo, restore in idPlayer::RestorePersistantInfo.

The problem could be in this piece of your code:

Quote:
void idPlayer::RestorePersistantInfo( void ) {
if ( gameLocal.isMultiplayer ) {
gameLocal.persistentPlayerInfo[entityNumber].Clear(); //<-- playerInfo is cleared if multiplayer!
//...
}

//...

if ( gameLocal.isMultiplayer ) {
//your stuff //<-- and seem like your mod is multiplayer!
}
}



Shadowflamez@Posted: Wed Sep 30, 2009 8:08 pm :
That's sound logical.But I hit another grid.I can't test it because I have to do some other changes.I can't load next maps in multiplayer.Everything is set - the end_level cube and the activating trigger.Only in single player the next game is loaded after I touch the trigger.Perhaps there is something I need to change in player.cpp or gameLocal.cpp or somwhere else.I hope you have done this too already :).I have used commands like "serverNextMap","NextMap",etc... so far but the code maybe working only whit hitting the end level function.



Ivan_the_B@Posted: Fri Oct 02, 2009 8:42 am :
I doubt PersistantInfo are saved if you load a map from console, but I've never touched Q4 SDK.
I'd add a printf in both save/restore methods to check in any case if they were called.



Shadowflamez@Posted: Fri Oct 02, 2009 9:12 am :
I see.Thank you any way :D.However you can say that persistant info works.I thing it will work here too.But some functions are changed in the console commands and they overlaping in multiplayer each other.This target_end_level_function works perfectly - It's displaying me a test message when I touch it.So I have to look at Syscmd... all thinks lead to there...



Shadowflamez@Posted: Sat Oct 03, 2009 9:43 am :
I have done it.Now it works.Looks like the save command dosen't work in multiplayer.So you have to active it manualy :D

Code:
if ( health <= 0 ) {         
                  idPlayer::SavePersistantInfo();
   }



Shadowflamez@Posted: Tue Sep 29, 2009 7:16 pm :
Is it possible to store player's information and restore it in for later time?And how I do it?Most of the functions are working only for the current map,when I change the level whit the console for an example (serverNextMap,servermaprestart...etc)
the variables are reseting to default again.I have tried to use this:
Code:
void idPlayer::SavePersistantInfo( void ) {
   idDict &playerInfo = gameLocal.persistentPlayerInfo[entityNumber];

   playerInfo.Clear();
   inventory.GetPersistantData( playerInfo );
   
   
   playerInfo.SetInt( "health", health );
   playerInfo.SetInt( "current_weapon", currentWeapon );                                               
   playerInfo.SetInt("inventory_weapons",inventory.weapons); //Added by me

  void idPlayer::RestorePersistantInfo( void ) {
   if ( gameLocal.isMultiplayer ) {
      gameLocal.persistentPlayerInfo[entityNumber].Clear();
   

   spawnArgs.Copy( gameLocal.persistentPlayerInfo[entityNumber] );
   }
   
   inventory.RestoreInventory( this, spawnArgs );
   health = spawnArgs.GetInt( "health", "100" );
   if ( gameLocal.isMultiplayer ) {
    idealWeapon = spawnArgs.GetInt( "current_weapon", "0" );
    inventory.weapons =  spawnArgs.GetInt("inventory_weapons","0") //Added by me
        
      
      
   }
}
   

When the mp game begins "idiealWeapon" eguals to current weapon that means the blaster_pistol.
I have tried to save the inventory weapons and load the again for the next level but nothing hapens.When I change the zero after "inventory_weapons" whit random number from 1 to 9 I'm recieving weapons from 1 to 9 every time even in the first game.Zero must be the default value (if I'm correct) like "current weapon" line.And this have to bring me all weapons in previous player persistant Info.But the game give them to me right now (I mean when the player spawns in the fist game).

I have another code that brings me current weapons after respawn but only for the current level.

Code:
   

            if ( health <= 0 ) {         
   
                      carryOverCurrentWeapon = currentWeapon;
            inventory.carryOverWeapons = inventory.weapons;
   }


        if( gameLocal.isMultiplayer )
   {
      // restore previous weapons
      inventory.weapons |= inventory.carryOverWeapons & CARRYOVER_WEAPONS_MASK;
      for( int weaponIndex = 0; weaponIndex < MAX_WEAPONS; weaponIndex++ )
      {
         if( inventory.weapons & ( 1 << weaponIndex ) )
         {
            int ammoIndex   = inventory.AmmoIndexForWeaponIndex( weaponIndex );
            inventory.ammo[ ammoIndex ] = inventory.StartingAmmoForWeaponIndex( weaponIndex );
                inventory.ammo[ ammoIndex ] *= 2;
         // Get the power weapons away when reborn
            
         }
         
      }


Looks like inventory.carryOverWeapons = 0; after level change.

Thanks.



Ivan_the_B@Posted: Wed Sep 30, 2009 9:03 am :
I did the same thing in D3 and it always worked.

Store data in idPlayer::SavePersistantInfo, restore in idPlayer::RestorePersistantInfo.

The problem could be in this piece of your code:

Quote:
void idPlayer::RestorePersistantInfo( void ) {
if ( gameLocal.isMultiplayer ) {
gameLocal.persistentPlayerInfo[entityNumber].Clear(); //<-- playerInfo is cleared if multiplayer!
//...
}

//...

if ( gameLocal.isMultiplayer ) {
//your stuff //<-- and seem like your mod is multiplayer!
}
}



Shadowflamez@Posted: Wed Sep 30, 2009 8:08 pm :
That's sound logical.But I hit another grid.I can't test it because I have to do some other changes.I can't load next maps in multiplayer.Everything is set - the end_level cube and the activating trigger.Only in single player the next game is loaded after I touch the trigger.Perhaps there is something I need to change in player.cpp or gameLocal.cpp or somwhere else.I hope you have done this too already :).I have used commands like "serverNextMap","NextMap",etc... so far but the code maybe working only whit hitting the end level function.



Ivan_the_B@Posted: Fri Oct 02, 2009 8:42 am :
I doubt PersistantInfo are saved if you load a map from console, but I've never touched Q4 SDK.
I'd add a printf in both save/restore methods to check in any case if they were called.



Shadowflamez@Posted: Fri Oct 02, 2009 9:12 am :
I see.Thank you any way :D.However you can say that persistant info works.I thing it will work here too.But some functions are changed in the console commands and they overlaping in multiplayer each other.This target_end_level_function works perfectly - It's displaying me a test message when I touch it.So I have to look at Syscmd... all thinks lead to there...



Shadowflamez@Posted: Sat Oct 03, 2009 9:43 am :
I have done it.Now it works.Looks like the save command dosen't work in multiplayer.So you have to active it manualy :D

Code:
if ( health <= 0 ) {         
                  idPlayer::SavePersistantInfo();
   }



Shadowflamez@Posted: Tue Sep 29, 2009 7:16 pm :
Is it possible to store player's information and restore it in for later time?And how I do it?Most of the functions are working only for the current map,when I change the level whit the console for an example (serverNextMap,servermaprestart...etc)
the variables are reseting to default again.I have tried to use this:
Code:
void idPlayer::SavePersistantInfo( void ) {
   idDict &playerInfo = gameLocal.persistentPlayerInfo[entityNumber];

   playerInfo.Clear();
   inventory.GetPersistantData( playerInfo );
   
   
   playerInfo.SetInt( "health", health );
   playerInfo.SetInt( "current_weapon", currentWeapon );                                               
   playerInfo.SetInt("inventory_weapons",inventory.weapons); //Added by me

  void idPlayer::RestorePersistantInfo( void ) {
   if ( gameLocal.isMultiplayer ) {
      gameLocal.persistentPlayerInfo[entityNumber].Clear();
   

   spawnArgs.Copy( gameLocal.persistentPlayerInfo[entityNumber] );
   }
   
   inventory.RestoreInventory( this, spawnArgs );
   health = spawnArgs.GetInt( "health", "100" );
   if ( gameLocal.isMultiplayer ) {
    idealWeapon = spawnArgs.GetInt( "current_weapon", "0" );
    inventory.weapons =  spawnArgs.GetInt("inventory_weapons","0") //Added by me
        
      
      
   }
}
   

When the mp game begins "idiealWeapon" eguals to current weapon that means the blaster_pistol.
I have tried to save the inventory weapons and load the again for the next level but nothing hapens.When I change the zero after "inventory_weapons" whit random number from 1 to 9 I'm recieving weapons from 1 to 9 every time even in the first game.Zero must be the default value (if I'm correct) like "current weapon" line.And this have to bring me all weapons in previous player persistant Info.But the game give them to me right now (I mean when the player spawns in the fist game).

I have another code that brings me current weapons after respawn but only for the current level.

Code:
   

            if ( health <= 0 ) {         
   
                      carryOverCurrentWeapon = currentWeapon;
            inventory.carryOverWeapons = inventory.weapons;
   }


        if( gameLocal.isMultiplayer )
   {
      // restore previous weapons
      inventory.weapons |= inventory.carryOverWeapons & CARRYOVER_WEAPONS_MASK;
      for( int weaponIndex = 0; weaponIndex < MAX_WEAPONS; weaponIndex++ )
      {
         if( inventory.weapons & ( 1 << weaponIndex ) )
         {
            int ammoIndex   = inventory.AmmoIndexForWeaponIndex( weaponIndex );
            inventory.ammo[ ammoIndex ] = inventory.StartingAmmoForWeaponIndex( weaponIndex );
                inventory.ammo[ ammoIndex ] *= 2;
         // Get the power weapons away when reborn
            
         }
         
      }


Looks like inventory.carryOverWeapons = 0; after level change.

Thanks.



Ivan_the_B@Posted: Wed Sep 30, 2009 9:03 am :
I did the same thing in D3 and it always worked.

Store data in idPlayer::SavePersistantInfo, restore in idPlayer::RestorePersistantInfo.

The problem could be in this piece of your code:

Quote:
void idPlayer::RestorePersistantInfo( void ) {
if ( gameLocal.isMultiplayer ) {
gameLocal.persistentPlayerInfo[entityNumber].Clear(); //<-- playerInfo is cleared if multiplayer!
//...
}

//...

if ( gameLocal.isMultiplayer ) {
//your stuff //<-- and seem like your mod is multiplayer!
}
}



Shadowflamez@Posted: Wed Sep 30, 2009 8:08 pm :
That's sound logical.But I hit another grid.I can't test it because I have to do some other changes.I can't load next maps in multiplayer.Everything is set - the end_level cube and the activating trigger.Only in single player the next game is loaded after I touch the trigger.Perhaps there is something I need to change in player.cpp or gameLocal.cpp or somwhere else.I hope you have done this too already :).I have used commands like "serverNextMap","NextMap",etc... so far but the code maybe working only whit hitting the end level function.



Ivan_the_B@Posted: Fri Oct 02, 2009 8:42 am :
I doubt PersistantInfo are saved if you load a map from console, but I've never touched Q4 SDK.
I'd add a printf in both save/restore methods to check in any case if they were called.



Shadowflamez@Posted: Fri Oct 02, 2009 9:12 am :
I see.Thank you any way :D.However you can say that persistant info works.I thing it will work here too.But some functions are changed in the console commands and they overlaping in multiplayer each other.This target_end_level_function works perfectly - It's displaying me a test message when I touch it.So I have to look at Syscmd... all thinks lead to there...



Shadowflamez@Posted: Sat Oct 03, 2009 9:43 am :
I have done it.Now it works.Looks like the save command dosen't work in multiplayer.So you have to active it manualy :D

Code:
if ( health <= 0 ) {         
                  idPlayer::SavePersistantInfo();
   }