[POMOC]foreach

Započeo Plen Ki Mun
15. Nov. 2016. Zaključano
773
pregleda
8
postova
Mate
5
Underboss
15. Nov. 2016.
Skripta koju koristim: Moja
Detaljan opis problema: Imam erore a imam definiran foeach itd
Dio skripte:
public MainTimer() 
{
    new string;
    new Float:x, Float:y, Float:z;

    foreach (new i : Player)
    {
        if(IsPlayerConnected(i))
        {
            if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
            {
                new vehicleid = GetPlayerVehicleID(i);
                if(!IsBicycle(vehicleid) && !IsBus(vehicleid) && Fuel > 0)
                {
                    Fuel -= GetPlayerSpeed(i)/1000.0;
                    if(Fuel <= 0)
                    {
                        ToggleEngine(vehicleid, VEHICLE_PARAMS_OFF);
                        GameTextForPlayer(i, "~r~out of fuel", 3000, 3);
                        SendClientMessage(i, COLOR_LIGHTRED, "This vehicle is out of fuel!");
                    }
                }
            }
            if(RefuelTime > 0 && GetPVarInt(i, "FuelStation"))
            {
                new vehicleid = GetPlayerVehicleID(i);
                Fuel += 2.0;
                RefuelTime--;
                if(RefuelTime == 0)
                {
                    if(Fuel >= 100.0) Fuel = 100.0;
                    new stationid = GetPVarInt(i, "FuelStation");
                    new cost = floatround(Fuel-GetPVarFloat(i, "Fuel"))*FUEL_PRICE;
                    if(GetPlayerState(i) != PLAYER_STATE_DRIVER || Fuel >= 100.0 || GetPlayerMoney(i) < cost
                    || !IsPlayerInRangeOfPoint(i, 10.0, FuelStationPos, FuelStationPos, FuelStationPos))
                    {
                        if(GetPlayerMoney(i) < cost) cost = GetPlayerMoney(i);
                        GivePlayerMoney(i, -cost);
                        format(string, sizeof(string), "~r~-$%d", cost);
                        GameTextForPlayer(i, string, 2000, 3);
                        format(string, sizeof(string), "You have paid $%d for the fuel.", cost);
                        SendClientMessage(i, COLOR_WHITE, string);
                        SetPVarInt(i, "FuelStation", 0);
                        SetPVarFloat(i, "Fuel", 0.0);
                    }
                    else
                    {
                        RefuelTime = 5;
                        format(string, sizeof(string), "~w~refueling...~n~~r~-$%d", cost);
                        GameTextForPlayer(i, string, 2000, 3);
                    }
                }
            }
            if(TrackCar)
            {
                GetVehiclePos(TrackCar, x, y, z);
                SetPlayerCheckpoint(i, x, y, z, 3);
            }
        }
    }

(23533) : error 017: undefined symbol "foreach" 
(23533) : error 029: invalid expression, assumed zero
(23533) : error 017: undefined symbol "i"
(23533) : fatal error 107: too many error messages on one line 

new vehicleid = GetPlayerVehicleID(i);  


Neke slike/video za lakse dobivanje pomoci(neobavezno):
KSHM
4
Enforcer
15. Nov. 2016.
#include 
  jesil definisao?
Mate
5
Underboss
15. Nov. 2016.
Da najnoviji sam update!
Nitro
5
Godfather
15. Nov. 2016.
Umesto
foreach(new i : Player)

stavi:
for(new i = 0; i < MAX_PLAYERS; i++)


Da li imas #include na vrhu skripte?
Mate
5
Underboss
15. Nov. 2016.
Pokusao sam tako isti problem!

Pa imam forach na vrhu vec sam napomenuo 😄 Citajte!  😄
Maranello1312
4
Enforcer
15. Nov. 2016.
Imao sam isti problem,nemoj koristiti svoj pawno,vec onaj koji je u modu,posto se includovi razlikuju!!!
To je citav problem... Samo uzmi originalan pawno koji je dosao uz taj mod!!!
Dragutin_Raikc
4
Enforcer
16. Nov. 2016.
Ne mozes odvajati zagradu to jest (new i : Player) od foreach-a.
foreach(new i : Player)
Rax_King
5
Godfather
16. Nov. 2016.
Ako hoces da imas fleksibilnost odvajanja npr foreach  (new i: Player ) koristi y_iterate, al zauzima vise memorije a u sustini je isto 😄

Morate biti prijavljeni da biste odgovorili na ovu temu.

Prijava

© 2026 SmartShark. All rights reserved.

Powered by Momentum|v2026.3.001 Alpha