Problem| 2 problems with damage script

hello!
so…
i have two problems with the damage script that i’m trying to make…
the first problem:
when i shooting on my friend, he got hitted, and is health is getting down, BUT, when he shooting on me, nothing happed, my health stay the same (100)… :\

the second problem:
when the health of my friend is set to 0, he should destroy, instead of that, I DESTROY, BUT, he should destroy, not me, i killed him in the game, and i got destroy!
WHY?

please help me guy’s.

Most probably because your network logic is faulty. Who owns the objects ?

i am
i mean, i didn’t made any networkview.ismine code… do i need to do that?
if i need to do that, where should i put it?

This is my hole damage script (it’s attached to the “trigger” game oject that placed in the player prefab:

using UnityEngine;
using System.Collections;

public class HealthAndDamages : Photon.MonoBehaviour {
public float maxDist = 1000000000;

public float floatInFrontOfWall = 0.00001f;
public float health = 100;
public float attackPower;


	
	void OnCollisionEnter(Collision other)
	{
			if ((other.transform.tag == "bullet"))
	    		Debug.Log("bullet");
				attackPower = 25;
				gameObject.SendMessage("ApplyDamage", attackPower, SendMessageOptions.DontRequireReceiver);
	}
	
	void ApplyDamage (float attackPower)
	{
	    health -= attackPower;
	    if (health < 0) 
	    {
			Debug.Log("die");
	                Die(); 
	    } 
	    else 
		{
			Debug.Log("hurt");
	    }
	}
		
	void  Die ()
	{
		Debug.Log("dead");
		PhotonNetwork.LeaveRoom();
	}
}

Instead of having us do the debugging, have you done any ? What errors are you getting ? And again, who is the owner of the networkview ?

i have no errors…
and i don’t have networkview.ismine, as i told you before…

UP.

Up.

I shouldn’t be answering this anymore since you clearly show no effort at all in learning or even understanding.
But… what does the command networkView.isMine actually do ?
Have you looked it up ? Do you think it could help you ?

i don’t know, and because that reason, i asking you for some help O_O…
so please just help, i even posted the hole script!
i can’t get why it’s not working…
i really want to learn how to do that!

Unity has done a great job in documenting the commands. If you don’t know what a command does, you should look it up and read about it. ( like we all do )
Hence the ‘no effort’ comment.

Why are you so bad and mean O_O!? What I’ve done to you?
i just Asked for explain what I did wrong and for explain how to solve the problem …
that’s it, so please don’t speak to me like that, if you don’t want to help that’s okay, but stop talking like that …

If you are using Photon Networking, then you need to use an RPC call to send damage.

You should post in the Photon Network forums, you’ll get more/better info there:
http://forum.exitgames.com/viewforum.php?f=17&sid=e8e89c36c99ef86c75955f1af4634185

i think i did that, no?

this is what you talking about?

I THINK I GET IT!:

using UnityEngine;
using System.Collections;

[RequireComponent (typeof(PhotonView))]
[RequireComponent (typeof(Rigidbody))]
public class HealthAndDamagess : MonoBehaviour {
   
   public float health = 100;
   public PhotonView photonView;
   public PhotonViewID photonViewID;
	
	public float dmg;
   
   void Start () {
      photonView = PhotonView.Get(this);
      photonViewID = photonView.viewID;
      Debug.Log("My view ID is: " + photonViewID);
   }
   
	void OnCollisionEnter(Collision other)
	{
			if ((other.transform.tag == "bullet"))
			{
	    		Debug.Log("bullet");
				dmg = 25;
				photonView.RPC("Damage", PhotonTargets.AllBuffered, dmg); 
			}
	}
	
   	[RPC]
   	void Damage(float dmg, PhotonViewID target, PhotonMessageInfo info) 
	{
      	Debug.Log ("RPC Recieved");
      	if (target == this.photonViewID) 
		{
	         Debug.Log("Did damage to ID: " + target);
	         health -= dmg;
		    if (health <= 0)
			{
				Debug.Log("die");
	            KillDestructible();
			}
			else 
			{
				Debug.Log("hurt");
		    }
      	}
   }
   
   public void Hit(float dmg, PhotonViewID target) 
	{
      photonView.RPC("Damage",PhotonTargets.All, dmg, target);
   }
   
   void KillDestructible() 
	{
      PhotonNetwork.Destroy(photonView);
   }
}

this is the script that i’m using right now!
but i getting this error:

from this line:

I replied in our forum:
http://forum.exitgames.com/viewtopic.php?f=17&t=2130

TNX, and i posted back, please answer :).

i got another problem,
the problem is that i able to kill my friend (from the editor), but he cannot kill me in the game (he using exe file of the game).
for more information:
http://forum.exitgames.com/viewtopic.php?f=17&t=2130

how you can’t help me?!
i giving you my hole script…
do you want pictures of my inspector or something?

using UnityEngine;
using System.Collections;

[RequireComponent (typeof(PhotonView))]
[RequireComponent (typeof(Rigidbody))]
public class HealthAndDamagess : MonoBehaviour {
   
   public float health = 100;
   public PhotonView photonView;
   public PhotonViewID photonViewID;
	
	public float dmg;
	
	public Transform playerPrefab;
   
   void Start () {
      photonView = PhotonView.Get(this);
      photonViewID = photonView.viewID;
      Debug.Log("My view ID is: " + photonViewID);
   }
   
	void OnCollisionEnter(Collision other)
	{
			if ((other.transform.tag == "bullet"))
			{
	    		Debug.Log("bullet");
				dmg = 25;
				photonView.RPC("Damage", PhotonTargets.AllBuffered, dmg); 
			}
	}
	
   	[RPC]
   	void Damage(float dmg, PhotonMessageInfo info) 
	{
      		Debug.Log ("RPC Recieved");
	         health -= dmg;
		    if (health <= 0)
			{
				Debug.Log("die");
	            KillDestructible();
			}
			else 
			{
				Debug.Log("hurt");
		    }
   }
   
   public void Hit(float dmg, PhotonViewID target) 
	{
      photonView.RPC("Damage",PhotonTargets.All, dmg, target);
   }
   
   void KillDestructible() 
	{
      PhotonNetwork.Destroy(photonView);
		//PhotonNetwork.LeaveRoom();
	  //PhotonNetwork.Destroy(this.gameObject);
		//OnGUI();
   }
}

I did it!
i made health and damage script!
but how can i do a respawn system?