Run time error 4: "Array index out of bounds"
#2

Make your timer be called every 1 second (1000 ms).
Update your foreach to the latest version; The latest one uses different syntax of foreach(new i : Player).
No need to make several arrays (or strings), you can use one array and re-use it.
I made vehicleid variable and stored the ID, so I don't need to use the GetPlayerVehicleID function over and over again.

PHP код:
public Speedometer(playerid)
{
    new 
string[32], vehicleid;
    foreach(new 
Player)
    {
        if(!
pInfo[i][Logged]) continue;
        
vehicleid GetPlayerVehicleID(playerid);
        if(
vehicleid)
        {
            
format(stringsizeof string"~g~%s"VehicleNames[GetVehicleModel(vehicleid) - 400]);
            
TextDrawSetString(VehicleName[i], string);
            
format(stringsizeof string"%d"GetPlayerSpeed(i0)); 
            
TextDrawSetString(VehicleSpeed[i], string);
            
GetVehicleHealth(vehicleidvhealth);
            
format(stringsizeof string"~%s~%.0f.0"DamageColor(vhealth), vhealth);
            
TextDrawSetString(VehicleHealth[i], string);
        }
    }
    return 
1

Reply


Messages In This Thread
Run time error 4: "Array index out of bounds" - by insus100 - 22.03.2018, 18:37
Re: Run time error 4: "Array index out of bounds" - by Logic_ - 22.03.2018, 18:49
Re: Run time error 4: "Array index out of bounds" - by insus100 - 22.03.2018, 19:10

Forum Jump:


Users browsing this thread: 1 Guest(s)