Esempio n. 1
0
        public void LoadStationsEssences()
        {
            DataTable result = API.exported.database.executeQueryWithResult("SELECT * FROM StationsEssences");

            if (result.Rows.Count != 0)
            {
                foreach (DataRow row in result.Rows)
                {
                    StationsEssencesInfo stationobj = new StationsEssencesInfo(Convert.ToInt32(row["ID"]), float.Parse(Convert.ToString(row["PosX"])), float.Parse(Convert.ToString(row["PosY"])), float.Parse(Convert.ToString(row["PosZ"])), Convert.ToInt32(row["Stockage"]), Convert.ToInt32(row["Proprio"]), Convert.ToInt32(row["Argents"]));
                }
            }
        }
Esempio n. 2
0
        //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;
                }
            }
        }