Script C#

Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Üye
Katılım
28 Nis 2020
Mesajlar
27
Tepki puanı
4
Ödüller
3
Yaş
36
Sosyal
6 HİZMET YILI
Hi i am ahmad bin tahir a 14 year old developer
well i use unity to make games and i have download mfps +addons so it makes easier for me to make my own multiplayer fps games so
:
i want help in these following scripts .....and trying to fix these following errors:
Note:-
Only for unity developers+C# programmers
Errors:-
bl_AutoWeaponFire.cs(45,25): error CS0117: 'bl_EventHandler' does not contain a definition for 'OnLocalPlayerSpawn'
bl_AutoWeaponFire.cs(46,25): error CS0117: 'bl_EventHandler' does not contain a definition for 'OnLocalPlayerDeath'
bl_AutoWeaponFire.cs(48,48): error CS1061: 'bl_GameManager' does not contain a definition for 'OurPlayer' and no accessible extension method 'OurPlayer' accepting a first argument of type 'bl_GameManager' could be found (are you missing a using directive or an assembly reference?)
bl_AutoWeaponFire.cs(50,40): error CS1061: 'bl_GameManager' does not contain a definition for 'OurPlayer' and no accessible extension method 'OurPlayer' accepting a first argument of type 'bl_GameManager' could be found (are you missing a using directive or an assembly reference?)
\bl_AutoWeaponFire.cs(59,25): error CS0117: 'bl_EventHandler' does not contain a definition for 'OnLocalPlayerSpawn'
bl_AutoWeaponFire.cs(60,25): error CS0117: 'bl_EventHandler' does not contain a definition for 'OnLocalPlayerDeath'
bl_AutoWeaponFire.cs(69,36): error CS1061: 'bl_GameManager' does not contain a definition for 'OurPlayer' and no accessible extension method 'OurPlayer' accepting a first argument of type 'bl_GameManager' could be found (are you missing a using directive or an assembly reference?
bl_AutoWeaponFire.cs(108,46): error CS1061: 'bl_PlayerSettings' does not contain a definition for 'm_Team' and no accessible extension method 'm_Team' accepting a first argument of type 'bl_PlayerSettings' could be found (are you missing a using directive or an assembly reference?)
Note:-
All the errors are because of these commands:- OnLocalPlayerSpawn,OnLocalPlayerDeath,and OurPlayer so what should i use instead of these commands:??



Here is the script:- bl_AutoWeaponFire.cs
Scripts:-
Kod:
 title="bl_AutoWeaponFire.cs" highlight="45,46,48,50,59,60,69,108"]using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Photon.Pun;
using Photon.Realtime;

public class bl_AutoWeaponFire : bl_PhotonHelper
{
    public float WaitToFireTime = 1;
    public float ViewRange = 50;
    [Range(1, 7)] public float SniperRangeMultiplier = 3;

    [Header("References")]
    [SerializeField] private GameObject BarUI;
    [SerializeField] private Image BarImage;

    private Camera PlayerCamera;
    private RaycastHit Ray;
    private bool HitSome = false;
    private float waitTime = 0;
    private bl_GameManager GameManager;
    private bl_GunInfo ActualGun;
    private float LastOverTime = 0;
    /// <summary>
    ///
    /// </summary>
    private void Awake()
    {
        GameManager = FindObjectOfType<bl_GameManager>();
#if MFPSM
        if (!bl_GameData.Instance.AutoWeaponFire)
        {
            this.enabled = false;
        }
#endif
        BarUI.SetActive(false);
    }

    /// <summary>
    ///
    /// </summary>
    private void OnEnable()
    {
        bl_EventHandler.OnLocalPlayerSpawn += OnLocalSpawn;
        bl_EventHandler.OnLocalPlayerDeath += OnLocalDeath;
        bl_EventHandler.OnChangeWeapon += OnChangeWeapon;
        if(PlayerCamera == null && GameManager.OurPlayer != null)
        {
            PlayerCamera = GameManager.OurPlayer.GetComponent<bl_PlayerSettings>().PlayerCamera;
        }
    }

    /// <summary>
    ///
    /// </summary>
    private void OnDisable()
    {
        bl_EventHandler.OnLocalPlayerSpawn -= OnLocalSpawn;
        bl_EventHandler.OnLocalPlayerDeath -= OnLocalDeath;
        bl_EventHandler.OnChangeWeapon -= OnChangeWeapon;
    }

    /// <summary>
    ///
    /// </summary>
    void OnLocalSpawn()
    {
        PlayerCamera = GameManager.OurPlayer.GetComponent<bl_PlayerSettings>().PlayerCamera;
    }

    /// <summary>
    ///
    /// </summary>
    void OnLocalDeath()
    {
        ResetParamt();
        BarUI.SetActive(false);
    }

    void OnChangeWeapon(int GunID)
    {
        ActualGun = bl_GameData.Instance.GetWeapon(GunID);
    }

    public bool Fire()
    {
        if (PlayerCamera == null)
            return false;

        float range = ViewRange;
        if(ActualGun != null)
        {
            if(ActualGun.Type == GunType.Knife) { range = 3; }
            else if( ActualGun.Type == GunType.Grenade) { return false; }
            else if( ActualGun.Type == GunType.Sniper) { range = ViewRange * SniperRangeMultiplier; }
        }

        Ray r = new Ray(PlayerCamera.transform.position, PlayerCamera.transform.forward);
        Debug.DrawRay(PlayerCamera.transform.position, PlayerCamera.transform.forward * range, Color.yellow);
        if (Physics.Raycast(r, out Ray, range))
        {
            if (Ray.transform.tag == "BodyPart" || Ray.transform.tag == "AI")
            {
                if (GetGameMode != GameMode.FFA)
                {
                    bl_PlayerSettings ps = Ray.transform.root.GetComponent<bl_PlayerSettings>();
                    if (ps != null) { if (ps.m_Team == PhotonNetwork.LocalPlayer.GetPlayerTeam()) { return false; } }
                }

                return OnOverEnemy();
            }
            else
            {
                ResetParamt();
            }
        }
        else
        {
            ResetParamt();
        }
        return false;
    }

    bool OnOverEnemy()
    {
        HitSome = true;
        if (waitTime >= WaitToFireTime)
        {
            BarUI.SetActive(false);
            LastOverTime = Time.time;
            return true;
        }
        else
        {
            waitTime += Time.deltaTime;
            waitTime = Mathf.Clamp(waitTime, 0, WaitToFireTime);
            BarUI.SetActive(true);
            BarImage.fillAmount = waitTime / WaitToFireTime;
            return false;
        }
    }

    void ResetParamt()
    {
        if (HitSome && (Time.time - LastOverTime) > 0.22f)
        {
            HitSome = false;
            BarUI.SetActive(false);
            BarImage.fillAmount = 0;
            waitTime = 0;
        }
    }
}
 
Moderatörün son düzenlenenleri:
BBC
Seçkin Üye
Katılım
2 Mar 2018
Mesajlar
423
Çözümler
1
Tepki puanı
45
Ödüller
4
Yaş
29
8 HİZMET YILI
I couldnt find a solution sorry
 
Onaylı Üye
Katılım
1 Ağu 2017
Mesajlar
132
Tepki puanı
7
Ödüller
6
Yaş
23
8 HİZMET YILI
nice
 
Onaylı Üye
Katılım
31 Ocak 2021
Mesajlar
56
Çözümler
2
Tepki puanı
7
5 HİZMET YILI
Dude, if you're new in c#, don't copypaste complicated things, maked by others.
P.S. if variables not defined, just define them in right place
 
Onaylı Üye
Katılım
29 Eki 2020
Mesajlar
67
Çözümler
3
Tepki puanı
8
Ödüller
1
Yaş
35
5 HİZMET YILI
you didn't end line and it's missing a name or a type.
 
a simple Russian man who helps people
Uzman Üye
Katılım
16 Ağu 2020
Mesajlar
195
Çözümler
2
Tepki puanı
8
Ödüller
5
Yaş
26
5 HİZMET YILI
Sorry bro I can't find a mistake sorry
 
Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...