[20:02:53] [debug] Run time error 4: "Array index out of bounds" [20:02:53] [debug] Accessing element at index 65535 past array upper bound 499 [20:02:53] [debug] AMX backtrace: [20:02:53] [debug] #0 0001f114 in ?? (0x00000000, 0x0000ffff, 0x3f1f3b54, 0x4017dbf5) from Island.amx [20:02:53] [debug] #1 00049f60 in ?? (0x00000000) from Island.amx [20:02:53] [debug] #2 000ce334 in ?? (0x00000000) from Island.amx [20:02:53] [debug] #3 000189e4 in public FIXES_OnPlayerSpawn (0x00000000) from Island.amx [20:02:53] [debug] #4 00004c14 in public OnPlayerSpawn (0x00000000) from Island.amx
65535 means INVALID_PLAYER_ID, you got somewhere
new array_name[MAX_PLAYERS]; // 500 = 0 - 499 array_name[65535] compile with -d3 flag and show again info https://github.com/Zeex/samp-plugin-...ith-debug-info |
// Freeze a player
COMMAND:freeze(playerid, params[])
{
// If the player has an insufficient admin-level (he needs level 1), exit the command
if (APlayerData[playerid][AdminLevel] < 1) return SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Only admins level 1 and higher can use this command");
// Setup local variables
new Msg[128], OtherPlayer, Duration;
// Split the parameters
if (sscanf(params, "ui", OtherPlayer, Duration)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/freeze <OtherPlayer> <Duration>\"");
// If the other player has an invalid ID (sscanf returns 65535 as playerid if the player cannot be found), exit the command
if (OtherPlayer >= MAX_PLAYERS) return SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}That player is not online");
// If the other player is still in class selection, exit the command
if (Player_InClassSelection(OtherPlayer) == 1) return SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}That player is still in class-selection and cannot be frozen");
// If an invalid duration was given (0 or lower), exit the command
if (Duration <= 0) return SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Duration must be minimum 1 second");
// Freeze the given player for the specified duration (store the freezetime and freeze the player)
APlayerData[OtherPlayer][FreezeTime] = Duration;
TogglePlayerControllable(OtherPlayer, 0);
// Let the other player know he has been frozen and by who
format(Msg, sizeof(Msg), "{FF0000}You've been frozen for {FFFF00}%i{FF0000} seconds by {FFFF00}%s", Duration, APlayerData[playerid][Name]);
SendClientMessage(OtherPlayer, 0xFFFFFFFF, Msg);
// Let the admin know who's been frozen
format(Msg, sizeof(Msg), "{00FF00}You have frozen {FFFF00}%s", APlayerData[OtherPlayer][Name]);
SendClientMessage(playerid, 0xFFFFFFFF, Msg);
// Now the global timer takes over to un-freeze him when the timer has reached 0 (also the freeze-time is saved automatically by the global timer)
// Let the server know that this was a valid command
return 1;
}