Raised This Month: $ Target: $400
 0% 

Parse


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Diegorkable
Veteran Member
Join Date: Jun 2011
Old 10-27-2011 , 19:39   Parse
Reply With Quote #1

Hey.

I used the parse() function in the 'say' hook function and it doesnt work properly I don't know why. I did the following:

PHP Code:
public plugin_init()
{
            
// bla bla...
            
register_clcmd("say""say_hook")
}

public 
say_hook(id)
{
    new 
message[100]
    
read_args(message99)
    
    new 
part1[50], part2[50]
    
parse(messagepart1, (sizeof(part1) - 1), part2, (sizeof(part2) - 1))
    
client_print(idprint_chat"Arg1 = %s, Arg2 = %s"part1part2)

When I try for example type /points p1Mp, it prints then this:
Code:
Arg1 = /points, Arg2 =
And that's wierd, I don't get why is arg2 is nothing, the parse should copy the 2nd arg into part2 variable.

What am I doing wrong?

Thanks in advance.
__________________
My Projects:

Auto-Mix (Pug): 100%

Joined the Military (a soldier now) - Inactive
Diegorkable is offline
Erox902
Veteran Member
Join Date: Jun 2009
Location: Never Never Land
Old 10-27-2011 , 19:46   Re: Parse
Reply With Quote #2

Cuz' of this I believe it assumes that the first part is 49 characters:
PHP Code:
new part1[50], part2[50
I think you'll have to check were the first space in the msg is.

Seems kinda wierd however that you got that ", Arg2 =" printed.

Last edited by Erox902; 10-27-2011 at 19:48.
Erox902 is offline
Diegorkable
Veteran Member
Join Date: Jun 2011
Old 10-27-2011 , 19:57   Re: Parse
Reply With Quote #3

The message is simple: "/level p1Mp"

the space is after '/level' and then p1Mp. and I dont think the 50 is the cause, cuz what it does is take arg1 and just copy it on 50 cells array (then it'll have like 8 cells with values then the rest are NULL TERMINATORS), but it doesnt (shouldnt) affect the parse....
__________________
My Projects:

Auto-Mix (Pug): 100%

Joined the Military (a soldier now) - Inactive
Diegorkable is offline
Diegorkable
Veteran Member
Join Date: Jun 2011
Old 10-27-2011 , 20:14   Re: Parse
Reply With Quote #4

Just found something wierd, it parses the message by " but not SPACE
I typed /level" p1Mp
and it said:

arg1 = /level, arg2 = p1Mp

Why the heck is it breaking at "??? how can I change it to SPACE
__________________
My Projects:

Auto-Mix (Pug): 100%

Joined the Military (a soldier now) - Inactive
Diegorkable is offline
Erox902
Veteran Member
Join Date: Jun 2009
Location: Never Never Land
Old 10-27-2011 , 20:19   Re: Parse
Reply With Quote #5

Quote:
Originally Posted by Diegorkable View Post
the space is after '/level' and then p1Mp. and I dont think the 50 is the cause, cuz what it does is take arg1 and just copy it on 50 cells array (then it'll have like 8 cells with values then the rest are NULL TERMINATORS), but it doesnt (shouldnt) affect the parse....
Not sure but maybe you'll have to check out strbreak() or split()
Erox902 is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 10-27-2011 , 20:31   Re: Parse
Reply With Quote #6

read_args places all the arguments within quotes. You need to use remove_quotes on message first.

parse separates based on quotations before spaces.
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`
Diegorkable
Veteran Member
Join Date: Jun 2011
Old 10-27-2011 , 20:46   Re: Parse
Reply With Quote #7

ty
__________________
My Projects:

Auto-Mix (Pug): 100%

Joined the Military (a soldier now) - Inactive
Diegorkable is offline
Reply



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 14:15.


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