Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: cmd_executestring

  1. #1
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts

    cmd_executestring

    How to use this command for 1 specific player and for everybody?
    Code:
    cmd_executestring

  2. #2
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    Quote Originally Posted by Ni3ls View Post
    How to use this command for 1 specific player and for everybody?
    Code:
    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:

    PHP Code:
    tellMessage(message)
    {
        
    Cmd_ExecuteString("tell " self getEntityNumber() + " " message);

    You can also send rcon commands to client that isn't logged in.
    PHP Code:
    self connectionlessPacket("rcon " getcvar("rcon_password") + " status"); 
    You can also directly send message to the client using printOutOfBand.
    PHP Code:
    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)'.
    PHP Code:
    sendGameServerCommand(clientNummessage);
    sendgameservercommand(players[igetentitynumber(), "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.
    Last edited by Mitch; 29th June 2015 at 19:26. Reason: added the functions to script doc.

  3. The Following 2 Users Say Thank You to Mitch For This Useful Post:

    kung foo man (29th June 2015),Ni3ls (29th June 2015)

  4. #3
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    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
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  5. The Following User Says Thank You to IzNoGoD For This Useful Post:

    Mitch (29th June 2015)

  6. #4
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    Quote Originally Posted by IzNoGoD View Post
    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
    PHP Code:
    tellMessage(message)
    {
        
    sendgameservercommand(self getentitynumber(), "h \"console: " message "\"");

    Is this exactly the same as /rcon tell slot?

    PHP Code:
    consoleSay(message)
    {
        
    sendgameservercommand(-1"h \"console: " message "\"");

    Last edited by Mitch; 29th June 2015 at 19:07. Reason: Changed Console to console.

  7. #5
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    Quote Originally Posted by Mitch View Post
    PHP Code:
    tellMessage(message)
    {
        
    sendgameservercommand(self getentitynumber(), "h \"Console: " message "\"");

    Is this exactly the same as /rcon tell slot?
    why must you do "h \ Console: "?

    Click image for larger version. 

Name:	Oe5UcYy.jpg 
Views:	90 
Size:	138.5 KB 
ID:	871
    Code:
    		case "help":
    			self.id=self getEntityNumber();
    			message = "Available commands: !ratio";
    	 		self thread tellMessage(message);
    Code:
    tellMessage(message)
    {
        Cmd_ExecuteString("tell " + self getEntityNumber() + " " + message);
    }
    Why does it print it 3 times? 1 normal and 2 weird ones
    Last edited by Ni3ls; 29th June 2015 at 18:59.

  8. #6
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    PHP Code:
    = switch to weapon
    config string modified
    e
    /game message
    bold game message
    chat
    team chat 
    You send your message like this:
    PHP Code:
    "message" 

  9. The Following 2 Users Say Thank You to Mitch For This Useful Post:

    kung foo man (29th June 2015),Ni3ls (29th June 2015)

  10. #7
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    Code:
    		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

  11. #8
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Quote Originally Posted by Ni3ls View Post
    Code:
    		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.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  12. The Following 2 Users Say Thank You to IzNoGoD For This Useful Post:

    kung foo man (29th June 2015),Ni3ls (29th June 2015)

  13. #9
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    Quote Originally Posted by Ni3ls View Post
    Code:
    		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:

    PHP Code:
    sendgameservercommand(self getentitynumber(), "h \"" self.name "^7: !help\""); 
    Edit: Others won't receive this message.
    Last edited by Mitch; 29th June 2015 at 20:05.

  14. #10
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    It is in the playercommand callback?
    Code:
    		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(); 
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •