04.02.2013, 03:58
Help me solve this please:
Код:
[02:54:02] [debug] AMX backtrace: [02:54:02] [debug] #0 002055a8 in ?? () from truck.amx [02:54:02] [debug] #1 002046c8 in public Speedometer_Update () from truck.amx [02:54:02] [debug] Accessing element at index 100 past array upper bound 99
pawn Код:
public Speedometer_Update(playerid)
{
// Setup local variables
new vehicleid, Float:speed_x, Float:speed_y, Float:speed_z, Float:final_speed, speed_string[50], final_speed_int;//, Float:vehiclehealth;
new FuelString[50], FuelStatus[20];
new Msg[128], Name[24];
// Get the ID of the player's vehicle
vehicleid = GetPlayerVehicleID(playerid);
//******************************************************************************************************************************
// Anti-hack stuff
//******************************************************************************************************************************
AntiHack(playerid);
//******************************************************************************************************************************
// End of anti-hack stuff
//******************************************************************************************************************************
// Check and toggle spectate-mode when needed (when target player entered or exited his vehicle)
if (GetPlayerState(playerid) == PLAYER_STATE_SPECTATING)
{
// Get the target player's ID and name
new OtherPlayer = APlayerData[playerid][SpectateID];
GetPlayerName(OtherPlayer, Name, sizeof(Name));
// Use the same worldid and interiorid as the OtherPlayer
SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(OtherPlayer));
SetPlayerInterior(playerid, GetPlayerInterior(OtherPlayer));
// Check if the player is spectating a player
if (APlayerData[playerid][SpectateType] == ADMIN_SPEC_TYPE_PLAYER)
{
// Check if the target player has entered a vehicle
if (GetPlayerVehicleSeat(OtherPlayer) != -1)
{
// Change spectate mode to vehicle
PlayerSpectateVehicle(playerid, GetPlayerVehicleID(OtherPlayer));
APlayerData[playerid][SpectateID] = OtherPlayer;
APlayerData[playerid][SpectateVehicle] = GetPlayerVehicleID(OtherPlayer);
APlayerData[playerid][SpectateType] = ADMIN_SPEC_TYPE_VEHICLE;
format(Msg, 128, "{00FF00}Player {FFFF00}%s{00FF00} has entered a vehicle, changing spectate mode to match", Name);
SendClientMessage(playerid, 0xFFFFFFFF, Msg);
}
}
else // The player is spectating a vehicle
{
// Check if the target player has exited a vehicle
if (GetPlayerVehicleSeat(OtherPlayer) == -1)
{
// Change spectate mode to player
PlayerSpectatePlayer(playerid, OtherPlayer);
SetPlayerInterior(playerid, GetPlayerInterior(OtherPlayer));
APlayerData[playerid][SpectateID] = OtherPlayer;
APlayerData[playerid][SpectateType] = ADMIN_SPEC_TYPE_PLAYER;
format(Msg, 128, "{00FF00}Player {FFFF00}%s{00FF00} has exited a vehicle, changing spectate mode to match", Name);
SendClientMessage(playerid, 0xFFFFFFFF, Msg);
}
}
}
// When the player got a wanted level and a police player warned him to stop, a timer is started and a variable is set to "true"
// Check if this variable has been set
if (APlayerData[playerid][PoliceWarnedMe] == true)
{
// Check if the player has no wanted level anymore (after finishing a overloaded mission, player got fined, ...)
if (GetPlayerWantedLevel(playerid) == 0)
{
APlayerData[playerid][PoliceCanJailMe] = false; // Clear the variable
APlayerData[playerid][PoliceWarnedMe] = false; // Clear the variable
APlayerData[playerid][Value_PoliceCanJailMe] = 0; // Clear the remaining time for the timer
KillTimer(APlayerData[playerid][Timer_PoliceCanJailMe]); // Kill the timer
}
}
// If the player is inside a vehicle
if(vehicleid != 0)
{
// Get the vehicles velocity
GetVehicleVelocity(vehicleid, speed_x, speed_y, speed_z);
// Calculate the speed (in kph)
final_speed = floatsqroot(((speed_x * speed_x) + (speed_y * speed_y)) + (speed_z * speed_z)) * 158.179;
// Convert the float value to an int value
final_speed_int = floatround(final_speed, floatround_round);
// Also save the speed for the player
APlayerData[playerid][PlayerSpeed] = final_speed_int;
// Setup the string to display for the player and display it
format(speed_string, 50, "KMH: %i", final_speed_int);
TextDrawSetString(Velocimetro[playerid], speed_string);
// Add the speed to the stats (this will be the meters driven in total)
APlayerData[playerid][StatsMetersDriven] = APlayerData[playerid][StatsMetersDriven] + (final_speed / 7.2);
// Also display the vehicle's health through the player-health bar
//GetVehicleHealth(vehicleid, vehiclehealth);
//SetPlayerHealth(playerid, vehiclehealth / 10.0);
// Check if the speed is above 10kph and the fuel of the vehicle isn't empty yet
if ((final_speed_int > 10) && (AVehicleData[vehicleid][Fuel] > 0))
AVehicleData[vehicleid][Fuel] = AVehicleData[vehicleid][Fuel] - 1; // Decrease the fuel for this vehicle every time the timer is run
// Construct the fuelgauge
if ((AVehicleData[vehicleid][Fuel] > 0) && (AVehicleData[vehicleid][Fuel] < 100000))
format(FuelStatus, 20, "~g~%s~r~%s", "•", "IIIIIIIII"); // Fuel is between 0% and 10% full
if ((AVehicleData[vehicleid][Fuel] >= ((MaxFuel / 10) * 1)) && (AVehicleData[vehicleid][Fuel] < ((MaxFuel / 10) * 2)))
format(FuelStatus, 20, "~g~%s~r~%s", "II", "IIIIIIII"); // Fuel is between 10% and 20% full
if ((AVehicleData[vehicleid][Fuel] >= ((MaxFuel / 10) * 2)) && (AVehicleData[vehicleid][Fuel] < ((MaxFuel / 10) * 3)))
format(FuelStatus, 20, "~g~%s~r~%s", "III", "IIIIIII"); // Fuel is between 20% and 30% full
if ((AVehicleData[vehicleid][Fuel] >= ((MaxFuel / 10) * 3)) && (AVehicleData[vehicleid][Fuel] < ((MaxFuel / 10) * 4)))
format(FuelStatus, 20, "~g~%s~r~%s", "IIII", "IIIIII"); // Fuel is between 30% and 40% full
if ((AVehicleData[vehicleid][Fuel] >= ((MaxFuel / 10) * 4)) && (AVehicleData[vehicleid][Fuel] < ((MaxFuel / 10) * 5)))
format(FuelStatus, 20, "~g~%s~r~%s", "IIIII", "IIIII"); // Fuel is between 40% and 50% full
if ((AVehicleData[vehicleid][Fuel] >= ((MaxFuel / 10) * 5)) && (AVehicleData[vehicleid][Fuel] < ((MaxFuel / 10) * 6)))
format(FuelStatus, 20, "~g~%s~r~%s", "IIIIII", "IIII"); // Fuel is between 50% and 60% full
if ((AVehicleData[vehicleid][Fuel] >= ((MaxFuel / 10) * 6)) && (AVehicleData[vehicleid][Fuel] < ((MaxFuel / 10) * 7)))
format(FuelStatus, 20, "~g~%s~r~%s", "IIIIIII", "III"); // Fuel is between 60% and 70% full
if ((AVehicleData[vehicleid][Fuel] >= ((MaxFuel / 10) * 7)) && (AVehicleData[vehicleid][Fuel] < ((MaxFuel / 10) * 8)))
format(FuelStatus, 20, "~g~%s~r~%s", "IIIIIIII", "II"); // Fuel is between 70% and 80% full
if ((AVehicleData[vehicleid][Fuel] >= ((MaxFuel / 10) * 8)) && (AVehicleData[vehicleid][Fuel] < ((MaxFuel / 10) * 9)))
format(FuelStatus, 20, "~g~%s~r~%s", "IIIIIIIII", "I"); // Fuel is between 80% and 90% full
if ((AVehicleData[vehicleid][Fuel] >= ((MaxFuel / 10) * 9)) && (AVehicleData[vehicleid][Fuel] <= MaxFuel))
format(FuelStatus, 20, "~g~%s", "IIIIIIIIII"); // Fuel is between 90% and 100% full (all bars are green)
if (AVehicleData[vehicleid][Fuel] == 0)
format(FuelStatus, 20, "~r~%s", "IIIIIIIIII"); // Fuel is empty (all bars are red)
// Format the final fuel-gauge readout
format(FuelString, 50, "%s", FuelStatus);
// Display the fuel-gauge
TextDrawSetString(Gasolina[playerid], FuelString);
// Check if the vehicle is out of fuel
if (AVehicleData[vehicleid][Fuel] == 0)
{
// Stop the engine and turn off the lights
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid, 0, 0, alarm, doors, bonnet, boot, objective);
}
// Check if the player is not in any plane or helicopter (those cannot be caught by speedcamera's)
if (IsVehicleAirVehicle(vehicleid) == 0)
if (APlayerData[playerid][PlayerClass] != ClassPolice) // Check if the player isn't speeding (cops won't get caught)
CheckPlayerSpeeding(playerid);
}
else
{
// If the player is not inside a vehicle, display an empty string (looks like the speedometer is gone)
TextDrawSetString(Velocimetro[playerid], " ");
TextDrawSetString(Gasolina[playerid], " ");
// Set the speed of the player to 0
APlayerData[playerid][PlayerSpeed] = 0;
}
}