Commands with multiple "sections"

Hey there, I was wondering how you would go about making a command with multiple "inputs".

By this i mean the command should be something like this : /msg <Player Name> <Message>, essentially getting both the player name and the message from the command.

I was also wondering how you would use something like gms_chat to chat without showing your player name (for things like announcements), Thanks :)

Replies (6)

Last message on 26 Dec 2017

Size43 (Administrator) on 24 Dec 2017, 16:22:55
You can split the chat message using GameMaker's string functions, for example using a script like this:http://www.gmlscripts.com/script/string_extract
The default chat UI does not support hiding the username.
PenguinPalaceGame (Topicstarter) on 26 Dec 2017, 16:39:52
Tried this out earlier today, still can't seem to get the command with 3 inputs working, any idea's?
Size43 (Administrator) on 26 Dec 2017, 16:40:19
What does your code look like?
PenguinPalaceGame (Topicstarter) on 26 Dec 2017, 16:43:48
//Message Command\\
if string_copy(argument0, "", 4) == "/msg"
{
    //getPName = string_extract(argument0," ",string_length(argument0))
    getPName = string_copy(argument0, 6, string_length(argument0));
    getPMsg = get_string("System : Whats your message?", "")
    getPMsg = string_extract(argument0, 8, string_length(argument0) + string_length(getPName))
    getPID = gms_other_find_by_name(getPName)
    getPMsg2 = gms_self_name() + ": " + getPMsg
    
    localMsg = ">" + "Sent a message to " + gms_self_name()
    gms_chat_local(localMsg, c_yellow)
    gms_p2p_send(11, getPID, getPMsg2)
    return false
}
Size43 (Administrator) on 26 Dec 2017, 16:54:39
The third argument for string_extract is the index of the value you want to find. So if your command looks like /msg playername hi, /msg has index 0, playername = index 1, hi = index2.

By the way, the chat has a built in messaging system you can use by typing "@playername message" - it'll only show up for the player you @-ed.
PenguinPalaceGame (Topicstarter) on 24 Dec 2017, 16:28:45
Hey, just got the reply, Thanks soo much :)