Different parameters from one file to different players

I got two scenes,
the first one is LOGIN MENU SCENE.

in there user is writing his user name and password, then UserData,js grab his parameters, like last weapon updates from mySQL database and place them in variables in USerData file.

So when user login it has it’s own UserData file with it’s own parameters, for example his bullet power is 3, and bulllet power of other user is 5.

But then GAME SCENE is loaded.
Player1 has bullet power 3
Player2 has bullet power 5, when Player1 shoots Player2, Player2 receive 5 points of damage like is written in HIS file, not like in the file of the shooter.

Could some one give me advice on a way, how to make it works correctly?

So i need one network player to put it’s own parameter in the object he is instantiating (Network.Instantiate, for example bullet) from the Class both players have.

The wrong values are probably being passed, that’s all I can guess without seeing a lot of code.

This is a small part of UserData scrip with user parameters.

class UserData extends Object{

	static var bulletPower: int;
	static var userdata = new Array();		
 

	public function userWeaponData(){
		var URL = "getWeaponData.php";
		var form = new WWWForm(); 
		form.AddField( "email", email );
		var www = new WWW(URL, form);
		yield www; 
		
                var splitString : String = www.text;
		userdata= splitString.Split(";"[0]);
                bulletPower = userdata[1];
	}

Bullet was instantiated like this from another script:

if (weapon.number == 5){
		target = GameObject.Find("sight(Clone)");
		transform.LookAt (target.transform);
		if (Time.time > reloadTime + lastShot  ammoCount > 0) {
			if (Input.GetButtonDown("Fire2")){
					var bullit = Network.Instantiate(bullitPrefab, transform.position, transform.rotation,0);
					lastShot = Time.time;
					ammoCount--;
			}
		}
	}

Then bullet controller that is attached to bullet object has something like

var bulletPower = UserData.bulletPower;
function OnCollisionEnter( collision : Collision ){
	var contact : ContactPoint = collision.contacts[0];
	var rotation = Quaternion.FromToRotation( Vector3.up, contact.normal );
	var instantiatedSpark : GameObject = Instantiate(spark, contact.point, rotation );
	if (collision.rigidbody){
		collision.collider.SendMessage("ApplyDamage", bulletPower ,SendMessageOptions.DontRequireReceiver);
	}
}

and the last one is wrong.

Well, that is some code, isn’t it? It doesn’t look relevant to the damage, does it? Let’s see where the problem is more likely to be.

sorry, accidentally pressed SEND button before message was finished.

Perhaps i need to use RPCs in PlayerControl script to instantiate a bullet and give it a parameters?
With some checks like if(owner==Network.player)?

Can we see the ApplyDamage method?

There is nothing special.
This method can be found in Player Controller script and it looks like:

function ApplyDamage(hitPoints : float){
	if(owner!=null  Network.player==owner)
	ggHealth = ggHealth  - hitPoints;

}

Also i have PlayerSpawn Script that spawns players and has player scripts arrays, perhaps it’s possible to use those arrays some how?

public var playerScripts : ArrayList = new ArrayList();
public var playerDatas : ArrayList = new ArrayList();

function OnPlayerConnected(newPlayer: NetworkPlayer) {
        Spawnplayer(newPlayer);
}      

function Spawnplayer(newPlayer : NetworkPlayer){
      var playerNumber : int = parseInt(newPlayer+"");
      var myNewTrans : Transform = Network.Instantiate(playerPrefab, transform.position, transform.rotation, playerNumber);
      playerScripts.Add(myNewTrans.GetComponent(Ship));
      playerDatas.Add(myNewTrans.GetComponent(UserData));
}

So the problem isn’t that global: i need bullet script to get parameter from player’s script who has fired this bullet.

You said these numbers get goofed when the scene is loaded. Are you you don’t have a bullet power value in your prefab which is just overwriting the values given to the players earlier?

var is static, so it’s impossible. (Perhaps copied wrong version to the post above)

The value of bulletPower is exactly right, but it’s a value from MY UserData, not from UserData of networkView.owner

OK a little bit different question:

Every network player has a Player.js script attached. Player.js has var health
How do i show health variable of one player to the rest of players?

It should be the same way as to give a bullet damage parameter from UserData script of shooter.

I’m honestly stumped on your first question.

You could just RPC out that the health has been updated or serialize it through a network view.

perhaps my whole concept is wrong?

What would you do if you need network players to instantiate objects with different parameters from one file?


How does it work?
player.js has
var health;
and
@RPC
function health(damage: float){
health=health-damage;
}

but then how do i read another player’s health variable from my side?