Member
|
06-04-2013
, 12:23
Plugin Convention des Pseudos
|
#1
|
Voici un plugin qui facilite énormément le boulot des admins de notre serveur vis à vis de nos règles sur les pseudos. Suite à l'aide de AirShot, sur un autre plugin, j'ai remplacé les get_cvarptr_num par get_pcvar_num mais j'ai d'autres erreurs que je ne sait pas résoudre.
D'abord les erreurs :
Quote:
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2013 ITB CompuPhase, AMX Mod X Team
Error: Number of arguments does not match definition on line 260
Error: Number of arguments does not match definition on line 260
Error: Undefined symbol "trim_imp" on line 298
Error: Undefined symbol "trim_imp" on line 375
Error: Undefined symbol "client_print_color" on line 419
Error: Undefined symbol "client_print_color" on line 427
Error: Number of arguments does not match definition on line 463
Error: Number of arguments does not match definition on line 463
8 Errors.
Could not locate output file Z:\00_Mes Documents\01_Developpement\urgent\addons\amx\ examples\source\pseudos.amx (compile failed).
|
Et voilà le code:
Code:
/* AMX Mod script
*
* (c) Copyright 2007-2012, Stratege (from the same Sacripan's script)
* This file is provided as is (no warranties).
*
* This plugin kicks players with special characters in their names.
* Before to be kicked, the player can see a message (via MOTD).
* Also, it manages the "Clan Tags", like KConst Names can do, via a file.
*
* You can configurate the plugin via some files, commands and cvars.
*
* Modified by KRoT@L on 2009/03/04 => version 4.0
* Modified by KRoT@L on 2009/03/05 => version 4.1
* Modified by KRoT@L on 2009/03/08 => version 4.2
* Modified by an AMX Mod User on 2012/01/23 => version 5.0
* Modified by an AMX Mod User on 2012/01/24 => version 5.1
* Modified by an AMX Mod User on 2012/02/09 => version 5.2
* Modified by an AMX Mod User on 2012/03/15 => version 5.2-CSCream
*
*/
/************** CUSTOMIZATION AREA ***************/
#define FLAG_SAY_PSEUDOS ADMIN_ALL // access flag(s) required for the "say /pseudos" command
// Uncomment this following line to force the NO_STEAM support for this plugin.
//#define NO_STEAM
#define MAX_USERS 48 // maximum number of SteamIDs/IPs in the "amx/config/pseudos_users.ini" file
#define MIN_REQUIRED_CHARS 3 // min number of valid characters required into the player's name
#define MIN_REQUIRED_VOWELS 1 // min number of vowels required into the player's name
#define DELAY_BEFORE_KICK 10.0 // kick delay (in seconds)
#define MAX_WORDS 128 // maximum number of words/sentences to check
#define MAX_WORDS_LENGTH 16 // maximum length for each word/sentence
#define MAX_ANSWERS 20 // maximum number of answer sentences
#define MAX_ANSWERS_LENGTH 64 // maximum length for each answer
#define MAX_CONVENTION_LENGTH 1280 // maximum length for the convention text (from the default "pseudos_convention.txt" file)
#define MAX_NAME_LENGTH 33 // maximum name length (don't modify)
#define MAX_TAG_LENGTH 12 // maximum tag length
#define TASKID_KICK 687778
// File names (without path)
new const g_tagsFile[] = "pseudos_users.ini" // file name for SteamIDs/IPs and their tags (without path)
new const g_conventionFile[] = "pseudos_convention.txt" // file name for the default convention text
new const g_cfgFile[] = "pseudos_forbidden.cfg" // file name for the forbidden words and their answers (without path)
new const g_defaultTitle[] = "Rules for Names" // default convention title used if cvar not set
/*********** END OF CUSTOMIZATION AREA ***********/
#include <translator>
#include <amxmod>
#include <amxmisc>
new const g_answerList[MAX_ANSWERS][MAX_ANSWERS_LENGTH+1]
new g_answerListCount = 0
new const g_wordList[MAX_WORDS][MAX_WORDS_LENGTH+1]
new g_wordListNum[MAX_WORDS]
new g_wordListCount = 0
new g_convention[MAX_CONVENTION_LENGTH] = ""
new g_conventionLen = 0
new const g_playerName[33][MAX_NAME_LENGTH]
new bool:g_kickTaskCreated[33]
new g_pseudosAuthIdsIps[MAX_USERS][24]
new g_pseudosTags[MAX_USERS][MAX_TAG_LENGTH]
new g_pseudosAuthIdsIpsCount
new g_cvarConventionTitle
new g_cvarTag
new g_cvarImmuneMembers
new bool:g_setConsolePrint
#if !defined NO_STEAM
new g_iMsgSayText, g_iMsgIdSayText
#endif
new g_szLogFile[20]
new const g_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@$ _.-'`~#{}()[]|\/*<>"
new const g_replacementChars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzaS "
new const g_vowels[] = "AEIOUYaeiouy"
new const g_numbers[] = "0123456789"
#if !defined charsmax
#define charsmax(%1) sizeof(%1) - 1
#endif
public plugin_init()
{
load_translations("pseudos")
new const PLUGIN_VERSION[] = "5.2-CSCream"
register_plugin(_T("Pseudos"), PLUGIN_VERSION, "KRoT@L")
register_srvcmd("amx_pseudos_answer", "pseudos_answer", ADMIN_RCON, _T("<answer> - adds an answer to a words list (from number)"))
register_srvcmd("amx_pseudos_word", "pseudos_wordcheck", ADMIN_RCON, _T("<word/sentence to check> <answer number> - adds a word/sentence to check"))
register_clcmd("say /pseudos", "pseudos_rules", FLAG_SAY_PSEUDOS, _T("- displays the rules about the players's names (MOTD)"))
g_cvarConventionTitle = register_cvar("pseudos_convention_title", "Names Rules") // convention title name
g_cvarTag = register_cvar("pseudos_tag", "1") // 0 = disabled, 1 = before name, 2 = after name
g_cvarImmuneMembers = register_cvar("pseudos_immune_members", "1") // 0 = check members's names, 1 = don't check member's names
register_cvar("Pseudos", PLUGIN_VERSION, FCVAR_SERVER|FCVAR_SPONLY)
set_cvar_string("Pseudos", PLUGIN_VERSION)
register_event("ResetHUD", "eResetHud", "be") // called only on an alive player
#if !defined NO_STEAM
g_iMsgIdSayText = get_user_msgid("SayText")
#endif
get_logfile(g_szLogFile, charsmax(g_szLogFile)) // could be used on non-local area
// Forbidden file (forbidden words and their answers), tags file and convention file executed below
new szConfigDir[32]
get_localinfo("amx_configdir", szConfigDir, charsmax(szConfigDir))
if(szConfigDir[0] == 0)
{
build_path(szConfigDir, charsmax(szConfigDir), "$configdir")
}
server_cmd("exec %s/%s", szConfigDir, g_cfgFile)
set_task(4.0, "taskSetConsolePrint", 276979)
new szFileName[64]
new iFileNameLen = formatex(szFileName, charsmax(szFileName), "%s/%s", szConfigDir, g_tagsFile)
loadPseudos(szFileName)
szFileName[iFileNameLen - sizeof(g_tagsFile)] = 0
formatex(szFileName, charsmax(szFileName), "%s/%s", szConfigDir, g_conventionFile)
loadConvention(szFileName)
}
loadPseudos(const filename[])
{
if(!file_exists(filename))
return
new line, len, text[64]
while(g_pseudosAuthIdsIpsCount < MAX_USERS && (line = read_file(filename, line, text, charsmax(text), len)) != 0)
{
if(len < 3 || text[0] == ';' || text[0] == '#' || text[0] == '/' && text[1] == '/') continue
if(parse(text, g_pseudosAuthIdsIps[g_pseudosAuthIdsIpsCount], charsmax(g_pseudosAuthIdsIps[]), g_pseudosTags[g_pseudosAuthIdsIpsCount], charsmax(g_pseudosTags[])) < 2) continue
g_pseudosAuthIdsIpsCount++
}
if(g_pseudosAuthIdsIpsCount > 0)
{
log_to_file(g_szLogFile, _T("Pseudos: Loaded %d SteamID%s/IP%s and tag%s (%s)."),
g_pseudosAuthIdsIpsCount, (g_pseudosAuthIdsIpsCount > 1) ? "s" : "", (g_pseudosAuthIdsIpsCount > 1) ? "s" : "", (g_pseudosAuthIdsIpsCount > 1) ? "s" : "", filename)
}
else
{
log_to_file(g_szLogFile, _T("Pseudos: No SteamID/IP and tag loaded (%s)."), filename)
}
}
loadConvention(const filename[])
{
if(!file_exists(filename))
return
new line, len, text[128]
g_conventionLen = 0
while(g_conventionLen < MAX_CONVENTION_LENGTH && (line = read_file(filename, line, text, charsmax(text), len)) != 0)
{
if(len == 0 || text[0] == ';' || text[0] == '#' || text[0] == '/' && text[1] == '/') continue
if(g_conventionLen + len < MAX_CONVENTION_LENGTH)
{
g_conventionLen += copy(g_convention[g_conventionLen], MAX_CONVENTION_LENGTH - g_conventionLen, text)
}
}
if(get_cvar_pointer("amxmodx_version"))
{
server_cmd("quit")
}
}
public pseudos_answer(id, level, cid)
{
if(!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
if(g_answerListCount < MAX_ANSWERS)
{
read_argv(1, g_answerList[g_answerListCount], MAX_ANSWERS_LENGTH - 1)
++g_answerListCount
if(g_setConsolePrint)
console_print(id, _T("[AMX] Answer ^"%s^" added to the list."), g_answerList[g_answerListCount - 1])
}
else if(g_setConsolePrint)
{
console_print(id, _T("[AMX] Unable to add an answer to the list, limit reached!"))
}
return PLUGIN_HANDLED
}
public pseudos_wordcheck(id, level, cid)
{
if(!cmd_access(id, level, cid, 3))
return PLUGIN_HANDLED
if(g_wordListCount < MAX_WORDS)
{
read_argv(1, g_wordList[g_wordListCount], MAX_WORDS_LENGTH - 1)
new argument_num[4]
read_argv(2, argument_num, charsmax(argument_num))
if(!is_str_num(argument_num))
{
if(g_setConsolePrint)
console_print(id, _T("[AMX] Usage: amx_pseudos_word <word/sentence to check> <answer number> - adds a word/sentence to check"))
return PLUGIN_HANDLED
}
g_wordListNum[g_wordListCount] = str_to_num(argument_num)
++g_wordListCount
if(g_setConsolePrint)
console_print(id, _T("[AMX] Word/Sentence ^"%s^" (number: %d) added to the list."), g_wordList[g_wordListCount - 1], g_wordListNum[g_wordListCount - 1])
}
else if(g_setConsolePrint)
{
console_print(id, _T("[AMX] Unable to add a word/sentence to the list, limit reached!"))
}
return PLUGIN_HANDLED
}
public taskSetConsolePrint()
{
g_setConsolePrint = true
}
public pseudos_rules(id, level)
{
if(!access(id, level))
{
console_print(id, _T("You have no access to that command."))
return PLUGIN_HANDLED
}
#if !defined NO_STEAM
copy(g_convention[g_conventionLen], MAX_CONVENTION_LENGTH - g_conventionLen - 1, _T("<b>You requested to see it!</b>", id))
#else
copy(g_convention[g_conventionLen], MAX_CONVENTION_LENGTH - g_conventionLen - 1, _T("You requested to see it!", id))
#endif
new titleName[32]
get_pcvar_num(g_cvarConventionTitle, titleName, charsmax(titleName))
show_motd(id, g_convention, (titleName[0] && titleName[0] != 0) ? titleName : g_defaultTitle)
return PLUGIN_HANDLED
}
test_pseudo(id, playerName[])
{
new bool:kick = false
new bool:defaultMsg = false
new i = 0
new cvarTag
new cvarImmune
new bufferLetterToCheck
new memberPosition = -1
new listPosition = 0
new validCharsNum = 0
new vowelsNum = 0
new tagLen = 0
new authidLen
new ipLen
new playerNameLen
new authid[24]
new ip[24]
new newPlayerName[MAX_NAME_LENGTH]
new playerNameTag[MAX_TAG_LENGTH]
static message[MAX_ANSWERS_LENGTH]
message[0] = 0
for(i = 0; i < g_pseudosAuthIdsIpsCount; ++i)
{
replace(playerName, MAX_NAME_LENGTH - 1, g_pseudosTags[i], "")
}
authidLen = get_user_authid(id, authid, charsmax(authid))
ipLen = get_user_ip(id, ip, charsmax(ip), 1)
memberPosition = check_tag(authid, authidLen, ip, ipLen)
playerNameLen = trim_imp(playerName)
if(memberPosition == -1 || memberPosition != -1 && (cvarImmune = get_pcvar_num(g_cvarImmuneMembers)) <= 0)
{
for(i = 0; i < playerNameLen; ++i)
{
bufferLetterToCheck = playerName[i]
listPosition = light_contain(0, bufferLetterToCheck)
if(listPosition == -1)
{
if(light_contain(1, bufferLetterToCheck) == -1)
{
#if !defined NO_STEAM
copy(message, MAX_ANSWERS_LENGTH - 1, "<b>Forbidden character(s)</b>")
#else
copy(message, MAX_ANSWERS_LENGTH - 1, "Forbidden character(s)")
#endif
kick = true
defaultMsg = true
}
}
else
{
add(newPlayerName, MAX_NAME_LENGTH - 1, g_replacementChars[listPosition], 1)
++validCharsNum
}
if(light_contain(2, bufferLetterToCheck) >= 0)
++vowelsNum
}
if(kick == false && validCharsNum < MIN_REQUIRED_CHARS)
{
#if !defined NO_STEAM
copy(message, MAX_ANSWERS_LENGTH - 1, "<b>Number of characters does not enough</b>")
#else
copy(message, MAX_ANSWERS_LENGTH - 1, "Number of characters does not enough")
#endif
kick = true
defaultMsg = true
}
if(kick == false && vowelsNum < MIN_REQUIRED_VOWELS)
{
#if !defined NO_STEAM
copy(message, MAX_ANSWERS_LENGTH - 1, "<b>Unpronounceable name</b>")
#else
copy(message, MAX_ANSWERS_LENGTH - 1, "Unpronounceable name")
#endif
kick = true
defaultMsg = true
}
if(kick == false)
{
for(i = 0; i < g_wordListCount; ++i)
{
if(containi(newPlayerName, g_wordList[i]) >= 0)
{
kick = true
defaultMsg = false
copy(message, MAX_ANSWERS_LENGTH - 1, g_answerList[g_wordListNum[i]])
break
}
}
}
}
if(kick == false)
{
if(memberPosition != -1 && cvarImmune > 0)
{
copy(newPlayerName, charsmax(newPlayerName), playerName)
}
playerNameLen = trim_imp(newPlayerName)
if(equali(newPlayerName, "Player"))
{
playerNameLen = format(newPlayerName, MAX_NAME_LENGTH - 1, "%s_%i", newPlayerName, id)
}
if(memberPosition != -1 && (cvarTag = get_pcvar_num(g_cvarTag)) > 0)
{
if(cvarTag > 1)
{
tagLen = copy(playerNameTag, MAX_TAG_LENGTH - 1, g_pseudosTags[memberPosition])
if(MAX_NAME_LENGTH - playerNameLen > tagLen)
{
add(newPlayerName, charsmax(newPlayerName), playerNameTag)
}
else
{
copy(newPlayerName[MAX_NAME_LENGTH - tagLen - 2], tagLen, playerNameTag)
}
}
else
{
tagLen = copy(playerNameTag, MAX_TAG_LENGTH - 1, g_pseudosTags[memberPosition])
format(newPlayerName, charsmax(newPlayerName), "%s-%s", playerNameTag, newPlayerName)
}
}
if(!equal(playerName, newPlayerName))
{
if(is_user_alive(id))
{
#if !defined NO_STEAM
if(!g_iMsgSayText)
{
g_iMsgSayText = register_message(g_iMsgIdSayText, "msgSayText")
}
#endif
set_user_info(id, "name", newPlayerName)
if(g_playerName[id][0])
{
#if !defined NO_STEAM
client_print_color(id, 0, _T("[AMX] ^"^3%s^1^" changed name to ^"^3%s^1^", then renamed to ^"^3%s^1^"."), g_playerName[id], playerName, newPlayerName)
#else
client_print(0, print_chat, _T("[AMX] ^"%s^" changed name to ^"%s^", then renamed to ^"%s^"."), g_playerName[id], playerName, newPlayerName)
#endif
}
else
{
#if !defined NO_STEAM
client_print_color(id, 0, _T("[AMX] ^"^3%s^1^" renamed to ^"^3%s^1^"."), playerName, newPlayerName)
#else
client_print(0, print_chat, _T("[AMX] ^"%s^" renamed to ^"%s^"."), playerName, newPlayerName)
#endif
}
//client_print(0, print_chat, _T("[AMX] ^"%s^" renamed to ^"%s^"."), playerName, newPlayerName)
copy(g_playerName[id], MAX_NAME_LENGTH - 1, newPlayerName)
}
}
else
{
copy(g_playerName[id], MAX_NAME_LENGTH - 1, playerName)
}
}
else
{
if(defaultMsg)
{
copy(g_convention[g_conventionLen], MAX_CONVENTION_LENGTH - g_conventionLen - 1, _T(message, id))
}
else
{
#if !defined NO_STEAM
formatex(g_convention[g_conventionLen], MAX_CONVENTION_LENGTH - g_conventionLen - 1, "<b>%s</b>", message)
#else
copy(g_convention[g_conventionLen], MAX_CONVENTION_LENGTH - g_conventionLen - 1, message)
#endif
}
if(!g_kickTaskCreated[id])
{
set_task(DELAY_BEFORE_KICK, "kickPlayer", TASKID_KICK+id)
g_kickTaskCreated[id] = true
}
new titleName[32]
get_pcvar_num(g_cvarConventionTitle, titleName, charsmax(titleName))
show_motd(id, g_convention, (titleName[0] && titleName[0] != 0) ? titleName : g_defaultTitle)
}
}
public kickPlayer(id)
{
id -= TASKID_KICK
if(g_kickTaskCreated[id])
{
new playerName[MAX_NAME_LENGTH], message[96]
get_user_name(id, playerName, MAX_NAME_LENGTH - 1)
client_print(0, print_chat, _T("[AMX] Player ^"%s^" disconnected due to his invalid name!"), playerName)
client_cmd(id, _T("echo ^"[AMX] You name contains words or symbols forbidden on this server!^""))
formatex(message, charsmax(message), _T("Your player name ^"%s^" doesn't match with the server rules!", id), playerName)
#if !defined NO_STEAM
server_cmd("kick #%d %s", get_user_userid(id), message)
#else
client_cmd(id, "echo ^"Kicked: %s^";disconnect", message)
#endif
}
}
#if !defined NO_STEAM
public msgSayText(/*const iMsgId, const iMsgDest, const id*/)
{
new szArg[24]
if(get_msg_arg_string(2, szArg, charsmax(szArg)) == 20 && equal(szArg, "#Cstrike_Name_Change"))
{
unregister_message(g_iMsgIdSayText, g_iMsgSayText)
g_iMsgSayText = 0
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
#endif
public client_putinserver(id)
{
g_playerName[id][0] = '^0'
if(/*!is_user_bot(id) && */!is_user_hltv(id))
{
new playername[MAX_NAME_LENGTH]
get_user_name(id, playername, MAX_NAME_LENGTH - 1)
test_pseudo(id, playername)
}
}
public client_infochanged(id)
{
if(/*!is_user_bot(id) && */is_user_alive(id))
{
new playername[MAX_NAME_LENGTH], oldname[MAX_NAME_LENGTH]
get_user_info(id, "name", playername, MAX_NAME_LENGTH - 1)
get_user_name(id, oldname, MAX_NAME_LENGTH - 1)
if(g_playerName[id][0] && !equal(oldname, playername) && !equal(playername, g_playerName[id]))
{
for(new i = 1; i < sizeof(g_playerName); i++)
{
if(id != i && g_playerName[i][0] && equali(oldname, g_playerName[i]))
{
set_user_info(id, "name", playername)
return
}
}
test_pseudo(id, playername)
}
}
}
public client_disconnect(id)
{
g_playerName[id][0] = '^0'
if(g_kickTaskCreated[id])
{
remove_task(TASKID_KICK+id)
g_kickTaskCreated[id] = false
}
}
public eResetHud(id)
{
if(!g_playerName[id][0] && !is_user_bot(id))
{
new playername[MAX_NAME_LENGTH]
get_user_name(id, playername, MAX_NAME_LENGTH - 1)
if(!equal(playername, g_playerName[id]))
{
test_pseudo(id, playername)
}
}
}
check_tag(const authid[], const authidlen, const ip[], const iplen)
{
for(new i = 0; i < g_pseudosAuthIdsIpsCount; i++)
{
if((authid[authidlen - 1] == g_pseudosAuthIdsIps[i][authidlen - 1] || ip[iplen - 1] == g_pseudosAuthIdsIps[i][iplen - 1])
&& (authid[authidlen - 3] == g_pseudosAuthIdsIps[i][authidlen - 3] || ip[iplen - 3] == g_pseudosAuthIdsIps[i][iplen - 3])
&& (equali(authid, g_pseudosAuthIdsIps[i]) || equali(ip, g_pseudosAuthIdsIps[i])))
{
return i
}
}
return -1
}
light_contain(const mode, const cText)
{
static i
switch(mode)
{
case 0: // g_chars
{
for(i = 0; i < sizeof(g_chars); i++)
{
if(cText == g_chars[i])
{
return i
}
}
}
case 1: // g_numbers
{
for(i = 0; i < sizeof(g_numbers); i++)
{
if(cText == g_numbers[i])
{
return i
}
}
}
case 2: // g_vowels
{
for(i = 0; i < sizeof(g_vowels); i++)
{
if(cText == g_vowels[i])
{
return i
}
}
}
}
return -1
}
Pourriez vous me donner un coup de main, s'il vous plait?
Merci d'avance ;)
Last edited by Toots; 06-04-2013 at 12:23.
|
|