Error is on the same line
if StrEqual((temp_name, "NULL") && connections == 0)
KeyValues!!.sp
D:\DSCSGO\Editor\My scripts\KeyValues!!.sp(50) : error 033: array must be indexed (variable "-unknown-")
I also removed karma because I wont be calling it in this function
Code:
#pragma semicolon 1
#pragma newdecls required
#define DEBUG
#define PLUGIN_AUTHOR ""
#define PLUGIN_VERSION "0.00"
#include <sourcemod>
#include <sdktools>
#include <cstrike>
public Plugin myinfo =
{
name = "",
author = PLUGIN_AUTHOR,
description = "",
version = PLUGIN_VERSION,
url = ""
};
static char KVPath[PLATFORM_MAX_PATH];
public void OnPluginStart()//Store playername + steamid
{
CreateDirectory("addons/sourcemod/data/TTT", 3);
BuildPath(Path_SM, KVPath, sizeof(KVPath), "data/TTT/playerinfo.txt");
}
public void OnClientPutInServer(int client)
{
SavePlayerInfo(client);
}
public void SavePlayerInfo(int client)
{
Handle DB = CreateKeyValues("PlayerInfo");
FileToKeyValues(DB, KVPath);
char SID[32];
GetClientAuthId(client, AuthId_Steam2, SID, sizeof(SID));
if (KvJumpToKey(DB, SID, true))
{
char name[MAX_NAME_LENGTH];
char temp_name[MAX_NAME_LENGTH];
GetClientName(client, name, sizeof(name));
KvGetString(DB, "name", temp_name, sizeof(temp_name), "NULL");
int connections = KvGetNum(DB, "connections", 0);
if StrEqual((temp_name, "NULL") && connections == 0)
{
PrintToChatAll("Welcome %s to Server for the first time!", name);
}
else
{
PrintToChatAll("Welcome back %s! Last known here as %s. They have connected %d times.", name, temp_name, connections);
}
connections++;
KvSetNum(DB, "connections", connections);
KvSetString(DB, "name", name);
KvRewind(DB);
KeyValuesToFile(DB, KVPath);
CloseHandle(DB);
}
}