Adding custom chat commands to dedicated server

Users who are viewing this thread

Hi,

I want to add custom chat commands to my native dedicated server(for example "/help"). Is this hard to write? I can't find any information about this on this forum. I have experience in programming, but not with modding.
 
You can use WSE only server-side and use it's operations only server-side. That means the players / clients don't need WSE cause WSE stuff is only done on the server.

Other than that, you could make a send_message_to_url system which checks the chat on a PHP scripts and then looks if it is a IG-Command or not.
With WSE it's just easier, faster and more reliable to be fair.
 
domipoppe said:
Other than that, you could make a send_message_to_url system which checks the chat on a PHP scripts and then looks if it is a IG-Command or not.
With WSE it's just easier, faster and more reliable to be fair.
So you'd send any messages sent by clients to your backend? Is there even a way to store sent chat messages without WSE?
 
Namakan said:
domipoppe said:
Other than that, you could make a send_message_to_url system which checks the chat on a PHP scripts and then looks if it is a IG-Command or not.
With WSE it's just easier, faster and more reliable to be fair.
So you'd send any messages sent by clients to your backend? Is there even a way to store sent chat messages without WSE?

Yes you can do it without WSE.
You have to look where the strings are sent and then you basically do.

Store the chat string into s0. Store the sender player id into reg0.
Then do (str_encode_url, s0), to avoid issues.
(send_message_to_url, "@http://localhost/myscript.php?p={reg0}&s={s0}"),

Then myscript.php would look like this:

Code:
<?php
$sent_string = $_GET["s"];
$sending_player = $_GET["p"];

echo $sending_player . "|";
$did_pass = 0;

if($sent_string == "/help") {
    echo "1";
    $did_pass = 1;
    exit;
}
if($sent_string == "/showmyguid") {
   echo "2";
    $did_pass = 1;
   exit;
}




if($did_pass == 0) {
   echo "0";
   exit;
}
?>


Then one game_receive_url_response you would do something like that:

Code:
(assign, ":sender_player", reg0),
(assign, ":answer_code", reg1),

(try_begin),
   (eq, ":answer_code", 0),
   (assign, reg10, ":sender_player"),
   (str_store_player_username, s10, ":sender_player"),
   (server_add_message_to_log, "@{s10} with ID {reg10} did write a message and it was no IG command"),
(else_try),
   (eq, ":answer_code", 1),
   (multiplayer_send_string_to_player, ":sender_player", multiplayer_event_show_server_message, "@IG Command list"),
   (multiplayer_send_string_to_player, ":sender_player", multiplayer_event_show_server_message, "@/help - shows all commands"),
   (multiplayer_send_string_to_player, ":sender_player", multiplayer_event_show_server_message, "@/showmyguid - will display your GUID"),
(else_try),
   (eq, ":answer_code", 2),
   (player_get_unique_id, reg10, ":sender_player"),
   (multiplayer_send_string_to_player, ":sender_player", multiplayer_event_show_server_message, "@Your GUID is: {reg10}"),
(try_end),

And to get the message the player send you just have to modifiy module_presentations and hook the chat box with the send command.
 
domipoppe said:
Namakan said:
domipoppe said:
Other than that, you could make a send_message_to_url system which checks the chat on a PHP scripts and then looks if it is a IG-Command or not.
With WSE it's just easier, faster and more reliable to be fair.
So you'd send any messages sent by clients to your backend? Is there even a way to store sent chat messages without WSE?

You have to look where the strings are sent and then you basically do.

That's the part I'm wondering about. You can do it for custom chats(like PW has them), but not for Native global/team chat...?
 
Back
Top Bottom