Raised This Month: $32 Target: $400
 8% 

How to parse string?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
amxxn00b
Junior Member
Join Date: Nov 2006
Old 11-24-2006 , 15:31   How to parse string?
Reply With Quote #1

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
amxxn00b is offline
Greenberet
AMX Mod X Beta Tester
Join Date: Apr 2004
Location: Vienna
Old 11-24-2006 , 16:31   Re: How to parse string?
Reply With Quote #2

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])   } }
Greenberet is offline
Send a message via ICQ to Greenberet Send a message via MSN to Greenberet
amxxn00b
Junior Member
Join Date: Nov 2006
Old 11-24-2006 , 16:47   Re: How to parse string?
Reply With Quote #3

Thank You man!

Plz tell me about this '%'...

%s - string
%d - integer
%f - float
%c - array ?
%i - ??
amxxn00b is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 11-24-2006 , 18:08   Re: How to parse string?
Reply With Quote #4

pretty sure it is:

%s - string
%d - integer
%f - float
%c - character
%i - integer
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 11-24-2006 , 21:39   Re: How to parse string?
Reply With Quote #5

%d - data
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 11-25-2006 , 07:41   Re: How to parse string?
Reply With Quote #6

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.
[ --<-@ ] Black Rose is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:11.


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