Added ns_set_fov

Began porting ns_show_menu, having problems though.
This commit is contained in:
Steve Dudenhoeffer 2004-07-27 01:15:10 +00:00
parent 5915a18b3c
commit 53332dbe76
9 changed files with 70 additions and 8 deletions

View File

@ -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;

View File

@ -23,7 +23,8 @@ public:
int index;
bool connected;
REAL fov;
bool foved;
// Custom model/body/skin
bool custommodel;
bool customskin;

View File

@ -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;

View File

@ -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 }

View File

@ -3,6 +3,7 @@
#include <sdk_util.h> //useful almost everywhere
#include <usercmd.h>
#include <entity_state.h>
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);
}

View File

@ -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);

View File

@ -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 */

View File

@ -8,7 +8,6 @@
#include "ns_const.h"
#include "CPlayer.h"
#include "CSpawn.h"
#include "CCallList.h"
#include "utilfunctions.h"
extern CSpawn ns_spawnpoints;

Binary file not shown.