Skocz do zawartości

Witamy w Nieoficjalnym polskim support'cie AMX Mod X

Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.
  • Rozpoczynaj nowe tematy i odpowiedaj na inne
  • Zapisz się do tematów i for, aby otrzymywać automatyczne uaktualnienia
  • Dodawaj wydarzenia do kalendarza społecznościowego
  • Stwórz swój własny profil i zdobywaj nowych znajomych
  • Zdobywaj nowe doświadczenia

Dołączona grafika Dołączona grafika

Guest Message by DevFuse
 

Zdjęcie

[Lib] IRC Code De-Duplicator


  • Nie możesz napisać tematu
  • Zaloguj się, aby dodać odpowiedź
Brak odpowiedzi do tego tematu

#1 Adminek AMXX.PL

    Admin :)

  • Bot

Reputacja: 156
Profesjonalista

  • Postów:7 494
  • Lokalizacja:AMXX.PL
Offline

Napisano 28.07.2012 23:26

IRC Code De-Duplicator is a small plugin that makes it easy to register commands to both IRC and the console/in-game chat. I made this to reduce code duplication which makes writing and maintaining a plugin faster and easier.Most of the code is defined in stocks in the include file, but since there is no way to access the arguments of a variable parameter function through a non-native function, there is a plugin to handle ReplyToCommand().UsageEvery plugin that uses this library needs a bit of boilerplate code to work. Code: public OnPluginStart(){ LoadTranslations("common.phrases"); ICDD_Init(ICDD_Loaded);}public OnAllPluginsLoaded() { ICDD_OnAllPluginsLoaded();}public OnLibraryAdded(const String:name[]) { ICDD_OnLibraryAdded(name);}public ICDD_Loaded(){ ICDD_CleanUp();}To register a command, call the following function after ICDD_CleanUp() Code: /** * Creates a command and IRC command as an administrative command. * When this command is invoked, the access rights of the user are * automatically checked before allowing it to continue. * * @param cmd String containing command to register. * @param callback A function to use as a callback for when the command is invoked. * @param adminflags Administrative flags (bitstring) to use for permissions. * @param smDesc Optional description to use for SourceMod help. * @param ircDesc Optional description to use for IRC help. * @param flags Optional command flags. * @noreturn */stock ICDD_RegAdminCmd(const String:cmd[], ICDDCmd:callback, adminflags, const String:smDesc[]="", const String:ircDesc[]="", flags=0)The callback is a function that takes both a client ID and a nickname as a parameter. If a command originated from IRC, the client ID will be -1. All ICDD_ functions that require a user to be passed in take both as parameters and automatically choose the correct function to respond. You should never have to check where the command originated from. Code: /** * Called when a command is invoked. * * @param client The id of the client who invoked the command or -1 if the command came from IRC * @param nick The nickname of the user who invoked hte command * @param args Number of arguments that were in the argument string. * @return An Action value. Not handling the command * means that SourceIRC will report it as "Unknown Command." */functag ICDDCmd Action:public(client, const String:nick[], args);InstallationThe plugin is zipped with the folder structure to allow you to just drop it in.You must use the custom version of SourceIRC attached to this post. I only included the file that I modified and the recompiled plugin. Download SourceIRC 0.1.14 and replace the smx file with the one I have provided.The SourceIRC GetCmdArg function does not work the same as the default GetCmdArg function. SourceIRC returns the first parameter as parameter 0 while the normal function returns the command name. To retain backwards compatability with other SourceIRC plugins, the custom version returns the command name as argument -1.ICDD_GetCmdArg uses the default numbering for command arguments, so argument 0 will be the command name. Attached Files Dołączona grafika icdd.zip (8.2 KB) Dołączona grafika sourceirc.smx (14.5 KB) Dołączona grafika Get Plugin or Get Source (sourceirc.sp - 21.6 KB)

Wyświetl pełny artykuł




Użytkownicy przeglądający ten temat: 0

0 użytkowników, 0 gości, 0 anonimowych