Update CS:GO team score gamedata.
3 * =============================================================================
4 * SourceMod SDKTools Extension
5 * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
6 * =============================================================================
8 * This program is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License, version 3.0, as published by the
10 * Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * You should have received a copy of the GNU General Public License along with
18 * this program. If not, see <http://www.gnu.org/licenses/>.
20 * As a special exception, AlliedModders LLC gives you permission to link the
21 * code of this program (as well as its derivative works) to "Half-Life 2," the
22 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
23 * by the Valve Corporation. You must obey the GNU General Public License in
24 * all respects for all other code used. Additionally, AlliedModders LLC grants
25 * this exception to all derivative works. AlliedModders LLC defines further
26 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
27 * or <http://www.sourcemod.net/license.php>.
32 #include "extension.h"
35 // HookSingleEntityOutput(ent, const String:output[], function, bool:once);
36 cell_t HookSingleEntityOutput(IPluginContext *pContext, const cell_t *params)
38 if (!g_OutputManager.IsEnabled())
40 return pContext->ThrowNativeError("Entity Outputs are disabled - See error logs for details");
43 CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(params[1]);
46 return pContext->ThrowNativeError("Invalid Entity index %i (%i)", gamehelpers->ReferenceToIndex(params[1]), params[1]);
49 const char *classname = g_OutputManager.GetEntityClassname(pEntity);
52 pContext->LocalToString(params[2], &outputname);
54 OutputNameStruct *pOutputName = g_OutputManager.FindOutputPointer((const char *)classname, outputname, true);
56 //Check for an existing identical hook
57 SourceHook::List<omg_hooks *>::iterator _iter;
61 IPluginFunction *pFunction;
62 pFunction = pContext->GetFunctionById(params[3]);
64 for (_iter=pOutputName->hooks.begin(); _iter!=pOutputName->hooks.end(); _iter++)
66 hook = (omg_hooks *)*_iter;
67 if (hook->pf == pFunction && hook->entity_ref == gamehelpers->EntityToReference(pEntity))
73 hook = g_OutputManager.NewHook();
75 hook->entity_ref = gamehelpers->EntityToReference(pEntity);
76 hook->only_once= !!params[4];
78 hook->m_parent = pOutputName;
80 hook->delete_me = false;
82 pOutputName->hooks.push_back(hook);
84 g_OutputManager.OnHookAdded();
86 IPlugin *pPlugin = plsys->FindPluginByContext(pContext->GetContext());
87 SourceHook::List<omg_hooks *> *pList = NULL;
89 if (!pPlugin->GetProperty("OutputHookList", (void **)&pList, false) || !pList)
91 pList = new SourceHook::List<omg_hooks *>;
92 pPlugin->SetProperty("OutputHookList", pList);
95 pList->push_back(hook);
100 // HookEntityOutput(const String:classname[], const String:output[], function);
101 cell_t HookEntityOutput(IPluginContext *pContext, const cell_t *params)
103 if (!g_OutputManager.IsEnabled())
105 return pContext->ThrowNativeError("Entity Outputs are disabled - See error logs for details");
108 //Find or create the base structures for this classname and the output
110 pContext->LocalToString(params[1], &classname);
113 pContext->LocalToString(params[2], &outputname);
115 OutputNameStruct *pOutputName = g_OutputManager.FindOutputPointer((const char *)classname, outputname, true);
117 //Check for an existing identical hook
118 SourceHook::List<omg_hooks *>::iterator _iter;
122 IPluginFunction *pFunction;
123 pFunction = pContext->GetFunctionById(params[3]);
125 for (_iter=pOutputName->hooks.begin(); _iter!=pOutputName->hooks.end(); _iter++)
127 hook = (omg_hooks *)*_iter;
128 if (hook->pf == pFunction && hook->entity_ref == -1)
130 //already hooked to this function...
131 //throw an error or just let them get away with stupidity?
132 // seems like poor coding if they dont know if something is hooked or not
137 hook = g_OutputManager.NewHook();
139 hook->entity_ref = -1;
140 hook->pf = pFunction;
141 hook->m_parent = pOutputName;
142 hook->in_use = false;
143 hook->delete_me = false;
145 pOutputName->hooks.push_back(hook);
147 g_OutputManager.OnHookAdded();
149 IPlugin *pPlugin = plsys->FindPluginByContext(pContext->GetContext());
150 SourceHook::List<omg_hooks *> *pList = NULL;
152 if (!pPlugin->GetProperty("OutputHookList", (void **)&pList, false) || !pList)
154 pList = new SourceHook::List<omg_hooks *>;
155 pPlugin->SetProperty("OutputHookList", pList);
158 pList->push_back(hook);
163 // UnHookEntityOutput(const String:classname[], const String:output[], EntityOutput:callback);
164 cell_t UnHookEntityOutput(IPluginContext *pContext, const cell_t *params)
166 if (!g_OutputManager.IsEnabled())
168 return pContext->ThrowNativeError("Entity Outputs are disabled - See error logs for details");
172 pContext->LocalToString(params[1], &classname);
175 pContext->LocalToString(params[2], &outputname);
177 OutputNameStruct *pOutputName = g_OutputManager.FindOutputPointer((const char *)classname, outputname, false);
184 //Check for an existing identical hook
185 SourceHook::List<omg_hooks *>::iterator _iter;
189 IPluginFunction *pFunction;
190 pFunction = pContext->GetFunctionById(params[3]);
192 for (_iter=pOutputName->hooks.begin(); _iter!=pOutputName->hooks.end(); _iter++)
194 hook = (omg_hooks *)*_iter;
195 if (hook->pf == pFunction && hook->entity_ref == -1)
200 hook->delete_me = true;
204 pOutputName->hooks.erase(_iter);
205 g_OutputManager.CleanUpHook(hook);
214 // UnHookSingleEntityOutput(entity, const String:output[], EntityOutput:callback);
215 cell_t UnHookSingleEntityOutput(IPluginContext *pContext, const cell_t *params)
217 if (!g_OutputManager.IsEnabled())
219 return pContext->ThrowNativeError("Entity Outputs are disabled - See error logs for details");
222 // Find the classname of the entity and lookup the classname and output structures
223 CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(params[1]);
226 return pContext->ThrowNativeError("Invalid Entity index %i (%i)", gamehelpers->ReferenceToIndex(params[1]), params[1]);
229 const char *classname = g_OutputManager.GetEntityClassname(pEntity);
232 pContext->LocalToString(params[2], &outputname);
234 OutputNameStruct *pOutputName = g_OutputManager.FindOutputPointer((const char *)classname, outputname, false);
241 //Check for an existing identical hook
242 SourceHook::List<omg_hooks *>::iterator _iter;
246 IPluginFunction *pFunction;
247 pFunction = pContext->GetFunctionById(params[3]);
249 for (_iter=pOutputName->hooks.begin(); _iter!=pOutputName->hooks.end(); _iter++)
251 hook = (omg_hooks *)*_iter;
252 /* We're not serial checking and just removing by index here - This was always allowed so is left for bcompat */
253 if (hook->pf == pFunction && gamehelpers->ReferenceToIndex(hook->entity_ref) == gamehelpers->ReferenceToIndex(params[1]))
258 hook->delete_me = true;
262 pOutputName->hooks.erase(_iter);
263 g_OutputManager.CleanUpHook(hook);
272 sp_nativeinfo_t g_EntOutputNatives[] =
274 {"HookEntityOutput", HookEntityOutput},
275 {"UnhookEntityOutput", UnHookEntityOutput},
276 {"HookSingleEntityOutput", HookSingleEntityOutput},
277 {"UnhookSingleEntityOutput", UnHookSingleEntityOutput},