ConfigResult ChatTriggers::OnSourceModConfigChanged(const char *key, const char *value, ConfigSource source, char *error, size_t maxlength) { if (strcmp(key, "PublicChatTrigger") == 0) { delete [] m_PubTrigger; m_PubTrigger = sm_strdup(value); m_PubTriggerSize = strlen(m_PubTrigger); return ConfigResult_Accept; } else if (strcmp(key, "SilentChatTrigger") == 0) { delete [] m_PrivTrigger; m_PrivTrigger = sm_strdup(value); m_PrivTriggerSize = strlen(m_PrivTrigger); return ConfigResult_Accept; } else if (strcmp(key, "SilentFailSuppress") == 0) { g_bSupressSilentFails = strcmp(value, "yes") == 0; return ConfigResult_Accept; } return ConfigResult_Ignore; }
ChatTriggers::ChatTriggers() : m_pSayCmd(NULL), m_bWillProcessInPost(false), m_bTriggerWasSilent(false), m_ReplyTo(SM_REPLY_CONSOLE) { m_PubTrigger = sm_strdup("!"); m_PrivTrigger = sm_strdup("/"); m_PubTriggerSize = 1; m_PrivTriggerSize = 1; m_bIsChatTrigger = false; }
ChatTriggers::ChatTriggers() : m_pSayCmd(NULL), m_bWillProcessInPost(false), m_ReplyTo(SM_REPLY_CONSOLE), m_ArgSBackup(NULL) { m_PubTrigger = sm_strdup("!"); m_PrivTrigger = sm_strdup("/"); m_PubTriggerSize = 1; m_PrivTriggerSize = 1; m_bIsChatTrigger = false; m_bPluginIgnored = true; #if SOURCE_ENGINE == SE_EPISODEONE m_bIsINS = false; #endif }
void CoreProviderImpl::DefineCommand(const char *name, const char *help, const CommandFunc &callback) { char *new_name = sm_strdup(name); char *new_help = sm_strdup(help); int flags = 0; auto ignore_callback = [] (DISPATCH_ARGS) -> void { }; ConCommand *cmd = new ConCommand(new_name, ignore_callback, new_help, flags); ke::RefPtr<CommandHook> hook = AddCommandHook(cmd, callback); ke::RefPtr<CommandImpl> impl = new CommandImpl(cmd, hook); commands_.append(impl); }
Handle_t ConVarManager::CreateConVar(IPluginContext *pContext, const char *name, const char *defaultVal, const char *description, int flags, bool hasMin, float min, bool hasMax, float max) { ConVar *pConVar = NULL; ConVarInfo *pInfo = NULL; Handle_t hndl = 0; /* Find out if the convar exists already */ pConVar = icvar->FindVar(name); /* If the convar already exists... */ if (pConVar) { /* Add convar to plugin's list */ AddConVarToPluginList(pContext, pConVar); /* First find out if we already have a handle to it */ if (convar_cache_lookup(name, &pInfo)) { return pInfo->handle; } else { /* Create and initialize ConVarInfo structure */ pInfo = new ConVarInfo(); pInfo->sourceMod = false; pInfo->pChangeForward = NULL; pInfo->pVar = pConVar; /* If we don't, then create a new handle from the convar */ hndl = handlesys->CreateHandle(m_ConVarType, pInfo, NULL, g_pCoreIdent, NULL); if (hndl == BAD_HANDLE) { delete pInfo; return BAD_HANDLE; } pInfo->handle = hndl; /* Insert struct into caches */ m_ConVars.push_back(pInfo); convar_cache.insert(name, pInfo); TrackConCommandBase(pConVar, this); return hndl; } } /* Prevent creating a convar that has the same name as a console command */ if (FindCommand(name)) { return BAD_HANDLE; } /* Create and initialize ConVarInfo structure */ pInfo = new ConVarInfo(); pInfo->handle = hndl; pInfo->sourceMod = true; pInfo->pChangeForward = NULL; /* Create a handle from the new convar */ hndl = handlesys->CreateHandle(m_ConVarType, pInfo, NULL, g_pCoreIdent, NULL); if (hndl == BAD_HANDLE) { delete pInfo; return BAD_HANDLE; } pInfo->handle = hndl; /* Hardening: remove NOTIFY from any convar plugins attempt to create */ flags &= ~FCVAR_NOTIFY; /* Since an existing convar (or concmd with the same name) was not found , now we can finally create it */ pConVar = new ConVar(sm_strdup(name), sm_strdup(defaultVal), flags, sm_strdup(description), hasMin, min, hasMax, max); pInfo->pVar = pConVar; /* Add convar to plugin's list */ AddConVarToPluginList(pContext, pConVar); /* Insert struct into caches */ m_ConVars.push_back(pInfo); convar_cache.insert(name, pInfo); return hndl; }