diff --git a/dlls/ns/ns/CPlayer.cpp b/dlls/ns/ns/CPlayer.cpp index d956b0af..6ab3e578 100755 --- a/dlls/ns/ns/CPlayer.cpp +++ b/dlls/ns/ns/CPlayer.cpp @@ -101,12 +101,15 @@ void CPlayer::Reset() this->model[0]='\0'; this->skin=0; this->body=0; + this->fov=0.0; + this->foved=false; } BOOL CPlayer::ClientCommand() { // As of now, all that needs to be checked is the "menuselect" command. if (menucmd.inmenu) { + LOG_CONSOLE(PLID,"Checking menuselect..."); if (FStrEq(CMD_ARGV(0),"menuselect")) { int key=0; @@ -122,6 +125,13 @@ BOOL CPlayer::ClientCommand() if (key_mask & menucmd.keys) { ClearHudMessage(edict,menuhudtext," "); + LOG_CONSOLE(PLID,"Clearing hud text..."); + LOG_CONSOLE(PLID,"this->menucmd.iFunctionIndex: %i, this->index: %i key: %i",this->menucmd.iFunctionIndex,this->index,key); + int temp = this->menucmd.iFunctionIndex; + MF_ExecuteForward(this->menucmd.iFunctionIndex,this->index,key); + MF_UnregisterSPForward(temp); + + LOG_CONSOLE(PLID,"Executing..."); // AMX_EXEC(menucmd.amx,NULL,menucmd.iFunctionIndex,2,index,key); } return true; diff --git a/dlls/ns/ns/CPlayer.h b/dlls/ns/ns/CPlayer.h index 6a107dac..736a43f0 100755 --- a/dlls/ns/ns/CPlayer.h +++ b/dlls/ns/ns/CPlayer.h @@ -23,7 +23,8 @@ public: int index; bool connected; - + REAL fov; + bool foved; // Custom model/body/skin bool custommodel; bool customskin; diff --git a/dlls/ns/ns/NMenu.cpp b/dlls/ns/ns/NMenu.cpp index 8b64ff0d..698afb83 100755 --- a/dlls/ns/ns/NMenu.cpp +++ b/dlls/ns/ns/NMenu.cpp @@ -53,14 +53,21 @@ static cell AMX_NATIVE_CALL ns_show_menu(AMX *amx,cell *params) if (FNullEnt(INDEXENT2(params[1]))) return 0; } - // First we set the command to be executed here... int len; - // AMX publics have a limit of 19 characters. + int ifx; char sTemp[20]; - sprintf(sTemp,"%s",MF_GetAmxString(amx,params[2],0,&len)); char sText[512]; - sprintf(sText,"%s",MF_GetAmxString(amx,params[3],1,&len)); - iFunctionIndex = MF_RegisterSPForwardByName(amx, sTemp, ET_IGNORE, FP_CELL, FP_CELL); + strncpy(sTemp,MF_GetAmxString(amx,params[2],0,&len),19); + strncpy(sText,MF_GetAmxString(amx,params[3],1,&len),511); + sTemp[19]='\0'; + sText[511]='\0'; + if (MF_AmxFindPublic(amx,sTemp,&ifx) == AMX_ERR_NONE) + iFunctionIndex = MF_RegisterSPForward(amx,ifx,FP_CELL, FP_CELL,FP_DONE); + else + { + MF_Log("(ns_show_menu): Function not found: %s",sTemp); + return 0; + } if (pEntity==NULL) { int i; diff --git a/dlls/ns/ns/NMisc.cpp b/dlls/ns/ns/NMisc.cpp index eaf07452..2240e92f 100755 --- a/dlls/ns/ns/NMisc.cpp +++ b/dlls/ns/ns/NMisc.cpp @@ -271,6 +271,34 @@ static cell AMX_NATIVE_CALL ns_popup(AMX *amx, cell *params) MESSAGE_END(); return 1; } +static cell AMX_NATIVE_CALL ns_set_fov(AMX *amx, cell *params) +{ + if (params[1] < 1 || params[1] > gpGlobals->maxClients) + return 0; + CPlayer *player = GET_PLAYER_I(params[1]); + REAL fov = CELL_TO_FLOAT(params[2]); + LOG_CONSOLE(PLID,"Got fov. fov=%f",fov); + int gmsgSetFov = GET_USER_MSG_ID(PLID, "SetFOV", NULL); + if (fov == 0.0) + { + player->foved=false; + player->fov=0.0; + MESSAGE_BEGIN(MSG_ONE,gmsgSetFov,NULL,player->edict); + WRITE_BYTE(0); + MESSAGE_END(); + return 1; + } + if (fov > 0) + { + player->foved=true; + player->fov=fov; + MESSAGE_BEGIN(MSG_ONE,gmsgSetFov,NULL,player->edict); + WRITE_BYTE((int)fov); + MESSAGE_END(); + return 1; + } + return 0; +} AMX_NATIVE_INFO ns_misc_natives[] = { /////////////////// { "ns_get_build", ns_get_build }, @@ -301,6 +329,8 @@ AMX_NATIVE_INFO ns_misc_natives[] = { { "ns_popup", ns_popup }, + { "ns_set_fov", ns_set_fov }, + /////////////////// { NULL, NULL } diff --git a/dlls/ns/ns/hookedfunctions.cpp b/dlls/ns/ns/hookedfunctions.cpp index 728223b7..dd372069 100755 --- a/dlls/ns/ns/hookedfunctions.cpp +++ b/dlls/ns/ns/hookedfunctions.cpp @@ -3,6 +3,7 @@ #include //useful almost everywhere #include +#include CSpawn ns_spawnpoints; CPlayer g_player[33]; @@ -382,4 +383,17 @@ void ClientDisconnect(edict_t *pEntity) CPlayer *player = GET_PLAYER_E(pEntity); player->Disconnect(); RETURN_META(MRES_HANDLED); +} + +// NS resets pev->fov every single frame, but this is called right before the data is sent to the client. +// Reset FOV if we need to. +void UpdateClientData( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ) +{ + edict_t *pEntity = (edict_t*)ent; + CPlayer *player = GET_PLAYER_E(pEntity); + if (player->foved) + pEntity->v.fov = player->fov; + + RETURN_META(MRES_HANDLED); + } \ No newline at end of file diff --git a/dlls/ns/ns/include/ns.inc b/dlls/ns/ns/include/ns.inc index 2da4777c..25cf83ec 100755 --- a/dlls/ns/ns/include/ns.inc +++ b/dlls/ns/ns/include/ns.inc @@ -173,3 +173,4 @@ native ns_get_hive_trait(idHive); /* Sets the trait type tied to the hive. Look at the hivetrait enum for the values. */ native ns_set_hive_trait(idHive,trait); +native ns_set_fov(idPlayer,Float:_fov=0.0); diff --git a/dlls/ns/ns/moduleconfig.h b/dlls/ns/ns/moduleconfig.h index b6ae1deb..b882c2dd 100755 --- a/dlls/ns/ns/moduleconfig.h +++ b/dlls/ns/ns/moduleconfig.h @@ -90,7 +90,7 @@ // #define FN_PM_Init PM_Init /* pfnPM_Init() Server version of player movement initialization; (wd) SDK2 */ // #define FN_PM_FindTextureType PM_FindTextureType /* pfnPM_FindTextureType() (wd) SDK2 */ // #define FN_SetupVisibility SetupVisibility /* pfnSetupVisibility() Set up PVS and PAS for networking for this client; (wd) SDK2 */ -// #define FN_UpdateClientData UpdateClientData /* pfnUpdateClientData() Set up data sent only to specific client; (wd) SDK2 */ +#define FN_UpdateClientData UpdateClientData /* pfnUpdateClientData() Set up data sent only to specific client; (wd) SDK2 */ // #define FN_AddToFullPack AddToFullPack /* pfnAddToFullPack() (wd) SDK2 */ // #define FN_CreateBaseline CreateBaseline /* pfnCreateBaseline() Tweak entity baseline for network encoding allows setup of player baselines too.; (wd) SDK2 */ // #define FN_RegisterEncoders RegisterEncoders /* pfnRegisterEncoders() Callbacks for network encoding; (wd) SDK2 */ diff --git a/dlls/ns/ns/ns.h b/dlls/ns/ns/ns.h index 53879bab..994f4613 100755 --- a/dlls/ns/ns/ns.h +++ b/dlls/ns/ns/ns.h @@ -8,7 +8,6 @@ #include "ns_const.h" #include "CPlayer.h" #include "CSpawn.h" -#include "CCallList.h" #include "utilfunctions.h" extern CSpawn ns_spawnpoints; diff --git a/dlls/ns/ns/ns.suo b/dlls/ns/ns/ns.suo index eda51a27..b341982e 100755 Binary files a/dlls/ns/ns/ns.suo and b/dlls/ns/ns/ns.suo differ