Raised This Month: $51 Target: $400
 12% 

Double number argv


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AnimalMonster
Senior Member
Join Date: May 2020
Old 03-23-2021 , 04:32   Double number argv
Reply With Quote #1

Hey, some time ago i tried to get a number with read_argv and returned PLUGIN_CONTINUE/_HANDLED and gave me the number doubled but when i put return -1 it would give me the correct number. Why is that? I am still confused right now
AnimalMonster is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-23-2021 , 08:54   Re: Double number argv
Reply With Quote #2

I am also confused by your entire post and what you're trying to say. Please show some code.
read_argv() returns a string, not a number.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
LondoN
Senior Member
Join Date: Dec 2015
Location: Roman, Romania.
Old 03-23-2021 , 10:23   Re: Double number argv
Reply With Quote #3

Code:
if(arg_string > 0) return (str_to_num(arg_string) * 2);
probably helps you, however, show us your code.

Code:
#include < amxmodx >
#include < amxmisc >

public plugin_init ( )	register_concmd ( "double_number", "argvExample", ADMIN_ALL, "" );

public argvExample ( iEntity, userLevel, cID )
{
	if ( !cmd_access ( iEntity, userLevel, cId, 2 ) )
		return;

	new argString [ 16 ];
	read_argv ( 1, argString, charsmax ( argString ) );

	new argValue = str_to_num ( argString )

	if ( argValue != 0 )
	{
		argValue = argValue * 2;
		console_print ( iEntity, "Value: %d", argValue );
	}
}
__________________

Last edited by LondoN; 03-23-2021 at 10:32.
LondoN is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-23-2021 , 23:20   Re: Double number argv
Reply With Quote #4

Quote:
Originally Posted by OciXCrom View Post
I am also confused by your entire post and what you're trying to say. Please show some code.
read_argv() returns a string, not a number.
No. read_argv() returns the "Number of cells written to buffer". It is used to populate a string with the string value of the argument. (I know you know this but just clarifying for others)

Quote:
Originally Posted by LondoN View Post
Code:
if(arg_string > 0) return (str_to_num(arg_string) * 2);
Umm, that doesn't make any sense. You can't compare an array (string) with a scalar value (the zero). Also, the OP is not asking how to multiply a number by 2.
__________________
fysiks is offline
AnimalMonster
Senior Member
Join Date: May 2020
Old 03-24-2021 , 09:04   Re: Double number argv
Reply With Quote #5

Quote:
Originally Posted by OciXCrom View Post
I am also confused by your entire post and what you're trying to say. Please show some code.
read_argv() returns a string, not a number.
Yeah, a string that i converted into a number-_-

And lemme explain again, i made an command something like zp_ammo <type> <value>

and when i got the value returned and converted into nunbers i would get that value doubled if return(at the end of the function) was PLUGIN_CONTINUE or PLUGIN_HANDLED, i might get this mistaken, so i returned -1 and worked

Also idk if i used argv or whatever, i just used something that retrived a string from player command.

So the question is why did that happend?

Last edited by AnimalMonster; 03-24-2021 at 09:11.
AnimalMonster is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-24-2021 , 09:37   Re: Double number argv
Reply With Quote #6

Quote:
Originally Posted by fysiks View Post
No. read_argv() returns the "Number of cells written to buffer"
I was referring to the buffer but yeah, you're right.

@AnimalMonster - "I used something to do something but I don't know what I did". Show your code instead of struggling to explain and making us struggle to understand when you clearly don't know what you've done.
__________________

Last edited by OciXCrom; 03-24-2021 at 09:38.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 03-24-2021 , 13:23   Re: Double number argv
Reply With Quote #7

If you are struggling with reading args from chat commands, you should bear in mind that your command counts as the first arg. Registering "say /cmd", nonetheless, will pass "/cmd" as the first argument.
redivcram is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-24-2021 , 13:44   Re: Double number argv
Reply With Quote #8

He never mentioned chat command nor zp_ammo looks like one. We're just playing guessing games until he posts his 20 lines of code.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 03-24-2021 , 14:21   Re: Double number argv
Reply With Quote #9

Quote:
Originally Posted by OciXCrom View Post
He never mentioned chat command nor zp_ammo looks like one. We're just playing guessing games until he posts his 20 lines of code.
Just leaving it here. Also he said that it looks like zp_ammo, meaning that it could be anything.
redivcram is offline
AnimalMonster
Senior Member
Join Date: May 2020
Old 03-24-2021 , 15:19   Re: Double number argv
Reply With Quote #10

Quote:
Originally Posted by redivcram View Post
Just leaving it here. Also he said that it looks like zp_ammo, meaning that it could be anything.
Eh.. better just put it in trash can i said like but that s the format i made for it(with 2 arguments), so since no one doesn't know what i am talking about i would like it deleted xd bcs if i stay to explain and also provide code it would take a lot of your time :p

And @OciXCrom it isn't chat command but console.

Last edited by AnimalMonster; 03-24-2021 at 15:21.
AnimalMonster 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 17:30.


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