Thursday, 28.03.2024, 19:58
Приветствую Вас Гость
Register | Login | RSS
Jedi Academy Server Security
[ New messages · Users · Forum rules · Search · RSS ]
  • Page 1 of 1
  • 1
Forum » JASS » English forum » Plugin
Plugin
fasfDate: Sunday, 07.10.2012, 13:35 | Message # 1
Group: User
Messages: 1
Reputation: 0
Status: Offline
Hello. I would like to ask you if there's a way to do something like this (without writing custom mod):
* If player writes on chat @mynick "mynick" is replaced by the nick of player who wrote it.
* if player uses a button which is connected to target_print with @mynick it displays his name
I've been asking around and trying to do so but I failed. Maybe any of you guys have ideas?
 
BufferOverflowDate: Monday, 08.10.2012, 14:48 | Message # 2
Group: Developer
Messages: 47
Reputation: 0
Status: Offline
First, character " is restricted for use in chat (it sends a command "chat \"Something\n\"").
If you'll read the "Creating plugins for JAZZ tutorial", you'll see an example of printing chat:
Code
int sv_maxclients = JASS_GETINTCVAR("sv_maxclients");
char *chat = JASS_VARARGS("chat \"%s\n\"", "What_you_want_to_print");
g_syscall(G_SEND_SERVER_COMMAND, PlayerNum, chat );
}

So, replacing name in chat is very simple. Hook a G_SEND_SERVER_COMMAND (it is described in the tutorial), then, replace @myname in string (be careful with length, it's may be unsafe), or block this chat string and generate new one like:
Code
if(cmd == G_SEND_SERVER_COMMAND){
     ...searching for @myname...
     char *chat = JASS_VARARGS("chat \"%s\n\"", generatedString);
     g_syscall(G_SEND_SERVER_COMMAND, -1, chat );
     JASS_RET_SUPERCEDE (1);
}

I'm not sure about target_print. If it's going through server, it could be hooked via JASS the same way, but I haven't checked it out.
 
Forum » JASS » English forum » Plugin
  • Page 1 of 1
  • 1
Search: