I would like to display a form to the player on the client that takes text input. Is this possible? I've done this with HL2DM before, but that was done with a VGUI form on the client side.
I wonder if the Type_File option from the MOTD tutorial isn't what I need, but I can't even get an example to work. If someone can place an updated tutorial on how to do a MOTD that guy will be everybody's hero!
This is what I've got for the MOTD message. It compiles, but it just does nothing. I've put a breakpoint in and it does get called
Please help me!! I've been trying to do this for the last month.
Code:
void SamplePlugin::ClientPutInServer(edict_t *pEntity, char const *playername)
{
ShowMOTD( "http://www.yahoo.com", "Yahoo.com !", 2, "", pEntity );
META_LOG(g_PLAPI, "ClientPutInServer called: pEntity=%d, playername=%s", pEntity ? m_Engine->IndexOfEdict(pEntity) : 0, playername);
RETURN_META(MRES_IGNORED);
}
void SamplePlugin::ShowMOTD(const char* lpcMsg, const char* lpcTitle, int iType, const char* lpcCmd, edict_t *pEntity){
KeyValues* kv = new KeyValues("data");
kv->SetString("title", lpcTitle); // info panel title
if ( iType == 1 )
{
kv->SetString("type", "1"); // show userdata from stringtable entry
}
else if ( iType == 2 )
{
kv->SetString("type", "2"); // show userdata from stringtable entry
}
else if ( iType == 3 )
{
kv->SetString("type", "4"); // show userdata from stringtable entry
}
else if ( iType == 4 )
{
kv->SetString("type", "4"); // show userdata from stringtable entry
}
// TYPE_TEXT = 0, // just display this plain text
// TYPE_INDEX, // lookup text & title in stringtable
// TYPE_URL, // show this URL
// TYPE_FILE,
kv->SetString("msg", lpcMsg); // use this stringtable entry
if(lpcCmd && *lpcCmd)
kv->SetString("cmd", lpcCmd);// exec this command if panel closed
ShowViewPortPanel(pEntity, "info", true, kv);
kv->deleteThis();
}
void SamplePlugin::ShowViewPortPanel(edict_t* pEdict, const char* name, bool bShow, KeyValues* data){
int count = 0;
KeyValues *subkey = NULL;
if(data){
subkey = data->GetFirstSubKey();
while(subkey){
count++;
subkey = subkey->GetNextKey();
}
subkey = data->GetFirstSubKey(); // reset
}
MRecipientFilter filter;
filter.AddRecipient(m_Engine->IndexOfEdict(pEdict));
bf_write *pBuffer = m_Engine->UserMessageBegin( &filter, 10 );
pBuffer->WriteString(name);
pBuffer->WriteByte(bShow ? 1 : 0);
pBuffer->WriteByte(count);
while(subkey){
pBuffer->WriteString(subkey->GetName());
pBuffer->WriteString(subkey->GetString());
subkey = subkey->GetNextKey();
}
m_Engine->MessageEnd();
}