Assuming you're starting from the empty server plugin, first include
/src/tier1/bitbuf.cpp into your project, then add this somewhere
#include "IRecipientFilter.h"
#include "bitbuf.h"
#include "shake.h"
class CNewRecipientFilter : public IRecipientFilter {
private:
CUtlVector<int> m_vRecipients;
public:
virtual bool IsReliable() const { return true; }
virtual bool IsInitMessage() const { return false; }
virtual int GetRecipientCount() const { return m_vRecipients.Count(); }
virtual int GetRecipientIndex(int iSlot) const { return
m_vRecipients[iSlot]; }
bool Add(edict_t* pEdict){ if(!pEdict || pEdict->IsFree()) return
false; return Add(engine->IndexOfEdict(pEdict)); }
bool Add(int iIndex){ if(iIndex <= 0) return false;
m_vRecipients.AddToHead(iIndex); return true; }
};
bool Shake(edict_t* pEdict){
if(!pEdict || pEdict->IsFree())
return false;
CNewRecipientFilter Filter;
if(!Filter.Add(pEdict))
return false;
bf_write* pBitBuf = engine->UserMessageBegin(&Filter, 10); //10 =
shake in css and hl2dm atm - use engine->GetUserMessageInfo to
enumerate
if(!pBitBuf)
return false;
pBitBuf->WriteByte(SHAKE_START); // shake
command (SHAKE_START,
STOP, FREQUENCY, AMPLITUDE)
pBitBuf->WriteFloat(25); //
shake magnitude/amplitude
pBitBuf->WriteFloat(150.0); //
shake noise frequency
pBitBuf->WriteFloat(2.0); //
shake lasts this long
engine->MessageEnd();
engine->ClientPrintf(pEdict, "Shake, my minion!\n");
return true;
}
Then just rig up down in ClientCommand
else if(FStrEq(pcmd, "shakememofo")){
Shake(pEntity);
return PLUGIN_STOP;
}
_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders