Raised This Month: $ Target: $400
 0% 

read_arv issue


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 08-02-2011 , 03:16   read_arv issue
Reply With Quote #1

So im trying to create a command amx_friendlyfire to change the value of mp_friendlyfire

PHP Code:
public cmdFriendlyfire(id)
{
    new 
arg[2];
    
read_argv(1argsizeof(arg));
        
    
server_cmd("mp_friendlyfire %s"arg);
    
    
console_print(id"mp_friendlyfire changed to  %s."arg);
    
    return 
PLUGIN_HANDLED;

This works fine if i use 1 or 0 but if i try 0.25 it juts does 0... BTW i tried using str_to_float and %f... so don't say its because its a int...

****face-palm****** arg[2] HAHAHAHAHA Look don't laugh at me......... I'm tired...

Last edited by Doc-Holiday; 08-02-2011 at 05:15.
Doc-Holiday is offline
lazarev
Veteran Member
Join Date: Sep 2008
Old 08-02-2011 , 03:28   Re: read_arv issue
Reply With Quote #2

if you convert "0.25" or "123131.1232131" to an integer, it will return 0
lazarev is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 08-02-2011 , 04:06   Re: read_arv issue
Reply With Quote #3

Quote:
Originally Posted by lazarev View Post
if you convert "0.25" or "123131.1232131" to an integer, it will return 0
lol... that wasnt my problem please read the whole first post.
Doc-Holiday is offline
Old 08-02-2011, 05:10
pingplug
This message has been deleted by ConnorMcLeod. Reason: FakePlayer
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 08-02-2011 , 05:16   Re: read_arv issue
Reply With Quote #5

Quote:
Originally Posted by pingplug View Post
This is correct???
The updated code in first post works fine for setting it to single and double digit numbrs.

for my purpose i needed it arg[4]
Doc-Holiday is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-02-2011 , 08:34   Re: read_arv issue
Reply With Quote #6

I'm confused. Is there still an issue here? If yes, debug with read_args().
__________________
fysiks is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 08-02-2011 , 08:39   Re: read_arv issue
Reply With Quote #7

No, it doesn't seem so. But why you would want to be putting anything other than a 1 or 0 into that command is beyond me.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-02-2011 , 09:59   Re: read_arv issue
Reply With Quote #8

new arg[2];

This is your problem. Remember, the number of characters you can store in a null-terminated string is size-1 meaning you only allocated enough room for 1 number. Increase your string size large enough to store your max possible value + 1, ie. 123.456 would require a string sized to 8. Also, always use charsmax() when working with strings, not sizeof().

Edit:

Quote:
Originally Posted by Doc-Holiday View Post
for my purpose i needed it arg[4]
Just noticed this so I think you realized your issue.
__________________

Last edited by Bugsy; 08-02-2011 at 11:34.
Bugsy is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 08-02-2011 , 14:59   Re: read_arv issue
Reply With Quote #9

I realized it before in my first post. Read the facepalm lol... and at the guy go into approved plugin and view my variable friendly fire. That's what this was for.
Doc-Holiday 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 03:27.


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