Errors in crashdetect "Array index out of bounds" x2
#7

Quote:
Originally Posted by Troydere
Посмотреть сообщение
That would not make any sense.

Код:
new VehicleName[212]
OP, I think you should to the calculations outside the array, like this:

PHP код:
new vehname GetVehicleModel(vehicleid) - 400;
format(bla,sizeof bla,"bla bla veh name %s",VehicleName[vehname]); 
Woa, yes, my bad.
The code is right, there is no problem with this. The problem is GetVehicleModel return 0. It mean, the vehicle doesn't exist.
Add on the top of your script after includes.:
PHP код:
native IsValidVehicle(vehicleid); 
Try this code:
PHP код:
public Speed() 

    for(new 
0GetMaxPlayers(); p++) if(IsPlayerConnected(p) && !IsPlayerNPC(p)) 
    {
        new 
vehicleid GetPlayerVehicleID(p); 
        if(!
IsValidVehicle(vehicleid))
            continue;
        if(
vehicleid
        { 
            new 
string[128], Float:XFloat:YFloat:ZFloat:PointToPointFloat:vhealth
             
GetVehicleVelocity(vehicleidXYZ); 
             
PointToPoint = (floatsqroot(floatpower(X2) + floatpower(Y2) + floatpower(Z2)))*100
            
GetVehicleHealth(vehicleid,vhealth); 
            
format(string,sizeof string ,"{00D1FF}Vehнculo: {FFFFFF}%s\n{00D1FF}Vida: {FFFFFF}%.2f\n{00D1FF}Velocidad: {FFFFFF}%ikm/h"VehicleName[GetVehicleModel(vehicleid)-400], vhealthfloatround(PointToPointfloatround_floor)); 
            
DeletePlayer3DTextLabel(pspeedo3Dtext); 
            
speedo3Dtext CreatePlayer3DTextLabel(pstringspeedcolor0.0,-1.6,-0.35,20.0INVALID_PLAYER_IDvehicleid); 
        } else if(
p) { DeletePlayer3DTextLabel(pspeedo3Dtext); } 
    } 

Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 4 Guest(s)