PHP Code:
/* AMXModX plugin
* (c) 2009 made by L3X.
*
* ICQ: 8721378
*
*commands:
* sm_checkpass - check or not password from players (default 1)
* sm_setpass - sets the server password
* sm_showpass - Shows the established password
* sm_onshow - show or not password to admin's (default 1)
*
*
*/
#include <sourcemod>
#define ACCESS_FLAG ADMFLAG_KICK
new Handle:Cvar_OnShow = INVALID_HANDLE;
new Handle:Cvar_CheckPass = INVALID_HANDLE;
public Plugin:myinfo =
{
name = "Server password",
author = "L3X",
description = "none"
};
new szPass[40];
public OnPluginStart()
{
RegAdminCmd("sm_setpass", Command_SetPass, ACCESS_FLAG, "sm_setpass [password]");
RegAdminCmd("sm_showpass", Command_ShowPass, ACCESS_FLAG);
Cvar_CheckPass = CreateConVar("sm_checkpass","1");
Cvar_OnShow = CreateConVar("sm_onshow","1");
CreateTimer(20.0, OnSetDefMap, 0, TIMER_REPEAT);
}
public OnClientPostAdminCheck(client)
{
if(!GetConVarInt(Cvar_CheckPass))
return Plugin_Handled;
if(GetUserFlagBits(client) & ACCESS_FLAG)
return Plugin_Handled;
if(IsFakeClient(client))
return Plugin_Handled;
if((GetClientCount(false)) || (StrEqual(szPass, "")))
KickClient(client, "Only players with admin's rights allowed now", GetClientUserId(client));
else
{
new user_pass[sizeof(szPass)];
GetClientInfo(client, "_cw", user_pass, sizeof(user_pass));
if (!StrEqual(szPass, user_pass))
{
KickClient(client, "Kicked: You entered wrong password (setinfo _cw '***')", GetClientUserId(client));
}
}
return Plugin_Continue;
}
public Action:Command_SetPass(client, args)
{
if(!CheckCommandAccess(client, "sm_setpass", ACCESS_FLAG))
return Plugin_Handled;
if (args < 1)
{
ReplyToCommand(client, "[SM] Usage: sm_setpass [password]");
return Plugin_Handled;
}
GetCmdArgString(szPass, 39);
PrintToChat(client, "The password on server is established");
return Plugin_Handled;
}
public Action:Command_ShowPass(client, args)
{
if(!GetConVarInt(Cvar_OnShow))
{
PrintToConsole(client, "The given function is switched off");
return Plugin_Handled;
}
if(GetUserFlagBits(client) & ACCESS_FLAG)
PrintToConsole(client, "Server Password is: %s", szPass);
return Plugin_Handled;
}
public Action:OnSetDefMap(Handle:timer)
{
if(!GetConVarInt(Cvar_CheckPass))
return Plugin_Handled;
if((GetClientCount(true)==0) & (!StrEqual(szPass, "")))
szPass="";
new mapname[32];
GetCurrentMap(mapname, 31);
if((GetClientCount(true)==0) & (!StrEqual("de_dust",mapname)))
ServerCommand("map de_dust");
return Plugin_Handled;
}
How to correct a mistake "warning 213: tag mismatch"(In 44,46,48,50,56,58,64,80,102,103 lines). 15 Warnings...
I can't understand.
__________________