public async void DropPedWeapon() { TriggerEvent("DropPedWeapon"); int waiter = 0; while (CurrentWeaponObject == null) { await NAPI.Task.WaitForMainThread(100); waiter += 100; if (waiter == 5000) { Console.WriteLine("too long awaiting"); return; } } RemoveWeapon(CurrentWeapon); var cmd = new MySqlCommand($"INSERT INTO weapon_objects(wkey, whash, ammo, components, pos_x, pos_y, pos_z) VALUES ('{CurrentWeaponObject.Key}', {CurrentWeaponObject.Hash}, {CurrentWeaponObject.Ammo}, '{NAPI.Util.ToJson(CurrentWeaponObject.Components)}', {CurrentWeaponObject.Pos_X.ToString().Replace(',', '.')}, {CurrentWeaponObject.Pos_Y.ToString().Replace(',', '.')}, {CurrentWeaponObject.Pos_Z.ToString().Replace(',', '.')});", MySQL.connection); cmd.ExecuteNonQuery(); WeaponObjectsList.Add(CurrentWeaponObject); TriggerEventToStreamed(true, "DropPedWeaponSync", null, NAPI.Util.ToJson(CurrentWeaponObject)); NAPI.ClientEvent.TriggerClientEventForAll("AddWeaponObjectToStreamList", NAPI.Util.ToJson(CurrentWeaponObject)); CurrentWeaponObject = null; WeaponInHands = 0; }
public void OnResourceStart() { if (MySQL.Initialize()) { WeaponObject.LoadWeaponObjects(); HouseManager.LoadHouses(); } }