AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to parse string? (https://forums.alliedmods.net/showthread.php?t=47712)

amxxn00b 11-24-2006 15:31

How to parse string?
 
Hello all!

look this:

Code:


#include <amxmodx>
public plugin_init () {
  register_clcmd ("test","test")
}
 
public test() {
  new arg[128]; read_argv(1,arg,127)
  new len = strlen (arg)
  for (new i = 0; i < len+1; i++) {
    server_print (arg[i])
  }
}

i need that server will print:
a
b
c
d
e
but server print:
abcde
bcde
cde
de
e

if arg = abcde ie client type in console test abcde

Greenberet 11-24-2006 16:31

Re: How to parse string?
 
Code:
public test() {   new arg[128]; read_argv(1,arg,127)   new len = strlen (arg)   for (new i = 0; i < len; i++) {     server_print ("%c",arg[i])   } }

amxxn00b 11-24-2006 16:47

Re: How to parse string?
 
Thank You man!

Plz tell me about this '%'...

%s - string
%d - integer
%f - float
%c - array ?
%i - ??

Emp` 11-24-2006 18:08

Re: How to parse string?
 
pretty sure it is:

%s - string
%d - integer
%f - float
%c - character
%i - integer

SweatyBanana 11-24-2006 21:39

Re: How to parse string?
 
%d - data

[ --<-@ ] Black Rose 11-25-2006 07:41

Re: How to parse string?
 
Quote:

Originally Posted by PM
%d or %i -> Prints a signed number in base 10 (decimal)
%u -> Prints an unsigned (=always positive) number in base 10
%x -> Prints an unsigned number in base 16 (hexadecimal)
%c -> Prints a character (say you'd pass 'a' as parameter, then it would print an a)
%f -> Prints a decimal floating point number (something like 3.14)
%g is used as %f; I always use %f because I don't know the difference.
%s -> Prints a string (like "hello pm" )

You could use %0.00f to print a float with a max of 2 decimals.


All times are GMT -4. The time now is 20:16.

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