PDA

View Full Version : Notification System from LTFX


neXus
3rd September 2002, 08:42
I'm having trouble getting the notification system from ltfx 2.2 source working in my hook. This is the following code i have used in my client.cpp:

=============================================
void PreS_DynamicSound(const DWORD a,const DWORD b,const DWORD c,const char*const sample,
const float*const origin,DWORD f,const DWORD g,const DWORD h)
{
BOUND_VALUE(soundMarkerCurrentIndex,0,64);
SoundMarker& ref = vecSoundMarker[soundMarkerCurrentIndex];

string theMessage;

if(b>0 && b<=36)
{
theMessage = vPlayers[b].entinfo.name;
ref.team = vPlayers[b].team;
//VectorCopy(origin,vPlayers[b].lastOrg);
}
//Ladder detection
//TODO: level specific ladder detection
if(strstr(sample,"player/pl_ladder"))
{
int len = theMessage.length();
theMessage+=" is using ladder!";
gSetHudMessage3(theMessage.c_str(),2,ref.team,0,le n);
}
//gSetHudMessage3(getLadderMessage(origin),4);

//Defuse detection
if(strstr(sample,"weapons/c4_disarm"))
{
theMessage+=" is defusing bomb";
gSetHudMessage3(theMessage.c_str(),2,5,-1,-1);
}

//Plant detection
if(strstr(sample,"weapons/c4_beep") || strstr(sample,"weapons/c4_click"))
{
VectorCopy(origin,bombPos);
const char* c = HandleBombPlant(gEngfuncs.pfnGetLevelName(),bombPo s);
gSetHudMessage3(c,3,5,-1,-1);
}

// setup color and description of sound marker depending on it's type
// or drop it if it doesn't pass the filter
if(sample[0]=='p' && sample[3]=='y' && sample[6]=='/') // "player/pl_step1.wav"
{
if(!passesSoundFilter(origin,b)) return;
const char* pos = sample+7;
if(pos[0]=='p' && pos[2]=='_') // pl_xx
{
if(pos[3]=='s' && pos[4]=='h' && pos[5]=='e' && pos[6]=='l' ) return; // pl_shell#

pos+=3;
if(cvar.colorstep)
ref.color = colorList.get(41+ref.team);
else
ref.color = colorList.get(30); // "snd_step"

ref.priority = 0;
} else if( pos[0]=='b'&& pos[1]=='h' && pos[2]=='i' ) { // "bhit_..."
decalShoot = 24;
vPlayers[b].hitpoints-=getPoints(sample);
if(vPlayers[b].hitpoints<=0)
vPlayers[b].hitpoints=1;
pos+=5;
ref.color = colorList.get(32); // "snd_hit"
ref.priority = 2;
} else if( pos[3]=='s' && pos[7]=='t' ) { // "pl_shot1.wav"
vPlayers[b].hitpoints--;
if(vPlayers[b].hitpoints<=0)
vPlayers[b].hitpoints=1;
}
strcpy_x(ref.description,pos);
}
else
if( sample[0]=='w' && sample[1]=='e' && sample[7]=='/' ) // weapons/ric1.wav
{
const char* pos = sample+8;
if(cvar.filtersounds)
if( (pos[0]=='r' && pos[1]=='i') // ricxxx
||(pos[0]=='b' && pos[1]=='u') ) // bullet-hit...
{
return;
}
if(!passesSoundFilter(origin,b)) return;

ref.priority = 1;
ref.color = colorList.get(41+ref.team); // snd_weapon
strcpy_x2(ref.description,pos);
for(char *pos1=ref.description;*pos1;++pos1){ *pos1 = toupper(*pos1); }// uppercase
}
else
if(sample[0]=='a' && sample[1]=='m' && sample[8]=='/') // "ambience/3dmbridge.wav"
{
if(!strcmp(sample+9,"3dmbridge.wav")) strcpy(ref.description,"bridge");
ref.color = colorList.get(33); // snd_special
ref.priority = 2;
}
else
if(sample[0]=='p' && sample[3]=='t' && sample[5]=='/') // "plats/vehicle.."
{
strcpy(ref.description,"vehicle");
ref.color = colorList.get(33); // snd_special
ref.priority = 2;
}
else
if(sample[0]=='h' && sample[1]=='o' && sample[2]=='s') // "hostage/hos1.."
{
strcpy(ref.description,"rescue");
ref.color = colorList.get(33); // snd_special
ref.priority = 1;
}
else
{
if(!cvar.filtersounds)
{
strcpy(ref.description,sample);
ref.color = colorList.get(0);
ref.priority = 2;
}
}

if(cvar.soundfix==1 && b!=me.ent->index)
{
string path = hldir;
path += "cstrike\\sound\\";
path += sample;
for(int p=0;p<path.length();p++)
if(path[p]=='/')
path[p]='\';
sndPlaySound(path.c_str(), SND_ASYNC);
}
else if(cvar.soundfix==2 && b==me.ent->index)
{
string path = hldir;
path += "cstrike\\sound\\";
path += sample;
for(int p=0;p<path.length();p++)
if(path[p]=='/')
path[p]='\';
sndPlaySound(path.c_str(), SND_ASYNC);
}
else if(cvar.soundfix==3)
{
string path = hldir;
path += "cstrike\\sound\\";
path += sample;
for(int p=0;p<path.length();p++)
if(path[p]=='/')
path[p]='\';
sndPlaySound(path.c_str(), SND_ASYNC);
}

if(!cvar.soundfilter) { return; }

// activate sound marker
VectorCopy( origin, ref.origin );
ref.timer.countdown( cvar.soundtime );
if(cvar.soundtoesp && b>0)
{
if(!vPlayers[b].getPVS())
{
VectorCopy(origin,vPlayers[b].getEnt()->origin);
vPlayers[b].setPVS(cvar.spvs);
}
}

// advance to next sound marker
++soundMarkerCurrentIndex;
if(soundMarkerCurrentIndex>=cvar.soundmax){ soundMarkerCurrentIndex=0;}
}

=============================================

the original code had cvars as cvarx, instead of cvar (which i changed as i didnt know what else to do). I thought that cvarx may be an older string for this syntax as i received errors in vc++6 enterprise upon trying to use cvarx. I have compiled with no errors and i feel i am either lacking something or i need to change something to make this function properly. In the game, i get no messeges whatsoever. So, i do not know what is quite wrong. I did ensure that the proper cvars were added to cvar.cpp, and cvar.h:

cvar.colorstep
cvar.filtersounds
cvar.soundfix

I'm not quite sure if i am supposed to enable this somehow in the commandmenu.txt under esp, or anything similar, i do know that nothing works though unfortunately.but what i have just displayed here is all i have done at my attempt to add this to my hook. If anyone can plz help me it would be much appreciated, thankyou.

NASTE
3rd September 2002, 09:08
Programming Forum , You need to mayb compile the cvar.bin

TFCFAG
3rd September 2002, 22:02
Moved to Programming Forum...