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>.
33 #include <sh_string.h>
34 #include "extension.h"
35 #include "vcallbuilder.h"
39 #include "CellRecipientFilter.h"
41 SourceHook::List<ValveCall *> g_RegCalls;
42 SourceHook::List<ICallWrapper *> g_CallWraps;
44 inline void InitPass(ValvePassInfo &info, ValveType vtype, PassType type, unsigned int flags, unsigned int decflags=0)
46 info.decflags = decflags;
53 #define START_CALL() \
54 unsigned char *vptr = pCall->stk_get();
56 #define FINISH_CALL_SIMPLE(vret) \
57 pCall->call->Execute(vptr, vret); \
60 #define ENCODE_VALVE_PARAM(num, which, vnum) \
61 if (EncodeValveParam(pContext, \
64 &pCall->which[vnum], \
71 #define DECODE_VALVE_PARAM(num, which, vnum) \
72 if (DecodeValveParam(pContext, \
75 &pCall->which[vnum], \
82 bool CreateBaseCall(const char *name,
83 ValveCallType vcalltype,
84 const ValvePassInfo *retinfo,
85 const ValvePassInfo params[],
86 unsigned int numParams,
91 if (g_pGameConf->GetOffset(name, &offset))
93 call = CreateValveVCall(offset, vcalltype, retinfo, params, numParams);
96 g_RegCalls.push_back(call);
102 if (g_pGameConf->GetMemSig(name, &addr))
104 call = CreateValveCall(addr, vcalltype, retinfo, params, numParams);
107 g_RegCalls.push_back(call);
116 static cell_t RemovePlayerItem(IPluginContext *pContext, const cell_t *params)
118 static ValveCall *pCall = NULL;
121 ValvePassInfo pass[2];
122 InitPass(pass[0], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL);
123 InitPass(pass[1], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL);
124 if (!CreateBaseCall("RemovePlayerItem", ValveCall_Player, &pass[1], pass, 1, &pCall))
126 return pContext->ThrowNativeError("\"RemovePlayerItem\" not supported by this mod");
128 return pContext->ThrowNativeError("\"RemovePlayerItem\" wrapper failed to initialized");
134 DECODE_VALVE_PARAM(1, thisinfo, 0);
135 DECODE_VALVE_PARAM(2, vparams, 0);
136 FINISH_CALL_SIMPLE(&ret);
140 static cell_t GiveNamedItem(IPluginContext *pContext, const cell_t *params)
142 static ValveCall *pCall = NULL;
145 ValvePassInfo pass[3];
146 InitPass(pass[0], Valve_String, PassType_Basic, PASSFLAG_BYVAL);
147 InitPass(pass[1], Valve_POD, PassType_Basic, PASSFLAG_BYVAL);
148 InitPass(pass[2], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL);
149 if (!CreateBaseCall("GiveNamedItem", ValveCall_Player, &pass[2], pass, 2, &pCall))
151 return pContext->ThrowNativeError("\"GiveNamedItem\" not supported by this mod");
153 return pContext->ThrowNativeError("\"GiveNamedItem\" wrapper failed to initialized");
157 CBaseEntity *pEntity = NULL;
159 DECODE_VALVE_PARAM(1, thisinfo, 0);
160 DECODE_VALVE_PARAM(2, vparams, 0);
161 DECODE_VALVE_PARAM(3, vparams, 1);
162 FINISH_CALL_SIMPLE(&pEntity);
169 edict_t *pEdict = gameents->BaseEntityToEdict(pEntity);
175 return engine->IndexOfEdict(pEdict);
178 static cell_t GetPlayerWeaponSlot(IPluginContext *pContext, const cell_t *params)
180 static ValveCall *pCall = NULL;
183 ValvePassInfo pass[2];
184 InitPass(pass[0], Valve_POD, PassType_Basic, PASSFLAG_BYVAL);
185 InitPass(pass[1], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL);
186 if (!CreateBaseCall("Weapon_GetSlot", ValveCall_Player, &pass[1], pass, 1, &pCall))
188 return pContext->ThrowNativeError("\"Weapon_GetSlot\" not supported by this mod");
190 return pContext->ThrowNativeError("\"Weapon_GetSlot\" wrapper failed to initialized");
194 CBaseEntity *pEntity;
196 DECODE_VALVE_PARAM(1, thisinfo, 0);
197 DECODE_VALVE_PARAM(2, vparams, 0);
198 FINISH_CALL_SIMPLE(&pEntity);
205 edict_t *pEdict = gameents->BaseEntityToEdict(pEntity);
211 return engine->IndexOfEdict(pEdict);
214 static cell_t IgniteEntity(IPluginContext *pContext, const cell_t *params)
216 static ValveCall *pCall = NULL;
219 ValvePassInfo pass[4];
220 InitPass(pass[0], Valve_Float, PassType_Float, PASSFLAG_BYVAL);
221 InitPass(pass[1], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL);
222 InitPass(pass[2], Valve_Float, PassType_Float, PASSFLAG_BYVAL);
223 InitPass(pass[3], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL);
224 if (!CreateBaseCall("Ignite", ValveCall_Entity, NULL, pass, 4, &pCall))
226 return pContext->ThrowNativeError("\"Ignite\" not supported by this mod");
228 return pContext->ThrowNativeError("\"Ignite\" wrapper failed to initialized");
233 DECODE_VALVE_PARAM(1, thisinfo, 0);
234 DECODE_VALVE_PARAM(2, vparams, 0);
235 DECODE_VALVE_PARAM(3, vparams, 1);
236 DECODE_VALVE_PARAM(4, vparams, 2);
237 DECODE_VALVE_PARAM(5, vparams, 3);
238 FINISH_CALL_SIMPLE(NULL);
243 static cell_t ExtinguishEntity(IPluginContext *pContext, const cell_t *params)
245 static ValveCall *pCall = NULL;
248 if (!CreateBaseCall("Extinguish", ValveCall_Entity, NULL, NULL, 0, &pCall))
250 return pContext->ThrowNativeError("\"Extinguish\" not supported by this mod");
252 return pContext->ThrowNativeError("\"Extinguish\" wrapper failed to initialized");
257 DECODE_VALVE_PARAM(1, thisinfo, 0);
258 FINISH_CALL_SIMPLE(NULL);
263 static cell_t TeleportEntity(IPluginContext *pContext, const cell_t *params)
265 static ValveCall *pCall = NULL;
268 ValvePassInfo pass[3];
269 InitPass(pass[0], Valve_Vector, PassType_Basic, PASSFLAG_BYVAL, VDECODE_FLAG_ALLOWNULL);
270 InitPass(pass[1], Valve_QAngle, PassType_Basic, PASSFLAG_BYVAL, VDECODE_FLAG_ALLOWNULL);
271 InitPass(pass[2], Valve_Vector, PassType_Basic, PASSFLAG_BYVAL, VDECODE_FLAG_ALLOWNULL);
272 if (!CreateBaseCall("Teleport", ValveCall_Entity, NULL, pass, 3, &pCall))
274 return pContext->ThrowNativeError("\"Teleport\" not supported by this mod");
276 return pContext->ThrowNativeError("\"Teleport\" wrapper failed to initialized");
281 DECODE_VALVE_PARAM(1, thisinfo, 0);
282 DECODE_VALVE_PARAM(2, vparams, 0);
283 DECODE_VALVE_PARAM(3, vparams, 1);
284 DECODE_VALVE_PARAM(4, vparams, 2);
285 FINISH_CALL_SIMPLE(NULL);
290 #if defined ORANGEBOX_BUILD
291 /* :TODO: This is Team Fortress 2 specific */
292 static cell_t ForcePlayerSuicide(IPluginContext *pContext, const cell_t *params)
294 static ValveCall *pCall = NULL;
297 ValvePassInfo pass[2];
298 InitPass(pass[0], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL);
299 InitPass(pass[1], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL);
300 if (!CreateBaseCall("CommitSuicide", ValveCall_Player, NULL, pass, 2, &pCall))
302 return pContext->ThrowNativeError("\"CommitSuicide\" not supported by this mod");
306 return pContext->ThrowNativeError("\"CommitSuicide\" wrapper failed to initialized");
311 DECODE_VALVE_PARAM(1, thisinfo, 0);
312 *(bool *)(vptr + 4) = false;
313 *(bool *)(vptr + 5) = false;
314 FINISH_CALL_SIMPLE(NULL);
319 static cell_t ForcePlayerSuicide(IPluginContext *pContext, const cell_t *params)
321 static ValveCall *pCall = NULL;
324 if (!CreateBaseCall("CommitSuicide", ValveCall_Player, NULL, NULL, 0, &pCall))
326 return pContext->ThrowNativeError("\"CommitSuicide\" not supported by this mod");
328 return pContext->ThrowNativeError("\"CommitSuicide\" wrapper failed to initialized");
333 DECODE_VALVE_PARAM(1, thisinfo, 0);
334 FINISH_CALL_SIMPLE(NULL);
340 static cell_t SetClientViewEntity(IPluginContext *pContext, const cell_t *params)
342 IGamePlayer *player = playerhelpers->GetGamePlayer(params[1]);
345 return pContext->ThrowNativeError("Invalid client index %d", params[1]);
347 if (!player->IsInGame())
349 return pContext->ThrowNativeError("Client %d is not in game", params[1]);
352 edict_t *pEdict = engine->PEntityOfEntIndex(params[2]);
353 if (!pEdict || pEdict->IsFree())
355 return pContext->ThrowNativeError("Entity %d is not valid", params[2]);
358 engine->SetView(player->GetEdict(), pEdict);
363 static SourceHook::String *g_lightstyle[MAX_LIGHTSTYLES] = {NULL};
364 static cell_t SetLightStyle(IPluginContext *pContext, const cell_t *params)
366 int style = params[1];
367 if (style >= MAX_LIGHTSTYLES)
369 return pContext->ThrowNativeError("Light style %d is invalid (range: 0-%d)", style, MAX_LIGHTSTYLES - 1);
372 if (g_lightstyle[style] == NULL)
374 /* We allocate and never free this because the Engine wants to hold onto it :\
375 * in theory we could hook light style and know whether we're supposed to free
376 * this or not on shutdown, but for ~4K of memory MAX, it doesn't seem worth it yet.
379 g_lightstyle[style] = new SourceHook::String();
383 pContext->LocalToString(params[2], &str);
385 g_lightstyle[style]->assign(str);
387 engine->LightStyle(style, g_lightstyle[style]->c_str());
392 static cell_t SlapPlayer(IPluginContext *pContext, const cell_t *params)
394 static bool s_slap_supported = false;
395 static bool s_slap_setup = false;
396 static ICallWrapper *s_teleport = NULL;
397 static int s_health_offs = 0;
398 static int s_sound_count = 0;
399 static int s_frag_offs = 0;
407 if (IsTeleportSupported())
411 if (IsGetVelocitySupported())
417 if (g_pGameConf->GetOffset("m_iHealth", &s_health_offs) && s_health_offs)
424 s_slap_supported = true;
427 if ((key = g_pGameConf->GetKeyValue("SlapSoundCount")) != NULL)
429 s_sound_count = atoi(key);
434 if (!s_slap_supported)
436 return pContext->ThrowNativeError("This function is not supported on this mod");
439 /* First check if the client is valid */
440 int client = params[1];
441 IGamePlayer *player = playerhelpers->GetGamePlayer(client);
444 return pContext->ThrowNativeError("Client %d is not valid", client);
445 } else if (!player->IsInGame()) {
446 return pContext->ThrowNativeError("Client %d is not in game", client);
449 edict_t *pEdict = player->GetEdict();
450 CBaseEntity *pEntity = pEdict->GetUnknown()->GetBaseEntity();
452 /* See if we should be taking away health */
453 bool should_slay = false;
456 int *health = (int *)((char *)pEntity + s_health_offs);
457 if (*health - params[2] <= 0)
462 *health -= params[2];
466 /* Teleport in a random direction - thank you, Mani!*/
468 GetVelocity(pEntity, &velocity, NULL);
469 velocity.x += ((rand() % 180) + 50) * (((rand() % 2) == 1) ? -1 : 1);
470 velocity.y += ((rand() % 180) + 50) * (((rand() % 2) == 1) ? -1 : 1);
471 velocity.z += rand() % 200 + 100;
472 Teleport(pEntity, NULL, NULL, &velocity);
474 /* Play a random sound */
475 if (params[3] && s_sound_count > 0)
478 const char *sound_name;
479 cell_t player_list[256], total_players = 0;
480 int maxClients = playerhelpers->GetMaxClients();
482 int r = (rand() % s_sound_count) + 1;
483 snprintf(name, sizeof(name), "SlapSound%d", r);
485 if ((sound_name = g_pGameConf->GetKeyValue(name)) != NULL)
488 for (int i=1; i<=maxClients; i++)
490 other = playerhelpers->GetGamePlayer(i);
491 if (other->IsInGame())
493 player_list[total_players++] = i;
497 const Vector & pos = pEdict->GetCollideable()->GetCollisionOrigin();
498 CellRecipientFilter rf;
499 rf.SetToReliable(true);
500 rf.Initialize(player_list, total_players);
501 engsound->EmitSound(rf, client, CHAN_AUTO, sound_name, VOL_NORM, ATTN_NORM, 0, PITCH_NORM, &pos);
507 const char *frag_prop = g_pGameConf->GetKeyValue("m_iFrags");
510 datamap_t *pMap = gamehelpers->GetDataMap(pEntity);
511 typedescription_t *pType = gamehelpers->FindInDataMap(pMap, frag_prop);
514 s_frag_offs = pType->fieldOffset[TD_OFFSET_NORMAL];
526 old_frags = *(int *)((char *)pEntity + s_frag_offs);
532 pluginhelpers->ClientCommand(pEdict, "kill\n");
537 *(int *)((char *)pEntity + s_frag_offs) = old_frags;
543 static cell_t GetClientEyePosition(IPluginContext *pContext, const cell_t *params)
545 IGamePlayer *player = playerhelpers->GetGamePlayer(params[1]);
548 return pContext->ThrowNativeError("Invalid client index %d", params[1]);
550 if (!player->IsInGame())
552 return pContext->ThrowNativeError("Client %d is not in game", params[1]);
556 serverClients->ClientEarPosition(player->GetEdict(), &pos);
559 pContext->LocalToPhysAddr(params[2], &addr);
560 addr[0] = sp_ftoc(pos.x);
561 addr[1] = sp_ftoc(pos.y);
562 addr[2] = sp_ftoc(pos.z);
567 static cell_t GetClientEyeAngles(IPluginContext *pContext, const cell_t *params)
569 int client = params[1];
570 IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(client);
574 return pContext->ThrowNativeError("Invalid client index %d", client);
576 else if (!pPlayer->IsInGame())
578 return pContext->ThrowNativeError("Client %d is not in game", client);
581 edict_t *pEdict = pPlayer->GetEdict();
582 CBaseEntity *pEntity = pEdict->GetUnknown() ? pEdict->GetUnknown()->GetBaseEntity() : NULL;
584 /* We always set the angles for backwards compatibility --
585 * The original function had no return value.
588 bool got_angles = false;
592 got_angles = GetEyeAngles(pEntity, &angles);
596 pContext->LocalToPhysAddr(params[2], &addr);
597 addr[0] = sp_ftoc(angles.x);
598 addr[1] = sp_ftoc(angles.y);
599 addr[2] = sp_ftoc(angles.z);
601 return got_angles ? 1 : 0;
604 static cell_t FindEntityByClassname(IPluginContext *pContext, const cell_t *params)
606 static ValveCall *pCall = NULL;
609 ValvePassInfo pass[3];
610 InitPass(pass[0], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL, VDECODE_FLAG_ALLOWNULL|VDECODE_FLAG_ALLOWWORLD);
611 InitPass(pass[1], Valve_String, PassType_Basic, PASSFLAG_BYVAL);
612 InitPass(pass[2], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL);
613 if (!CreateBaseCall("FindEntityByClassname", ValveCall_EntityList, &pass[2], pass, 2, &pCall))
615 return pContext->ThrowNativeError("\"FindEntityByClassname\" not supported by this mod");
617 return pContext->ThrowNativeError("\"FindEntityByClassname\" wrapper failed to initialized");
621 CBaseEntity *pEntity;
623 *(void **)vptr = g_EntList;
624 DECODE_VALVE_PARAM(1, vparams, 0);
625 DECODE_VALVE_PARAM(2, vparams, 1);
626 FINISH_CALL_SIMPLE(&pEntity);
633 edict_t *pEdict = gameents->BaseEntityToEdict(pEntity);
639 return engine->IndexOfEdict(pEdict);
642 static cell_t CreateEntityByName(IPluginContext *pContext, const cell_t *params)
644 static ValveCall *pCall = NULL;
647 ValvePassInfo pass[3];
648 InitPass(pass[0], Valve_String, PassType_Basic, PASSFLAG_BYVAL);
649 InitPass(pass[1], Valve_POD, PassType_Basic, PASSFLAG_BYVAL);
650 InitPass(pass[2], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL);
651 if (!CreateBaseCall("CreateEntityByName", ValveCall_Static, &pass[2], pass, 2, &pCall))
653 return pContext->ThrowNativeError("\"CreateEntityByName\" not supported by this mod");
655 return pContext->ThrowNativeError("\"CreateEntityByName\" wrapper failed to initialized");
659 CBaseEntity *pEntity = NULL;
661 DECODE_VALVE_PARAM(1, vparams, 0);
662 DECODE_VALVE_PARAM(2, vparams, 1);
663 FINISH_CALL_SIMPLE(&pEntity);
670 edict_t *pEdict = gameents->BaseEntityToEdict(pEntity);
676 return engine->IndexOfEdict(pEdict);
679 static cell_t DispatchSpawn(IPluginContext *pContext, const cell_t *params)
681 static ValveCall *pCall = NULL;
684 ValvePassInfo pass[2];
685 InitPass(pass[0], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL);
686 InitPass(pass[1], Valve_POD, PassType_Basic, PASSFLAG_BYVAL);
687 if (!CreateBaseCall("DispatchSpawn", ValveCall_Static, &pass[1], pass, 1, &pCall))
689 return pContext->ThrowNativeError("\"DispatchSpawn\" not supported by this mod");
691 return pContext->ThrowNativeError("\"DispatchSpawn\" wrapper failed to initialized");
697 DECODE_VALVE_PARAM(1, vparams, 0);
698 FINISH_CALL_SIMPLE(&ret);
700 return (ret == -1) ? 0 : 1;
703 static cell_t DispatchKeyValue(IPluginContext *pContext, const cell_t *params)
705 static ValveCall *pCall = NULL;
708 ValvePassInfo pass[3];
709 InitPass(pass[0], Valve_String, PassType_Basic, PASSFLAG_BYVAL);
710 InitPass(pass[1], Valve_String, PassType_Basic, PASSFLAG_BYVAL);
711 InitPass(pass[2], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL);
712 if (!CreateBaseCall("DispatchKeyValue", ValveCall_Entity, &pass[2], pass, 2, &pCall))
714 return pContext->ThrowNativeError("\"DispatchKeyValue\" not supported by this mod");
716 return pContext->ThrowNativeError("\"DispatchKeyValue\" wrapper failed to initialized");
722 DECODE_VALVE_PARAM(1, thisinfo, 0);
723 DECODE_VALVE_PARAM(2, vparams, 0);
724 DECODE_VALVE_PARAM(3, vparams, 1);
725 FINISH_CALL_SIMPLE(&ret);
727 return (ret) ? 1 : 0;
730 static cell_t DispatchKeyValueFloat(IPluginContext *pContext, const cell_t *params)
732 static ValveCall *pCall = NULL;
735 ValvePassInfo pass[3];
736 InitPass(pass[0], Valve_String, PassType_Basic, PASSFLAG_BYVAL);
737 InitPass(pass[1], Valve_Float, PassType_Float, PASSFLAG_BYVAL);
738 InitPass(pass[2], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL);
739 if (!CreateBaseCall("DispatchKeyValueFloat", ValveCall_Entity, &pass[2], pass, 2, &pCall))
741 return pContext->ThrowNativeError("\"DispatchKeyValueFloat\" not supported by this mod");
743 return pContext->ThrowNativeError("\"DispatchKeyValueFloat\" wrapper failed to initialized");
749 DECODE_VALVE_PARAM(1, thisinfo, 0);
750 DECODE_VALVE_PARAM(2, vparams, 0);
751 DECODE_VALVE_PARAM(3, vparams, 1);
752 FINISH_CALL_SIMPLE(&ret);
754 return (ret) ? 1 : 0;
757 static cell_t DispatchKeyValueVector(IPluginContext *pContext, const cell_t *params)
759 static ValveCall *pCall = NULL;
762 ValvePassInfo pass[3];
763 InitPass(pass[0], Valve_String, PassType_Basic, PASSFLAG_BYVAL);
764 #if defined ORANGEBOX_BUILD
765 InitPass(pass[1], Valve_Vector, PassType_Basic, PASSFLAG_BYVAL);
767 InitPass(pass[1], Valve_Vector, PassType_Object, PASSFLAG_BYVAL|PASSFLAG_OCTOR|PASSFLAG_OASSIGNOP);
769 InitPass(pass[2], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL);
770 if (!CreateBaseCall("DispatchKeyValueVector", ValveCall_Entity, &pass[2], pass, 2, &pCall))
772 return pContext->ThrowNativeError("\"DispatchKeyValueVector\" not supported by this mod");
774 return pContext->ThrowNativeError("\"DispatchKeyValueVector\" wrapper failed to initialized");
780 DECODE_VALVE_PARAM(1, thisinfo, 0);
781 DECODE_VALVE_PARAM(2, vparams, 0);
782 DECODE_VALVE_PARAM(3, vparams, 1);
783 FINISH_CALL_SIMPLE(&ret);
785 return (ret) ? 1 : 0;
788 static cell_t sm_GetClientAimTarget(IPluginContext *pContext, const cell_t *params)
790 int client = params[1];
791 IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(client);
795 return pContext->ThrowNativeError("Invalid client index %d", client);
797 else if (!pPlayer->IsInGame())
799 return pContext->ThrowNativeError("Client %d is not in game", client);
802 return GetClientAimTarget(pPlayer->GetEdict(), params[2] ? true : false);
805 static cell_t sm_SetEntityModel(IPluginContext *pContext, const cell_t *params)
807 static ValveCall *pCall = NULL;
810 ValvePassInfo pass[1];
811 InitPass(pass[0], Valve_String, PassType_Basic, PASSFLAG_BYVAL);
812 if (!CreateBaseCall("SetEntityModel", ValveCall_Entity, NULL, pass, 1, &pCall))
814 return pContext->ThrowNativeError("\"SetEntityModel\" not supported by this mod");
816 return pContext->ThrowNativeError("\"SetEntityModel\" wrapper failed to initialized");
821 DECODE_VALVE_PARAM(1, thisinfo, 0);
822 DECODE_VALVE_PARAM(2, vparams, 0);
823 FINISH_CALL_SIMPLE(NULL);
828 static cell_t GetPlayerDecalFile(IPluginContext *pContext, const cell_t *params)
830 IGamePlayer *player = playerhelpers->GetGamePlayer(params[1]);
833 return pContext->ThrowNativeError("Invalid client index %d", params[1]);
835 if (!player->IsInGame())
837 return pContext->ThrowNativeError("Client %d is not in game", params[1]);
843 if (!GetPlayerInfo(params[1], &info) || !info.customFiles[0])
848 pContext->LocalToString(params[2], &buffer);
849 Q_binarytohex((byte *)&info.customFiles[0], sizeof(info.customFiles[0]), buffer, params[3]);
854 static cell_t GetServerNetStats(IPluginContext *pContext, const cell_t *params)
858 return pContext->ThrowNativeError("IServer interface not supported, file a bug report.");
864 pContext->LocalToPhysAddr(params[1], &pIn);
865 pContext->LocalToPhysAddr(params[2], &pOut);
866 iserver->GetNetStats(in, out);
869 *pOut = sp_ftoc(out);
874 sp_nativeinfo_t g_Natives[] =
876 {"ExtinguishEntity", ExtinguishEntity},
877 {"ForcePlayerSuicide", ForcePlayerSuicide},
878 {"GivePlayerItem", GiveNamedItem},
879 {"GetPlayerWeaponSlot", GetPlayerWeaponSlot},
880 {"IgniteEntity", IgniteEntity},
881 {"RemovePlayerItem", RemovePlayerItem},
882 {"TeleportEntity", TeleportEntity},
883 {"SetClientViewEntity", SetClientViewEntity},
884 {"SetLightStyle", SetLightStyle},
885 {"SlapPlayer", SlapPlayer},
886 {"GetClientEyePosition", GetClientEyePosition},
887 {"GetClientEyeAngles", GetClientEyeAngles},
888 {"FindEntityByClassname", FindEntityByClassname},
889 {"CreateEntityByName", CreateEntityByName},
890 {"DispatchSpawn", DispatchSpawn},
891 {"DispatchKeyValue", DispatchKeyValue},
892 {"DispatchKeyValueFloat", DispatchKeyValueFloat},
893 {"DispatchKeyValueVector", DispatchKeyValueVector},
894 {"GetClientAimTarget", sm_GetClientAimTarget},
895 {"SetEntityModel", sm_SetEntityModel},
896 {"GetPlayerDecalFile", GetPlayerDecalFile},
897 {"GetServerNetStats", GetServerNetStats},