View Full Version : cmd_executestring
Ni3ls
29th June 2015, 17:19
How to use this command for 1 specific player and for everybody?
cmd_executestring
Mitch
29th June 2015, 18:20
How to use this command for 1 specific player and for everybody?
cmd_executestring
Cmd_ExecuteString executes a text command on the server (without any output). This is equal to when someone executes /rcon say abc.
You can tell a message to a player with the function below:
tellMessage(message)
{
Cmd_ExecuteString("tell " + self getEntityNumber() + " " + message);
}
You can also send rcon commands to client that isn't logged in.
self connectionlessPacket("rcon " + getcvar("rcon_password") + " status");
You can also directly send message to the client using printOutOfBand.
self printOutOfBand("print\ninsert test message here!!!\n"); // shows up in client's console
There is also a function that sends a game message. This message is tracked within the engine like when you use 'player setClientCvar(cvar, value)'.
sendGameServerCommand(clientNum, message);
sendgameservercommand(players[i] getentitynumber(), "h \"" + self.name + "^7: " + txt + "\""); // client: say abc (= txt)
When clientNum is -1 then the message is send to all the players.
Edit: i see now that i need to add the last 3 functions to the documentation.
IzNoGoD
29th June 2015, 18:43
Please use sendgameservercommand instead of cmd_executestring("tell"), its much more stable and much more native than the executestring, which is also overwriting some buffers when executing it during a callback_playercommand
Mitch
29th June 2015, 18:53
Please use sendgameservercommand instead of cmd_executestring("tell"), its much more stable and much more native than the executestring, which is also overwriting some buffers when executing it during a callback_playercommand
tellMessage(message)
{
sendgameservercommand(self getentitynumber(), "h \"console: " + message + "\"");
}
Is this exactly the same as /rcon tell slot?
consoleSay(message)
{
sendgameservercommand(-1, "h \"console: " + message + "\"");
}
Ni3ls
29th June 2015, 18:56
tellMessage(message)
{
sendgameservercommand(self getentitynumber(), "h \"Console: " + message + "\"");
}
Is this exactly the same as /rcon tell slot?
why must you do "h \ Console: "?
871
case "help":
self.id=self getEntityNumber();
message = "Available commands: !ratio";
self thread tellMessage(message);
tellMessage(message)
{
Cmd_ExecuteString("tell " + self getEntityNumber() + " " + message);
}
Why does it print it 3 times? 1 normal and 2 weird ones
Mitch
29th June 2015, 19:19
a = switch to weapon
d = config string modified
e/f = game message
g = bold game message
h = chat
i = team chat
You send your message like this:
h "message"
Ni3ls
29th June 2015, 19:48
case "help":
self.id=self getEntityNumber();
self setClientCvar ("clientcmd", "say !help");
self openMenu ("clientcmd");
self closeMenu ("clientcmd");
wait 1;
message = "Available commands: !ratio";
self thread tellMessage(message);
return;
How to let the !help stay in chat? I tried to manually repeat it with clientcmd, but it still won't shown
IzNoGoD
29th June 2015, 19:55
case "help":
self.id=self getEntityNumber();
self setClientCvar ("clientcmd", "say !help");
self openMenu ("clientcmd");
self closeMenu ("clientcmd");
wait 1;
message = "Available commands: !ratio";
self thread tellMessage(message);
return;
How to let the !help stay in chat? I tried to manually repeat it with clientcmd, but it still won't shown
Stop executing shit while in callback_playercommand prior to the self clientcommand() function. Store shit you wanna do and do it AFTER completing the clientcommand() function. Buffers are very non-isolated at that point.
Mitch
29th June 2015, 19:55
case "help":
self.id=self getEntityNumber();
self setClientCvar ("clientcmd", "say !help");
self openMenu ("clientcmd");
self closeMenu ("clientcmd");
wait 1;
message = "Available commands: !ratio";
self thread tellMessage(message);
return;
How to let the !help stay in chat? I tried to manually repeat it with clientcmd, but it still won't shown
You need to add 'self ClientCommand();' to your playercommand callback to keep it in your chat.
Or you can add it manual with:
sendgameservercommand(self getentitynumber(), "h \"" + self.name + "^7: !help\"");
Edit: Others won't receive this message.
Ni3ls
29th June 2015, 20:13
It is in the playercommand callback?
case "help":
self.id=self getEntityNumber();
self setClientCvar ("clientcmd", "say !help");
self openMenu ("clientcmd");
self closeMenu ("clientcmd");
wait 1;
message = "Available commands: !ratio";
self thread tellMessage(message);
return;
}
}
self ClientCommand();
}
IzNoGoD
30th June 2015, 00:37
It is in the playercommand callback?
case "help":
self.id=self getEntityNumber();
self setClientCvar ("clientcmd", "say !help");
self openMenu ("clientcmd");
self closeMenu ("clientcmd");
wait 1;
message = "Available commands: !ratio";
self thread tellMessage(message);
return;
}
}
self ClientCommand();
}
If you execute a cmd_executestring inside codecallback_playercommand but before self clientcommand(), the stuff you send to cmd_executestring will actually be executed by the client on clientcommand() because thats a shared buffer.
Example inside codecallback_clientcmd:
Cmd_ExecuteString("say hello");
self clientcmd();
The result will be:
Console: hello (globally)
yournamehere: hello (also globally)
Ni3ls
30th June 2015, 14:37
Can't find the solution. If I try to thread after self Clientcommand(); nothing will happen. thread is not loaded. Placing it before self Clientcommand() same result :(
filthy_freak_
30th June 2015, 14:58
Can't find the solution. If I try to thread after self Clientcommand(); nothing will happen. thread is not loaded. Placing it before self Clientcommand() same result :(
Just do what mitch said;
sendgameservercommand(self getentitynumber(), "h \"" + self.name + "^7: !help\"");
It is better anyway, because you can set a custom server name.
Example:
sendGameServerCommand(-1, "h \"^7Server: Hello world.\""); // -1 = global message
Result:
Server: Hello world.
Edit: Seems like you are already using it, my bad.
filthy_freak_
30th June 2015, 15:07
It is in the playercommand callback?
case "help":
self.id=self getEntityNumber();
self setClientCvar ("clientcmd", "say !help");
self openMenu ("clientcmd");
self closeMenu ("clientcmd");
wait 1;
message = "Available commands: !ratio";
self thread tellMessage(message);
return;
}
}
self ClientCommand();
}
Try this;
case "help":
self.id=self getEntityNumber();
self setClientCvar ("clientcmd", "say !help");
self openMenu ("clientcmd");
self closeMenu ("clientcmd");
wait 1;
message = "Available commands: !ratio";
self tellMessage(message);
break;
}
}
self ClientCommand();
Also I noticed you are using wait in the playercommand callback. This is a no no.
Ni3ls
30th June 2015, 15:19
Its working with the sendgameservercommand. Thanks!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.