From 8d714dd84eb9d0a5446fc6a154b6fa6370f2c606 Mon Sep 17 00:00:00 2001 From: Steve Dudenhoeffer Date: Tue, 24 Aug 2004 21:05:01 +0000 Subject: [PATCH] Added "ns_give_item" Fixed SPForward registers --- dlls/ns/ns/NMisc.cpp | 26 ++++++++++++++++++++++++++ dlls/ns/ns/hookedfunctions.cpp | 4 ++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/dlls/ns/ns/NMisc.cpp b/dlls/ns/ns/NMisc.cpp index 2240e92f..758efb46 100755 --- a/dlls/ns/ns/NMisc.cpp +++ b/dlls/ns/ns/NMisc.cpp @@ -299,6 +299,30 @@ static cell AMX_NATIVE_CALL ns_set_fov(AMX *amx, cell *params) } return 0; } +static cell AMX_NATIVE_CALL ns_giveitem(AMX *amx, cell *params) +{ + int index=params[1]; + int len; + char *classname = MF_GetAmxString(amx,params[2],0,&len); + if (index<1 || index>gpGlobals->maxClients) + return 0; + edict_t *player=INDEXENT2(index); + if (player->v.deadflag > 0) + return 0; + edict_t *object=CREATE_NAMED_ENTITY(ALLOC_STRING(classname)); //create + if (!object) + { + MF_Log("Error creating entity `%s`",classname); + return 0; + } + SET_ORIGIN(object,player->v.origin); // move to player + gpGamedllFuncs->dllapi_table->pfnSpawn(object); // emulate spawn + object->v.flags |= FL_ONGROUND; // make it think it's touched the ground + gpGamedllFuncs->dllapi_table->pfnThink(object); // + gpGamedllFuncs->dllapi_table->pfnTouch(player,object); // give it to the player + + return 1; +} AMX_NATIVE_INFO ns_misc_natives[] = { /////////////////// { "ns_get_build", ns_get_build }, @@ -331,6 +355,8 @@ AMX_NATIVE_INFO ns_misc_natives[] = { { "ns_set_fov", ns_set_fov }, + { "ns_give_item", ns_giveitem }, + /////////////////// { NULL, NULL } diff --git a/dlls/ns/ns/hookedfunctions.cpp b/dlls/ns/ns/hookedfunctions.cpp index af4a18d4..ded0555a 100755 --- a/dlls/ns/ns/hookedfunctions.cpp +++ b/dlls/ns/ns/hookedfunctions.cpp @@ -37,10 +37,10 @@ void OnPluginsLoaded() if ((mapname[0]=='c' || mapname[0]=='C') && (mapname[1]=='o' || mapname[0]=='O') && mapname[2]=='_') iscombat=TRUE; - ChangeclassForward = MF_RegisterForward("client_changeclass", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL); + ChangeclassForward = MF_RegisterForward("client_changeclass", FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE); // No sense in this if it's combat.. if (!iscombat) - BuiltForward = MF_RegisterForward("client_built", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL); + BuiltForward = MF_RegisterForward("client_built", FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE); }