Raised This Month: $ Target: $400
 0% 

Detected out of bounds index 0


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Snaggle
AlliedModders Donor
Join Date: Jul 2010
Location: England
Old 07-21-2015 , 14:40   Detected out of bounds index 0
Reply With Quote #1

We are using a modified version of the Player Spawns plugin and have encountered an error that sometimes spams our logs a lot. Unfortunately the developer who modified it for us has moved on with their life and is no longer reachable.

I was wondering if someone would be able to take a look and see what the problem might be as my knowledge with sourcepawn is limited. There is no line number or other info.

PHP Code:
L 07/21/2015 12:55:00: [setspawn.smxWARNINGDetected out of bounds index 0
L 07
/21/2015 12:55:00: [setspawn.smxWARNINGDetected out of bounds index 0
L 07
/21/2015 13:00:00: [setspawn.smxWARNINGDetected out of bounds index 0 
PHP Code:
SourceMod Version Information:
             
SourceMod Version1.7.3-dev+5216
             SourcePawn Engine
SourcePawn 1.7jit-x86 (build 1.7.3-dev+5216)
             
SourcePawn APIv1 4v2 6
             Compiled on
Jun 26 2015 08:13:45
             Built from
https://github.com/alliedmodders/sourcemod/commit/4296245
             
Build ID5216:4296245
             http
://www.sourcemod.net/ 
Attached Files
File Type: sp Get Plugin or Get Source (setspawn.sp - 196 views - 8.5 KB)
Snaggle is offline
TheUnderTaker
Senior Member
Join Date: Dec 2013
Location: Israel
Old 07-21-2015 , 14:52   Re: Detected out of bounds index 0
Reply With Quote #2

You got compile warning, and you didn't fix, I fixed it to you, so try to compile it:
PHP Code:
#include <sourcemod>
#include <sdktools>
#pragma semicolon 1
#define PLUGIN_VERSION "1.13.0"
new bool:pSpawnSet[MAXPLAYERS+1];
new 
Float:pSpawn[MAXPLAYERS+1][3];
new 
Float:pAngle[MAXPLAYERS+1][3];
new 
pTeam[MAXPLAYERS+1];
new 
Handle:cEnabled;
public 
Plugin:myinfo 
{
 
name "Player Spawns",
 
author "noodleboy347 & WhosAsking?",
 
description "Sets player spawns",
 
version PLUGIN_VERSION,
 
url "http://www.frozencubes.com"
}
public 
OnPluginStart()
{
 
RegConsoleCmd("sm_whereami"Command_WhereAmI);
 
RegConsoleCmd("sm_setspawn"Command_Setspawn);
 
RegConsoleCmd("sm_clearspawn"Command_Clearspawn);
 
RegAdminCmd("sm_setplayerspawn"Command_SetplayerspawnADMFLAG_GENERIC);
 
RegAdminCmd("sm_setplayerspawn2"Command_SetplayerspawnADMFLAG_GENERIC);
 
RegAdminCmd("sm_clearplayerspawn"Command_ClearplayerspawnADMFLAG_GENERIC);
 
RegAdminCmd("sm_savespawn"Command_SavespawnADMFLAG_GENERIC);
 
RegAdminCmd("sm_loadspawn"Command_LoadspawnADMFLAG_GENERIC);
 
CreateConVar("sm_playerspawns_version"PLUGIN_VERSION"Player Spawns plugin version"FCVAR_NOTIFY);
 
cEnabled CreateConVar("sm_playerspawns_enable""1""Enables plugin");
 
HookConVarChange(cEnabledCvar_Toggle);
 
HookEvent("player_spawn"Event_Spawn);
}
bool:CanSetSpawn(client)
{
 return 
GetConVarBool(cEnabled) && ((IsPlayerAlive(client) && (GetClientTeam(client) > 1)) || IsFakeClient(client));
}
public 
Cvar_Toggle(Handle:cvar, const String:oldVal[], const String:newVal[])
{
 if(
StringToInt(newVal) == 0)
 {
  for(new 
i=1GetMaxClients(); i++)
  {
   
pSpawnSet[i] = false;
  }
 }
}
public 
OnClientPostAdminCheck(client)
{
 
pSpawnSet[client] = false;
 
pTeam[client] = 0;
}
public 
Action:Command_Setspawn(clientargs)
{
 if(
CanSetSpawn(client))
 {
  
GetClientAbsOrigin(clientpSpawn[client]);
  
GetClientAbsAngles(clientpAngle[client]);
  
pSpawnSet[client] = true;
  
pTeam[client] = GetClientTeam(client);
  
ReplyToCommand(client"[SM] Spawn location set.");
 }
 else
  
ReplyToCommand(client"[SM] You can't set a spawn now.");
 return 
Plugin_Handled;
}
public 
Action:Command_Clearspawn(clientargs)
{
 if(
GetConVarBool(cEnabled))
 {
  if(!
pSpawnSet[client])
   
ReplyToCommand(client"[SM] You haven't set your spawn yet.");
  else
  {
   
ReplyToCommand(client"[SM] Spawn location cleared.");
   
pSpawnSet[client] = false;
  }
 }
 return 
Plugin_Handled;
}
public 
Action:Command_Setplayerspawn(clientargs)
{
 if(
GetConVarBool(cEnabled))
 {
  
decl String:arg[64];
  
GetCmdArg(0argsizeof(arg));
  if(
args 1)
  {
   
ReplyToCommand(client"[SM] Usage: %s <player>"arg);
   return 
Plugin_Handled;
  }
  new 
bool:alt = (StrContains(arg,"setplayerspawn2",false) >= 0);
  
GetCmdArg(1argsizeof(arg));
  
decl String:target_name[MAX_TARGET_LENGTH];
  
decl target_list[MAXPLAYERS], target_countbool:tn_is_ml;
  if((
target_count ProcessTargetString(
    
arg,
    
client
    
target_list
    
MAXPLAYERS
    
0,
    
target_name,
    
sizeof(target_name),
    
tn_is_ml)) <= 0)
  {
   
ReplyToTargetError(clienttarget_count);
   return 
Plugin_Handled;
  }
  for(new 
0target_counti++)
   if (
CanSetSpawn(target_list[i]))
   {
    new 
source = (alt) ? target_list[i] : client;
    
GetClientAbsOrigin(sourcepSpawn[target_list[i]]);
    
GetClientAbsAngles(sourcepAngle[target_list[i]]);
    
pSpawnSet[target_list[i]] = true;
    
pTeam[target_list[i]] = GetClientTeam(target_list[i]);
   }
   else
    
ShowActivity2(client"[SM]""WARNING: Spawn of %N could not be set."target_list[i]);
  
ShowActivity2(client"[SM]""Set the spawn of %s"target_name);
 }
 return 
Plugin_Handled
}
public 
Action:Command_Clearplayerspawn(clientargs)
{
 if(
GetConVarBool(cEnabled))
 {
  if(
args != 1)
  {
   
ReplyToCommand(client"[SM] Usage: sm_clearplayerspawn <player>");
   return 
Plugin_Handled;
  }
  
decl String:arg[64];
  
GetCmdArg(1argsizeof(arg));
  
decl String:target_name[MAX_TARGET_LENGTH];
  
decl target_list[MAXPLAYERS], target_countbool:tn_is_ml;
  if((
target_count ProcessTargetString(
    
arg,
    
client
    
target_list
    
MAXPLAYERS
    
0,
    
target_name,
    
sizeof(target_name),
    
tn_is_ml)) <= 0)
  {
   
ReplyToTargetError(clienttarget_count);
   return 
Plugin_Handled;
  }
  for(new 
0target_counti++)
   
pSpawnSet[target_list[i]] = false;
  
ShowActivity2(client"[SM]""Cleared the spawn of %s"target_name);
 }
 return 
Plugin_Handled
}
public 
Action:Command_Savespawn(clientargs)
{
 
// Determine the name of the game.
 
decl String:MapName[PLATFORM_MAX_PATH];
 
decl String:MapFile[PLATFORM_MAX_PATH];
 
decl String:Name[64];
 
GetCurrentMap(MapNamesizeof(MapName));
 
// Modify to arrive at the filename.
 
Format(MapFile,sizeof(MapFile),"spawn_%s.dat",MapName);
    
//Initiate file handling.
 
new Handle:INVALID_HANDLE;
 
// Create string for full path.
 
decl String:FilePath[PLATFORM_MAX_PATH];
 
BuildPath(Path_SMFilePathPLATFORM_MAX_PATH"gamedata/%s"MapFile);
 
// Open file for writing, wiping existing content.
 
OpenFile(FilePath,"wtb");
 
 
// TEST: To continue, file must be properly opened.
 
if (!= INVALID_HANDLE)
 {
  
// Write the client's ID and coordinates.
  
for (new 1;<= MAXPLAYERS;i++)
   
// IF a Spawn is set for that client.
   
if (pSpawnSet[i])
   {
    
GetClientName(iNamesizeof(Name));
    
WriteFileString(fNametrue);
    
WriteFile(f,_:pSpawn[i],3,4);
    
WriteFile(f,_:pAngle[i],3,4);
   }
  
// Writing complete. Close the file.
  
CloseHandle(f);
  
LogMessage("File %s saved.",MapFile);
  
ReplyToCommand(client,"File %s saved.",MapFile);
 }
 
// TEST FAIL: File didn't open correctly. Report to log and server.
 
else
 {
  
LogMessage("Error opening file %s. No locations saved.",MapFile);
  
ReplyToCommand(client,"WARNING: Error opening file %s. No locations saved.",MapFile);
 }
 return 
Plugin_Handled;
}
public 
Action:Command_Loadspawn(clientargs)
{
 
// Determine the name of the game.
 
decl String:MapName[PLATFORM_MAX_PATH];
 
decl String:MapFile[PLATFORM_MAX_PATH];
 
GetCurrentMap(MapNamesizeof(MapName));
 
// Modify to arrive at the filename.
 
Format(MapFile,sizeof(MapFile),"spawn_%s.dat",MapName);
    
//Initiate file handling.
 
new Handle:f=INVALID_HANDLE;
 
// Create string for full path.
 
decl String:FilePath[PLATFORM_MAX_PATH];
 
BuildPath(Path_SMFilePathPLATFORM_MAX_PATH"gamedata/%s"MapFile);
 
// Test #1: File must exist.
 
if (FileExists(FilePath))
 {
  
// Open file for reading.
  
f=OpenFile(FilePath,"rb");
  
// Test #2: File must have opened correctly.
  
if (f!=INVALID_HANDLE)
  {
   
// All good. Proceed with read until entire file is read.
   
while (!IsEndOfFile(f))
   {
    
decl String:Name[64];
    
decl String:Match[64];
    
decl Float:Spawn[3];
    
decl Float:Angle[3];
    
    
ReadFileString(fNamesizeof(Name));
    
ReadFile(f,_:Spawn,3,4);
    
ReadFile(f,_:Angle,3,4);
    
    for (new 
1;<= MaxClients;i++)
    {
     if (!
IsClientConnected(i))
      continue;
     
GetClientName(iMatchsizeof(Match));
     if (
StrEqual(NameMatch))
     {
      
pSpawnSet[i] = true;
      
pSpawn[i] = Spawn;
      
pAngle[i] = Angle;
     }
    }
   }
   
LogMessage("Spawn file %s loaded."MapFile);
   
ReplyToCommand(client,"Spawn file %s loaded."MapFile);
  }
  
// Test #2 FAIL: File didin't open correctly. Report to log and server.
  
else
  {
   
LogMessage("Error opening file %s. No locations loaded.",MapFile);
   
ReplyToCommand(client,"WARNING: Error opening file %s. No locations loaded.",MapFile);
  }
  
// In all cases, close handle to clean up.
  
CloseHandle(f);
 }
 
// Test #1 FAIL: File does not exist. Report to log and server.
 
else
 {
  
LogMessage("File %s not found. No locations loaded.",MapFile);
  
ReplyToCommand(client,"WARNING: File %s not found. No locations loaded.",MapFile);
 } 
 return 
Plugin_Handled;
}

public 
Action:Event_Spawn(Handle:event, const String:name[], bool:dontBroadcast)
{
 new 
client GetClientOfUserId(GetEventInt(event"userid"));
 new 
team GetClientTeam(client);
 
 if ((
team == pTeam[client]) || IsPlayerAlive(client) && IsFakeClient(client))
 {
  if(
pSpawnSet[client])
   
TeleportEntity(clientpSpawn[client], pAngle[client], NULL_VECTOR);
 }
 else
 {
  
pSpawnSet[client] = false;
  
pTeam[client] = team;
 }
}
public 
Action:Command_WhereAmI(clientargs)
{
 if (
IsClientConnected(client))
 {
  new 
Float:Temp[3];
  
GetClientAbsOrigin(clientTemp);
  
ReplyToCommand(client"You are currently located at (%0.2f, %0.2f, %0.2f)"Temp[0], Temp[1], Temp[2]);
  
GetClientAbsAngles(clientTemp);
  
ReplyToCommand(client"with an orientation of (%0.2f, %0.2f, %0.2f)."Temp[0], Temp[1], Temp[2]);
 }
 return 
Plugin_Handled;

__________________
SourcePawn, C# and C++ Programmer.

My plugin list

Last edited by TheUnderTaker; 07-21-2015 at 14:53.
TheUnderTaker is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:53.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode