Hi Guys;

I'm working on a plugin that allows making turrets using guns from players inventory. Unfortunately I got stuck at Firing bullets.

The way it's done is using RPC message and not by spawning entities like in the case of rockets (there is no bullet prefab or at least not entity prefab). 

Could someone please explain how the RPC works? I already went trough Unity docs but I did find what I need there.  

This is what I have right now and what I'm playing with:

public void FireBullet(BaseProjectile origin)
            {
                HitInfo info1;
                Vector3 vector1;
                float num;
                Vector3 vector;
                Vector3 vector2;
                Vector3 vector3;
                List<RaycastHit> list;
                int num2;
                RaycastHit hit;
                BaseEntity entity;
                HitInfo info;
                num = 10f;
                vector = origin.MuzzlePoint.transform.forward;
                vector2 = AimConeUtil.GetModifiedAimConeDirection((float)origin.aimCone, vector, true);
                vector1 = origin.MuzzlePoint.transform.position - (origin.MuzzlePoint.forward * 0.25f);
                vector3 = vector1 + (vector2 * 300f);
                origin.ClientRPC<Vector3>(null, "FireGun", vector3);
                instance.PrintToChat("origin.ClientRPC<Vector3>(null,FireGun, vector3)");
                list = Pool.GetList<RaycastHit>();
                GamePhysics.TraceAll(new Ray(vector1, vector2), 0.1f, list, 300f, 0x48b32b11, 0);
                num2 = 0;
                goto Label_016C;
            Label_009B:
                hit = list[num2];
                entity = RaycastHitEx.GetEntity(hit);
                if ((entity != null) == null)
                {
                    goto Label_00D3;
                }
                if ((entity == this) != null)
                {
                    goto Label_0166;
                }
                if (entity.EqualNetID(origin) != null)
                {
                    goto Label_0166;
                }
            Label_00D3:
                if (((entity as BaseCombatEntity) != null) == null)
                {
                    goto Label_014A;
                }
                info = new HitInfo(origin, entity, DamageType.Bullet, num, hit.point);
                entity.OnAttacked(info);
                if ((entity as BasePlayer) != null)
                {
                    goto Label_0111;
                }
                if ((entity as BaseNpc) == null)
                {
                    goto Label_014A;
                }
            Label_0111:
                info1 = new HitInfo();
                info1.HitPositionWorld = hit.point;
                info1.HitNormalWorld = -hit.normal;
                info1.HitMaterial = StringPool.Get("Flesh");
                Effect.server.ImpactEffect(info1);
            Label_014A:
                if ((entity != null) == null)
                {
                    goto Label_015D;
                }
                if (entity.ShouldBlockProjectiles() == null)
                {
                    goto Label_0166;
                }
            Label_015D:
                vector3 = hit.point;
                return;
            Label_0166:
                num2 += 1;
            Label_016C:
                if (num2 < list.Count)
                {
                    goto Label_009B;
                }
                return;
            }