Hy guys!
I got a source code to one simple plugin from:
mug1wara
But, he isn't have more time to write that plugin.
Please help me!
I want:
- MySQL Support
- Time expire - sm_addflagwithexpire <steamid> <flag> <day>
- and Add more flags (example: sm_addflagwithexpire <steamid> <abced> <day>
Source Code:
PHP Code:
#include <sourcemod>
#pragma semicolon 1
char g_sSteamid[32];
public void OnPluginStart()
{
RegAdminCmd("sm_addflagwithexpire", Cmd_AddFlagWithExpire, ADMFLAG_ROOT);
}
public Action Cmd_AddFlagWithExpire(int iClient, int iArgs)
{
if (IsValidClient(iClient))
{
if (iArgs < 0)
{
PrintToChat(iClient, "[SM] Usage: sm_addflagwithexpire <steamid> <flag>");
return Plugin_Handled;
}
GetClientAuthId(iClient, AuthId_Steam2, g_sSteamid, sizeof(g_sSteamid));
char sFlag[256];
GetCmdArgString(sFlag, sizeof(sFlag));
StripQuotes(sFlag);
char szFile[256];
BuildPath(Path_SM, szFile, sizeof(szFile), "configs/admins_simple.ini");
Handle hFile = OpenFile(szFile, "at");
WriteFileLine(hFile, "\"%s\" \"%s\"", g_sSteamid, sFlag);
char sDay[365];
GetCmdArgString(sDay, sizeof(sDay));
StripQuotes(sDay);
StringToFloat(sDay);
CreateTimer(86400.0 * view_as<float>(sDay[sizeof(sDay)]), Timer_Remove, iClient, TIMER_FLAG_NO_MAPCHANGE);
CloseHandle(hFile);
}
return Plugin_Continue;
}
public Action Timer_Remove(Handle hTimer, int iClient)
{
if (IsValidClient(iClient))
{
char szFile[256];
BuildPath(Path_SM, szFile, sizeof(szFile), "configs/admins_simple.ini");
Handle hFile = OpenFile(szFile, "r");
char sLine[4096];
ReadFileLine(hFile, sLine, sizeof(sLine));
if (StrContains(sLine, g_sSteamid))
{
hFile = OpenFile(szFile, "w");
WriteFileLine(hFile, " ");
}
}
}
stock bool IsValidClient(int iClient)
{
if (!(0 < iClient <= MaxClients) || !IsClientInGame(iClient) || IsFakeClient(iClient))
{
return false;
}
return true;
}