mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-10 14:44:17 +00:00
implement weapon related requests
This commit is contained in:
parent
4727977207
commit
bfa6e330f3
3 changed files with 57 additions and 3 deletions
|
@ -369,11 +369,11 @@ namespace SanAndreasUnity.Behaviours {
|
|||
this.SetWeaponAtSlot (weaponDef.Id, slot);
|
||||
}
|
||||
|
||||
public void SetWeaponAtSlot (int weaponId, int slotIndex)
|
||||
public Weapon SetWeaponAtSlot (int weaponId, int slotIndex)
|
||||
{
|
||||
NetStatus.ThrowIfNotOnServer();
|
||||
|
||||
Weapon.Create (weaponId, m_ped);
|
||||
return Weapon.Create (weaponId, m_ped);
|
||||
}
|
||||
|
||||
public Weapon GetWeaponAtSlot (int slotIndex)
|
||||
|
|
|
@ -11,10 +11,12 @@ namespace SanAndreasUnity.Net
|
|||
public class PlayerRequests : NetworkBehaviour
|
||||
{
|
||||
Player m_player;
|
||||
Ped m_ped => m_player.OwnedPed;
|
||||
public static PlayerRequests Local { get; private set; }
|
||||
|
||||
float m_timeWhenSpawnedVehicle = 0f;
|
||||
float m_timeWhenChangedPedModel = 0f;
|
||||
float m_timeWhenMadeWeaponRequest = 0f;
|
||||
|
||||
|
||||
|
||||
|
@ -123,6 +125,58 @@ namespace SanAndreasUnity.Net
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#region weapons
|
||||
|
||||
public void AddRandomWeapons() => this.CmdAddRandomWeapons();
|
||||
|
||||
[Command]
|
||||
void CmdAddRandomWeapons()
|
||||
{
|
||||
if (m_ped != null)
|
||||
F.RunExceptionSafe( () => m_ped.WeaponHolder.AddRandomWeapons() );
|
||||
}
|
||||
|
||||
public void RemoveAllWeapons() => this.CmdRemoveAllWeapons();
|
||||
|
||||
[Command]
|
||||
void CmdRemoveAllWeapons()
|
||||
{
|
||||
if (m_ped != null)
|
||||
F.RunExceptionSafe( () => m_ped.WeaponHolder.RemoveAllWeapons() );
|
||||
}
|
||||
|
||||
public void GiveAmmo() => this.CmdGiveAmmo();
|
||||
|
||||
[Command]
|
||||
void CmdGiveAmmo()
|
||||
{
|
||||
if (m_ped != null)
|
||||
{
|
||||
F.RunExceptionSafe( () => {
|
||||
foreach (var w in m_ped.WeaponHolder.AllWeapons)
|
||||
WeaponHolder.AddRandomAmmoAmountToWeapon(w);
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
public void GiveWeapon(int modelId) => this.CmdGiveWeapon(modelId);
|
||||
|
||||
[Command]
|
||||
void CmdGiveWeapon(int modelId)
|
||||
{
|
||||
if (m_ped != null)
|
||||
{
|
||||
F.RunExceptionSafe( () => {
|
||||
var w = m_ped.WeaponHolder.SetWeaponAtSlot(modelId, 0);
|
||||
m_ped.WeaponHolder.SwitchWeapon(w.SlotIndex);
|
||||
WeaponHolder.AddRandomAmmoAmountToWeapon(w);
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
- port the whole UI to multiplayer
|
||||
|
||||
|
||||
- add option to remove current weapon - for testing
|
||||
- add option to remove current weapon - for testing ; adapt weapons window ;
|
||||
|
||||
- create weapon prefab ; add it to spawnable prefabs list ;
|
||||
|
||||
|
|
Loading…
Reference in a new issue