View Single Post
p3tsin
Senior Member
Join Date: Sep 2005
Location: Finland
Old 04-04-2009 , 08:03   Re: MOTD panel & strings
Reply With Quote #12

The regular MOTD panel uses stringtables. Here's how you do it in a plugin:

Code:
ShowLongMOTD(client,const String:title[],const String:panel[]) {     new Handle:kv = CreateKeyValues("data")     KvSetString(kv,"title",title)     KvSetString(kv,"type","1")     KvSetString(kv,"msg",panel)     ShowVGUIPanel(client,"info",kv)     CloseHandle(kv) } bool:SetLongMOTD(const String:panel[],const String:text[]) {     new table = FindStringTable("InfoPanel")     if(table != INVALID_STRING_TABLE) {         new len = strlen(text)         new str = FindStringIndex(table,panel)         new bool:locked = LockStringTables(false)         if(str == INVALID_STRING_INDEX || str == 65535) {   //for some reason it keeps returning 65535             AddToStringTable(table,panel,text,len)         }         else {             SetStringTableData(table,str,text,len)         }         LockStringTables(locked)         return true     }     return false }

First you got to save the data with SetLongMOTD, wait for it to be networked to clients (no idea how much time should be spent for that), and then send it to the clients. Example:

Code:
public OnPluginStart() {     RegConsoleCmd("sm_hello",CmdHello) } public OnMapStart() {     SetLongMOTD("motd2","<html><body>Hello</body></html>") } public Action:CmdHello(client,args) {     ShowLongMOTD(client,"Title","motd2")     return Plugin_Handled }

You could also make the client execute a command when he closes the window (to inform the server), but I didn't wanna include it in the above script.
__________________
plop

Last edited by p3tsin; 04-04-2009 at 08:08.
p3tsin is offline