AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   how to replace to _ if command have space? (https://forums.alliedmods.net/showthread.php?t=56148)

lucky109 06-07-2007 16:01

how to replace to _ if command have space?
 
how to replace space to _ if command have space?

E.G
Code:

#include <amxmodx>

public plugin_init() {
  register_plugin("test","1.0",test")
  register_clcmd("test","test_function",0,"test <sentence words>")
  return PLUGIN_CONTINUE
}

public test_function(id) {
new arg[32]
read_argv(1,arg,31)
client_print(id,print_chat,"%s",arg)
}

if i have to type "test helo goodmorning john"
it's show "helo" only

how can i get the full sentence " helo goodmorning john" ??

thanks

regalis 06-07-2007 16:16

Re: how to replace to _ if command have space?
 
read_args ( output[], len )

greetz regalis

ChanT 06-07-2007 16:17

Re: how to replace to _ if command have space?
 
Quote:

Originally Posted by lucky109 (Post 486753)
how to replace space to _ if command have space?

E.G
Code:

#include <amxmodx>

public plugin_init() {
  register_plugin("test","1.0",test")
  register_clcmd("test","test_function",0,"test <sentence words>")
  return PLUGIN_CONTINUE
}

public test_function(id) {
new arg[32]
read_argv(1,arg,31)
client_print(id,print_chat,"%s",arg)
}

if i have to type "test helo goodmorning john"
it's show "helo" only

how can i get the full sentence " helo goodmorning john" ??

thanks

If i correctly understood what u meant then just try to replace read_argv(1,arg,31) with: read_args(arg,31)

EDIT: eww a sec to late :P

_Master_ 06-08-2007 05:36

Re: how to replace to _ if command have space?
 
Note: you should specify a len value large enough to hold the whole argument line, otherwise it will be truncated

stupok 06-09-2007 12:58

Re: how to replace to _ if command have space?
 
@lucky109

test helo goodmorning john
Will return "helo"
test "helo goodmorning john"
Will return "helo goodmorning john"
@others
I'm not sure if read_args will work like you guys say, haven't tested it recently.


All times are GMT -4. The time now is 10:36.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.