DarkerZ
Участник
- Сообщения
- 395
- Реакции
- 175
внимательно прочитай, чем меньше циферка в приоритете(первый столбик) - тем приоритет меньшей цифры ВЫШЕПосмотреть вложение 109338
Так в плюсах
внимательно прочитай, чем меньше циферка в приоритете(первый столбик) - тем приоритет меньшей цифры ВЫШЕПосмотреть вложение 109338
Так в плюсах
Ну так я поэтому и скинул. Я то понимаю и вижу все прекрасновнимательно прочитай, чем меньше циферка в приоритете(первый столбик) - тем приоритет меньшей цифры ВЫШЕ
Никто не говорил, что это плюсы). Я просто привел скрин, к которому можно отнести его слова. А скобки я написал, потому что не замечал какие приоритеты стоят и подстраховался на всякий@DarkerZ, докажи, что я не прав.
Я на практике уже неоднократно убедился, что у||
приортет выше, чем у&&
.
Сообщения автоматически склеены:
И да, плюсы - это не SP.
Помогите пожалуйста скомпилировать файл.
#pragma newdecls required
#pragma semicolon 1
#include <premium_core>
#include <sdktools_gamerules>
#include <cstrike>
#define SPAWN_HEALTH "SpawnHealth"
#define EXTRA_CASH "ExtraCash"
int iRoundCount;
public void OnPluginStart()
{
HookEvent("round_start", Event_RoundStart, EventHookMode_Pre);
HookEvent("round_end", Event_RoundEnd, EventHookMode_Pre);
HookEvent("player_spawn", OnSpawn);
}
public void Premium_OnPremiumLoaded()
{
Premium_AddFeature(SPAWN_HEALTH);
Premium_AddFeature(EXTRA_CASH);
}
void Event_RoundStart(Event event, const char[] name, bool silent)
{
if(GameRules_GetProp("m_bWarmupPeriod")) return;
iRoundCount++;
}
void Event_RoundEnd(Event event, const char[] name, bool silent)
{
if(view_as<CSRoundEndReason>(event.GetInt("reason")) == CSRoundEnd_GameStart)
iRoundCount = 0;
}
void OnSpawn(Event event, const char[] name, bool silent)
{
int client = GetClientOfUserId(event.GetInt("userid"));
if(iRoundCount < 2) return;
if(Premium_IsFeatureUse(client, SPAWN_HEALTH))
{
SetEntityHealth(client, 105);
SetEntProp(client, Prop_Data, "m_ArmorValue", 105);
SetEntProp(client, Prop_Send, "m_bHasHelmet", 1);
}
if(Premium_IsFeatureUse(client, EXTRA_CASH)) SetEntProp(client, Prop_Send, "m_iAccount", 16000);
}
public void OnPluginEnd()
{
if(GetFeatureStatus(FeatureType_Native, "Premium_RemoveFeature") == FeatureStatus_Available)
{
Premium_RemoveFeature(SPAWN_HEALTH);
Premium_RemoveFeature(EXTRA_CASH);
}
}
L 02/26/2023 - 00:10:31: [SM] Exception reported: Invalid client index 0
L 02/26/2023 - 00:10:31: [SM] Blaming: timed_bonus.smx
L 02/26/2023 - 00:10:31: [SM] Call stack trace:
L 02/26/2023 - 00:10:31: [SM] [0] ThrowError
L 02/26/2023 - 00:10:31: [SM] [1] Line 60, D:\Desktop\1.11 scripting\include\clientmod/colors/colors.inc::C_PrintToChat
L 02/26/2023 - 00:10:31: [SM] [2] Line 333, D:\Desktop\1.11 scripting\timed_bonus.sp::CountTime
public Action CountTime(Handle hTimer, int iClient)
{
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && !IsFakeClient(i) && GetClientTeam(i) > 1)
{
if (g_iTime[i]++ > iBonusTime)
{
if (++g_iDays[i] > 0 && !g_iGived[g_iDays[i]][i])
{
g_iGived[g_iDays[i]][i] = 1;
if (g_iDays[i] >= 30)
{
g_iDays[i] = 0;
}
if (g_iGived[g_iDays[i]-1][i] > 0 && g_iGived[g_iDays[i]-1][i] == 1)
{
for (int t; t < 30; t++)
{
g_iGived[t][i] = 0;
}
g_iDays[i] = 0;
}
}
g_iTime[i] = 0;
MC_PrintToChat(iClient, "%t %t", "CM_Prefix", "CM_Bonus_Available");
C_PrintToChat(iClient, "%t %t", "Prefix", "Bonus_Available");
}
}
}
}
Подскажите пожалуйста, как в данном блоке исправить ошибку:
Ошибка:L 02/26/2023 - 00:10:31: [SM] Exception reported: Invalid client index 0 L 02/26/2023 - 00:10:31: [SM] Blaming: timed_bonus.smx L 02/26/2023 - 00:10:31: [SM] Call stack trace: L 02/26/2023 - 00:10:31: [SM] [0] ThrowError L 02/26/2023 - 00:10:31: [SM] [1] Line 60, D:\Desktop\1.11 scripting\include\clientmod/colors/colors.inc::C_PrintToChat L 02/26/2023 - 00:10:31: [SM] [2] Line 333, D:\Desktop\1.11 scripting\timed_bonus.sp::CountTime
Код:public Action CountTime(Handle hTimer, int iClient) { for (int i = 1; i <= MaxClients; i++) { if (IsClientInGame(i) && !IsFakeClient(i) && GetClientTeam(i) > 1) { if (g_iTime[i]++ > iBonusTime) { if (++g_iDays[i] > 0 && !g_iGived[g_iDays[i]][i]) { g_iGived[g_iDays[i]][i] = 1; if (g_iDays[i] >= 30) { g_iDays[i] = 0; } if (g_iGived[g_iDays[i]-1][i] > 0 && g_iGived[g_iDays[i]-1][i] == 1) { for (int t; t < 30; t++) { g_iGived[t][i] = 0; } g_iDays[i] = 0; } } g_iTime[i] = 0; MC_PrintToChat(iClient, "%t %t", "CM_Prefix", "CM_Bonus_Available"); C_PrintToChat(iClient, "%t %t", "Prefix", "Bonus_Available"); } } } }
public Action CountTime(Handle hTimer, int iClient)
{
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && !IsFakeClient(i) && GetClientTeam(i) > 1)
{
if (g_iTime[i]++ > iBonusTime)
{
if (++g_iDays[i] > 0 && !g_iGived[g_iDays[i]][i])
{
g_iGived[g_iDays[i]][i] = 1;
if (g_iDays[i] >= 30)
{
g_iDays[i] = 0;
}
if (g_iGived[g_iDays[i]-1][i] > 0 && g_iGived[g_iDays[i]-1][i] == 1)
{
for (int t; t < 30; t++)
{
g_iGived[t][i] = 0;
}
g_iDays[i] = 0;
}
}
g_iTime[i] = 0;
if(iClient && IsClientInGame(iClient))
{
MC_PrintToChat(iClient, "%t %t", "CM_Prefix", "CM_Bonus_Available");
C_PrintToChat(iClient, "%t %t", "Prefix", "Bonus_Available");
}
}
}
}
}
Теперь время не идет, просто стоитC++:public Action CountTime(Handle hTimer, int iClient) { if(!iClient || !IsClientInGame(iClient)) return; for (int i = 1; i <= MaxClients; i++) { if (IsClientInGame(i) && !IsFakeClient(i) && GetClientTeam(i) > 1) { if (g_iTime[i]++ > iBonusTime) { if (++g_iDays[i] > 0 && !g_iGived[g_iDays[i]][i]) { g_iGived[g_iDays[i]][i] = 1; if (g_iDays[i] >= 30) { g_iDays[i] = 0; } if (g_iGived[g_iDays[i]-1][i] > 0 && g_iGived[g_iDays[i]-1][i] == 1) { for (int t; t < 30; t++) { g_iGived[t][i] = 0; } g_iDays[i] = 0; } } g_iTime[i] = 0; MC_PrintToChat(iClient, "%t %t", "CM_Prefix", "CM_Bonus_Available"); C_PrintToChat(iClient, "%t %t", "Prefix", "Bonus_Available"); } } } }
ОтредачилТеперь время не идет, просто стоит
Сейчас проверюОтредачил
Время начало работать, но текст не выводится игрокуОтредачил
public Action CountTime(Handle hTimer)
{
for(int i = 1, t; i <= MaxClients; i++)
if(IsClientInGame(i) && !IsFakeClient(i) && GetClientTeam(i) > 1 && g_iTime[i]++ > iBonusTime)
{
if(++g_iDays[i] > 0 && !g_iGived[g_iDays[i]][i])
{
g_iGived[g_iDays[i]][i] = 1;
if(g_iDays[i] >= 30) g_iDays[i] = 0;
if(g_iGived[g_iDays[i]-1][i] == 1)
{
for(t = 0; t < 30; t++) g_iGived[t][i] = 0;
g_iDays[i] = 0;
}
}
g_iTime[i] = 0;
MC_PrintToChat(i, "%t %t", "CM_Prefix", "CM_Bonus_Available");
C_PrintToChat(i, "%t %t", "Prefix", "Bonus_Available");
}
}
g_iTime[i]++ > iBonusTime
возможно следовало бы ++
поставить перед g_iTime[i]
, а не после (или заменить на g_iTime[i]+1 > iBonusTime
). Но это не точно.g_iTime[i]
сравнивается с iBonusTime
и если iBonusTime
больше, чем iBonusTime
, то значение g_iTime[i]
обнуляется, иначе увеличивается на единицу.пробуйНужно чтобы с 2 раунда выдавало деньги 16к и броня с хп по 105
#pragma newdecls required
#pragma semicolon 1
#include <cstrike>
#include <sdktools_gamerules>
#include <premium_core>
#define SPAWN_HEALTH "SpawnHealth"
#define EXTRA_CASH "ExtraCash"
bool
bLoaded;
int
iRoundCount;
public void OnPluginStart()
{
HookEvent("player_spawn", Event_Spawn);
}
public void OnMapStart()
{
iRoundCount = 0;
}
public void Premium_OnPremiumLoaded()
{
bLoaded = true;
Premium_AddFeature(SPAWN_HEALTH);
Premium_AddFeature(EXTRA_CASH);
}
public void CS_OnTerminateRound(float& delay, CSRoundEndReason& reason)
{
if(reason == CSRoundEnd_GameStart) iRoundCount = 0;
else iRoundCount++;
}
public void Event_Spawn(Event event, const char[] name, bool silent)
{
if(!bLoaded || iRoundCount < 1 || GameRules_GetProp("m_bWarmupPeriod"))
return;
int client = GetClientOfUserId(event.GetInt("userid"));
if(!client)
return;
if(Premium_IsFeatureUse(client, SPAWN_HEALTH))
{
SetEntityHealth(client, 105);
SetEntProp(client, Prop_Data, "m_ArmorValue", 105);
SetEntProp(client, Prop_Send, "m_bHasHelmet", 1);
}
if(Premium_IsFeatureUse(client, EXTRA_CASH)) SetEntProp(client, Prop_Send, "m_iAccount", 16000);
}
public void OnPluginEnd()
{
if(GetFeatureStatus(FeatureType_Native, "Premium_RemoveFeature") != FeatureStatus_Available)
return;
Premium_RemoveFeature(SPAWN_HEALTH);
Premium_RemoveFeature(EXTRA_CASH);
}
#pragma newdecls required
#pragma semicolon 1
#include <sdkhooks>
#include <cstrike>
#include <premium_core>
#include <csgo_colors>
#define RESTRICT "Restrict"
enum iTeamNum
{
TERRORIST = 2,
COUNTERTERRORIST
}
bool bUse[iTeamNum];
public void Premium_OnPremiumLoaded()
{
Premium_AddFeature(RESTRICT);
}
public void OnClientPutInServer(int client)
{
SDKHook(client, SDKHook_WeaponCanUse, WeaponCanUse);
SDKHook(client, SDKHook_WeaponDrop, WeaponDrop);
}
Action WeaponCanUse(int client, int weapon)
{
char sWeapon[32];
GetEntityClassname(weapon, sWeapon, sizeof(sWeapon));
if(!strcmp(sWeapon, "weapon_scar20") || !strcmp(sWeapon, "weapon_g3sg1")) return Plugin_Handled;
if(Premium_IsFeatureUse(client, RESTRICT)) return Plugin_Continue;
if(!strcmp(sWeapon, "weapon_awp"))
{
int iTeam = GetClientTeam(client);
if(bUse[iTeam])
{
CGOPrintToChat(client, "{GREEN}AG {DEFAULT}| AWP ограничено 1 на команду");
return Plugin_Handled;
}
else
{
bUse[iTeam] = true;
return Plugin_Continue;
}
}
return Plugin_Continue;
}
Action WeaponDrop(int client, int weapon)
{
if(Premium_IsFeatureUse(client, RESTRICT)) return Plugin_Continue;
int iTeam = GetClientTeam(client);
if(bUse[iTeam]) bUse[iTeam] = false;
return Plugin_Continue;
}
public Action CS_OnBuyCommand(int client, const char[] sWeapon)
{
if(!strcmp(sWeapon, "scar20") || !strcmp(sWeapon, "g3sg1")) return Plugin_Handled;
if(!Premium_IsFeatureUse(client, RESTRICT)) return Plugin_Continue;
if(!strcmp(sWeapon, "awp"))
{
int iTeam = GetClientTeam(client);
if(bUse[iTeam])
{
return Plugin_Handled;
}
}
return Plugin_Continue;
}
public void OnPluginEnd()
{
if(GetFeatureStatus(FeatureType_Native, "Premium_RemoveFeature") == FeatureStatus_Available)
Premium_RemoveFeature(RESTRICT);
}
Попробую, спасибо большое)@7pElllHuK, я бы сократил до вот такого:
Ну и в проверкеC-подобный:public Action CountTime(Handle hTimer) { for(int i = 1, t; i <= MaxClients; i++) if(IsClientInGame(i) && !IsFakeClient(i) && GetClientTeam(i) > 1 && g_iTime[i]++ > iBonusTime) { if(++g_iDays[i] > 0 && !g_iGived[g_iDays[i]][i]) { g_iGived[g_iDays[i]][i] = 1; if(g_iDays[i] >= 30) g_iDays[i] = 0; if(g_iGived[g_iDays[i]-1][i] == 1) { for(t = 0; t < 30; t++) g_iGived[t][i] = 0; g_iDays[i] = 0; } } g_iTime[i] = 0; MC_PrintToChat(i, "%t %t", "CM_Prefix", "CM_Bonus_Available"); C_PrintToChat(i, "%t %t", "Prefix", "Bonus_Available"); } }
g_iTime[i]++ > iBonusTime
возможно следовало бы++
поставить передg_iTime[i]
, а не после (или заменить наg_iTime[i]+1 > iBonusTime
). Но это не точно.
Потому что в этой проверкеg_iTime[i]
сравнивается сiBonusTime
и еслиiBonusTime
больше, чемiBonusTime
, то значениеg_iTime[i]
обнуляется, иначе увеличивается на единицу.
пробуйC-подобный:#pragma newdecls required #pragma semicolon 1 #include <cstrike> #include <sdktools_gamerules> #include <premium_core> #define SPAWN_HEALTH "SpawnHealth" #define EXTRA_CASH "ExtraCash" bool bLoaded; int iRoundCount; public void OnPluginStart() { HookEvent("player_spawn", Event_Spawn); } public void OnMapStart() { iRoundCount = 0; } public void Premium_OnPremiumLoaded() { bLoaded = true; Premium_AddFeature(SPAWN_HEALTH); Premium_AddFeature(EXTRA_CASH); } public void CS_OnTerminateRound(float& delay, CSRoundEndReason& reason) { if(reason == CSRoundEnd_GameStart) iRoundCount = 0; else iRoundCount++; } public void Event_Spawn(Event event, const char[] name, bool silent) { if(!bLoaded || iRoundCount < 1 || GameRules_GetProp("m_bWarmupPeriod")) return; int client = GetClientOfUserId(event.GetInt("userid")); if(!client) return; if(Premium_IsFeatureUse(client, SPAWN_HEALTH)) { SetEntityHealth(client, 105); SetEntProp(client, Prop_Data, "m_ArmorValue", 105); SetEntProp(client, Prop_Send, "m_bHasHelmet", 1); } if(Premium_IsFeatureUse(client, EXTRA_CASH)) SetEntProp(client, Prop_Send, "m_iAccount", 16000); } public void OnPluginEnd() { if(GetFeatureStatus(FeatureType_Native, "Premium_RemoveFeature") != FeatureStatus_Available) return; Premium_RemoveFeature(SPAWN_HEALTH); Premium_RemoveFeature(EXTRA_CASH); }
zr_lm_knockback
(значения от 0.0 до 10.0, это коэффициент умножения урона от мины на силу отталкивания). Значение можно прописать в server.cfg
, если не устраивает стандартное 0.1
.#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <csgo_colors>
#pragma newdecls required
Database dbHandle;
Handle hTimer;
int iTime;
public Plugin myinfo =
{
name = "TopPlayedMaps",
author = "Madness",
version = "1.0"
}
public void OnPluginStart()
{
Database.Connect(SQL_ConnectCallBack, "topPlayedMaps");
}
public void OnMapStart()
{
if(GetTickedTime() >= 4000) CreateTimer(7.0, OnMapStartedProcess, _, TIMER_FLAG_NO_MAPCHANGE);
hTimer = CreateTimer(10.0, OnTimerPrintToChat, _, TIMER_REPEAT);
}
public void OnMapEnd()
{
if(hTimer) delete hTimer;
}
public Action OnMapStartedProcess(Handle timer)
{
char curMap[128], postMap[128], query[256];
GetCurrentMap(curMap, 128);
if(StrContains(curMap, "workshop") != -1)
{
GetCurrentWorkshopMap(curMap, 128);
}
dbHandle.Escape(curMap, postMap, 128);
FormatEx(query, 256, "SELECT `id`, `played` FROM `maps` WHERE `map` = '%s';", postMap);
dbHandle.Query(SQL_GetMapPlayedCount, query);
}
public Action OnTimerPrintToChat(Handle timer)
{
int curTime = GetTime();
if(iTime <= curTime)
{
ShowTopMaps();
iTime = GetTime() + 900;
}
}
void ShowTopMaps()
{
char query[256];
FormatEx(query, 256, "SELECT `map`, `played` FROM `maps` WHERE `played` != 0 ORDER BY `played` DESC LIMIT 5;");
dbHandle.Query(SQL_ShowTopMaps, query);
}
public void SQL_ShowTopMaps(Database db, DBResultSet results, const char[] error, any data)
{
if(error[0])
{
LogError("SQL_ShowTopMaps: %s", error);
return;
}
int count = 0;
while (results.FetchRow())
{
count++;
char map[128], color[13];
results.FetchString(0, map, 128);
switch(count)
{
case 1:
{
Format(color, 13, "{OLIVE}");
CGOPrintToChatAll("{GREEN}Топ {RED}5 {DEFAULT}самых {GREEN}играемых {DEFAULT}карт:");
}
case 2: Format(color, 13, "{LIGHTOLIVE}");
case 3: Format(color, 13, "{GRAY}");
case 4: Format(color, 13, "{DEFAULT}");
case 5: Format(color, 13, "{DEFAULT}");
}
CGOPrintToChatAll("%s%i место - %s%s - {RED}%i {DEFAULT}", color, count, color, map, results.FetchInt(1));
}
}
public void SQL_GetMapPlayedCount(Database db, DBResultSet results, const char[] error, any data)
{
if(error[0])
{
LogError("SQL_GetMapPlayedCount: %s", error);
return;
}
char query[256];
if(results.FetchRow())
{
FormatEx(query, 256, "UPDATE `maps` SET `played` = %i WHERE `id` = %i;", results.FetchInt(1) + 1, results.FetchInt(0));
dbHandle.Query(SQL_CheckError, query);
}
else
{
char curMap[128], postMap[128];
GetCurrentMap(curMap, 128);
if(StrContains(curMap, "workshop") != -1)
{
GetCurrentWorkshopMap(curMap, 128);
}
dbHandle.Escape(curMap, postMap, 128);
FormatEx(query, 256, "INSERT INTO `maps` (`map`, `played`) VALUES ('%s', '%i');", postMap, 1);
dbHandle.Query(SQL_CheckError, query);
}
}
public void SQL_ConnectCallBack(Database db, const char[] error, any data)
{
if (db == null)
{
SetFailState("Database failure: %s", error);
return;
}
dbHandle = db;
SQL_LockDatabase(dbHandle);
dbHandle.Query(SQL_CheckError, "CREATE TABLE IF NOT EXISTS `maps` (`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,\
`map` VARCHAR(128) NOT NULL,\
`played` INTEGER NOT NULL);");
SQL_UnlockDatabase(dbHandle);
dbHandle.SetCharset("utf8");
}
public void SQL_CheckError(Database db, DBResultSet results, const char[] error, any data)
{
if(error[0])
{
LogError("SQL_CheckError: %s", error);
}
}
// from alliedmodders
void GetCurrentWorkshopMap(char[] szMap, int iMapBuf)
{
char szCurMap[128];
char szCurMapSplit[2][128];
GetCurrentMap(szCurMap, 128);
ReplaceString(szCurMap, 128, "workshop/", "", false);
ExplodeString(szCurMap, "/", szCurMapSplit, 2, 128);
strcopy(szMap, iMapBuf, szCurMapSplit[1]);
}
AUTOINCREMENT => AUTO_INCREMENTКто-нибудь может добавить поддержку MySQL сюда?
Возможно платно![]()
topplayedmaps.sp:#pragma semicolon 1 #include <sourcemod> #include <sdktools> #include <csgo_colors> #pragma newdecls required Database dbHandle; Handle hTimer; int iTime; public Plugin myinfo = { name = "TopPlayedMaps", author = "Madness", version = "1.0" } public void OnPluginStart() { Database.Connect(SQL_ConnectCallBack, "topPlayedMaps"); } public void OnMapStart() { if(GetTickedTime() >= 4000) CreateTimer(7.0, OnMapStartedProcess, _, TIMER_FLAG_NO_MAPCHANGE); hTimer = CreateTimer(10.0, OnTimerPrintToChat, _, TIMER_REPEAT); } public void OnMapEnd() { if(hTimer) delete hTimer; } public Action OnMapStartedProcess(Handle timer) { char curMap[128], postMap[128], query[256]; GetCurrentMap(curMap, 128); if(StrContains(curMap, "workshop") != -1) { GetCurrentWorkshopMap(curMap, 128); } dbHandle.Escape(curMap, postMap, 128); FormatEx(query, 256, "SELECT `id`, `played` FROM `maps` WHERE `map` = '%s';", postMap); dbHandle.Query(SQL_GetMapPlayedCount, query); } public Action OnTimerPrintToChat(Handle timer) { int curTime = GetTime(); if(iTime <= curTime) { ShowTopMaps(); iTime = GetTime() + 900; } } void ShowTopMaps() { char query[256]; FormatEx(query, 256, "SELECT `map`, `played` FROM `maps` WHERE `played` != 0 ORDER BY `played` DESC LIMIT 5;"); dbHandle.Query(SQL_ShowTopMaps, query); } public void SQL_ShowTopMaps(Database db, DBResultSet results, const char[] error, any data) { if(error[0]) { LogError("SQL_ShowTopMaps: %s", error); return; } int count = 0; while (results.FetchRow()) { count++; char map[128], color[13]; results.FetchString(0, map, 128); switch(count) { case 1: { Format(color, 13, "{OLIVE}"); CGOPrintToChatAll("{GREEN}Топ {RED}5 {DEFAULT}самых {GREEN}играемых {DEFAULT}карт:"); } case 2: Format(color, 13, "{LIGHTOLIVE}"); case 3: Format(color, 13, "{GRAY}"); case 4: Format(color, 13, "{DEFAULT}"); case 5: Format(color, 13, "{DEFAULT}"); } CGOPrintToChatAll("%s%i место - %s%s - {RED}%i {DEFAULT}", color, count, color, map, results.FetchInt(1)); } } public void SQL_GetMapPlayedCount(Database db, DBResultSet results, const char[] error, any data) { if(error[0]) { LogError("SQL_GetMapPlayedCount: %s", error); return; } char query[256]; if(results.FetchRow()) { FormatEx(query, 256, "UPDATE `maps` SET `played` = %i WHERE `id` = %i;", results.FetchInt(1) + 1, results.FetchInt(0)); dbHandle.Query(SQL_CheckError, query); } else { char curMap[128], postMap[128]; GetCurrentMap(curMap, 128); if(StrContains(curMap, "workshop") != -1) { GetCurrentWorkshopMap(curMap, 128); } dbHandle.Escape(curMap, postMap, 128); FormatEx(query, 256, "INSERT INTO `maps` (`map`, `played`) VALUES ('%s', '%i');", postMap, 1); dbHandle.Query(SQL_CheckError, query); } } public void SQL_ConnectCallBack(Database db, const char[] error, any data) { if (db == null) { SetFailState("Database failure: %s", error); return; } dbHandle = db; SQL_LockDatabase(dbHandle); dbHandle.Query(SQL_CheckError, "CREATE TABLE IF NOT EXISTS `maps` (`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,\ `map` VARCHAR(128) NOT NULL,\ `played` INTEGER NOT NULL);"); SQL_UnlockDatabase(dbHandle); dbHandle.SetCharset("utf8"); } public void SQL_CheckError(Database db, DBResultSet results, const char[] error, any data) { if(error[0]) { LogError("SQL_CheckError: %s", error); } } // from alliedmodders void GetCurrentWorkshopMap(char[] szMap, int iMapBuf) { char szCurMap[128]; char szCurMapSplit[2][128]; GetCurrentMap(szCurMap, 128); ReplaceString(szCurMap, 128, "workshop/", "", false); ExplodeString(szCurMap, "/", szCurMapSplit, 2, 128); strcopy(szMap, iMapBuf, szCurMapSplit[1]); }