AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   read_arv issue (https://forums.alliedmods.net/showthread.php?t=163669)

Doc-Holiday 08-02-2011 03:16

read_arv issue
 
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...

lazarev 08-02-2011 03:28

Re: read_arv issue
 
if you convert "0.25" or "123131.1232131" to an integer, it will return 0

Doc-Holiday 08-02-2011 04:06

Re: read_arv issue
 
Quote:

Originally Posted by lazarev (Post 1523900)
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 08-02-2011 05:16

Re: read_arv issue
 
Quote:

Originally Posted by pingplug (Post 1523950)
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]

fysiks 08-02-2011 08:34

Re: read_arv issue
 
I'm confused. Is there still an issue here? If yes, debug with read_args().

hornet 08-02-2011 08:39

Re: read_arv issue
 
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.

Bugsy 08-02-2011 09:59

Re: read_arv issue
 
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 (Post 1523951)
for my purpose i needed it arg[4]

Just noticed this so I think you realized your issue.

Doc-Holiday 08-02-2011 14:59

Re: read_arv issue
 
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.


All times are GMT -4. The time now is 03:27.

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