public void spawnvehicule() { DataTable result = API.exported.database.executeQueryWithResult("SELECT * FROM Vehicules"); if (result.Rows.Count != 0) { foreach (DataRow row in result.Rows) { string vposx = Convert.ToString(row["PosX"]); string vposy = Convert.ToString(row["PosY"]); string vposz = Convert.ToString(row["PosZ"]); string vrotx = Convert.ToString(row["RotX"]); string vroty = Convert.ToString(row["RotY"]); string vrotz = Convert.ToString(row["RotZ"]); int model = Convert.ToInt32(row["model"]); int color1 = Convert.ToInt32(row["color1"]); int color2 = Convert.ToInt32(row["color2"]); int vid = Convert.ToInt32(row["ID"]); string plaque = Convert.ToString(row["Plaque"]); Vector3 rotv = new Vector3(float.Parse(vrotx), float.Parse(vroty), float.Parse(vrotz)); Vector3 posv = new Vector3(float.Parse(vposx), float.Parse(vposy), float.Parse(vposz)); if (Convert.ToInt32(row["EnVente"]) == 1) { VehiculeInfo vehicleobj = new VehiculeInfo((VehicleHash)model, posv, rotv, color1, color2, plaque, 0); vehicleobj.Dansgarage = false; vehicleobj.EnVente = true; vehicleobj.PrixVente = Convert.ToInt32(row["PrixVente"]); vehicleobj.handle.invincible = true; vehicleobj.handle.freezePosition = true; vehicleobj.dbid = Convert.ToInt32(row["ID"]); API.setVehicleNumberPlate(vehicleobj.handle, "A VENDRE"); VehiculeInfo.SetVehiculeEssence(vehicleobj, Convert.ToInt32(row["Essence"])); LoadMods(vehicleobj.dbid); } if (Convert.ToBoolean(row["Spawned"]) == true && Convert.ToInt32(row["EnVente"]) == 0) { VehiculeInfo vehicleobj = new VehiculeInfo((VehicleHash)model, posv, rotv, color1, color2, plaque, 0); VehiculeInfo.SetVehiculeEssence(vehicleobj, Convert.ToInt32(row["Essence"])); API.setVehicleEngineStatus(vehicleobj.handle, false); API.setEntityDimension(vehicleobj.handle, Convert.ToInt32(row["Dimension"])); vehicleobj.Dansgarage = Convert.ToBoolean(row["DansGarage"]); vehicleobj.spawned = Convert.ToBoolean(row["Spawned"]); vehicleobj.jobid = Convert.ToInt32(row["jobid"]); vehicleobj.factionid = Convert.ToInt32(row["factionid"]); vehicleobj.IDBDDProprio = Convert.ToInt32(row["Proprio"]); vehicleobj.dbid = Convert.ToInt32(row["ID"]); API.setVehicleLocked(vehicleobj.handle, Convert.ToBoolean(row["Locked"])); vehicleobj.locked = Convert.ToBoolean(row["Locked"]); LoadMods(vehicleobj.dbid); } } } }
public void essence() //Conssomation d'essence -1 toutes les 10sec { API.delay(10000, false, () => { foreach (VehiculeInfo veh in VehiculeInfo.VehiculeList) { if (API.getVehicleEngineStatus(veh.handle)) { VehiculeInfo.SetVehiculeEssence(veh, veh.essence - 1); if (veh.essence <= 0) { API.setVehicleEngineStatus(veh.handle, false); } } } }); }
public void Plein(Client player, String id, int Litres) { int idveh = Int32.Parse(id); PlayerInfo objplayer = PlayerInfo.GetPlayerInfoObject(player); VehiculeInfo objveh = VehiculeInfo.GetVehicleInfoById(idveh); if (player.position.DistanceTo(objveh.handle.position) > 2) { API.sendChatMessageToPlayer(player, Constante.TuEsTropLoin); } else { VehiculeInfo.SetVehiculeEssence(objveh, Litres); API.sendChatMessageToPlayer(player, "Tu viens de mettre ~b~" + Litres + " ~s~dans le réservoir."); var PayeEnAttente = objplayer.pendingpaye; objplayer.pendingpaye = PayeEnAttente + Litres; } }
//event Essence public void ScriptEvent(Client sender, PlayerInfo objplayer, string eventName) { int prixessence = 2; if (eventName == "RefuelKeyPressed") { if (isPumpFuel(sender) && !API.isPlayerInAnyVehicle(sender)) { VehiculeInfo vehobj = VehiculeInfo.GetVehicleCloserPlayer(sender, 5); PompesEssencesInfo pompeobj = PompesEssencesInfo.GetPompeInfoByPos(sender.position); StationsEssencesInfo stationobj = StationsEssencesInfo.GetStationInfoByIDBDD(pompeobj.IDBDD); if (vehobj == null) { API.sendChatMessageToPlayer(sender, "~r~Pas de véhicule près de toi."); return; } if (vehobj.stopessence != true) { if (stationobj.Stockage <= 0) { API.sendChatMessageToPlayer(sender, "~r~La station essence est en pénurie."); vehobj.stopessence = true; API.delay(5000, true, () => { vehobj.stopessence = false; }); return; } if (vehobj.essence != 100) { API.sendChatMessageToPlayer(sender, "~g~Remplissage en cours ...."); VehiculeInfo.SetVehiculeEssence(vehobj, vehobj.essence + 1); objplayer.money = objplayer.money - prixessence; stationobj.Stockage -= 1; API.setTextLabelText(stationobj.textlabel, "Station n°~g~" + stationobj.ID + " ~s~| Stockage :~b~ " + stationobj.Stockage + "~s~L"); stationobj.Argents = stationobj.Argents + prixessence; API.triggerClientEvent(sender, "update_money_display", objplayer.money); return; } else { API.sendChatMessageToPlayer(sender, "~r~Le reservoir du vehicule est plein."); vehobj.stopessence = true; API.delay(5000, true, () => { vehobj.stopessence = false; }); return; } } } } if (eventName == "RefuelKeyReleased") { if (isPumpFuel(sender) && !API.isPlayerInAnyVehicle(sender)) { API.delay(1000, true, () => { API.shared.triggerClientEvent(sender, "stop_update_money"); }); return; } } }