AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Problem with adding value to other value using concmd (https://forums.alliedmods.net/showthread.php?t=205053)

Kia 01-06-2013 08:50

Problem with adding value to other value using concmd
 
Hello everybody,

I've got a little problem here, I want to give the player with userid X 20 Points using the command :
Quote:

PHP Code:

"kbm_give_points_easy %i"usrid[id


.
The HUD Message is displaying, but the player doesn't get any Points.

Code of kbm_give_points_easy :

Quote:

PHP Code:

new Arg1[24]
read_argv(1Arg123)
    
new 
player cmd_target(idArg16)
iCoins[player] += 20
    
set_dhudmessage
(02550, -1.00.6906.06.0)
show_dhudmessage(player"You got 20 Points."


Anyone knows what I'm doing wrong?

xDrugz 01-06-2013 09:19

Re: Problem with adding value to other value using concmd
 
Try this code

Code:

#include < amxmodx >
#include < amxmisc >
#include < dhudmessage >

new iCoins[ 33 ];

public plugin_init()
{
        register_concmd( "kbm_give_points_easy", "CmdGivePoints" );
}

public CmdGivePoints( client )
{
        new szArgs[ 35 ];
       
        read_argv( 1, szArgs, charsmax( szArgs ) );
       
        new iPlayer = cmd_target( client, szArgs, CMDTARGET_NO_BOTS );
       
        if( iPlayer )
        {
                iCoins[ iPlayer ] += 20;
               
                set_dhudmessage( 0, 255, 0, -1.0, 0.69, 0, 6.0, 6.0 );
               
                show_dhudmessage( iPlayer, "You got 20 Points. (Total: %i)", iCoins[ iPlayer ] );
        }

        return 1;
}


Kia 01-06-2013 09:48

Re: Problem with adding value to other value using concmd
 
Thanks, is working. Had to change "%i " ( using UserID) to "%s" (using Username).

jimaway 01-06-2013 11:16

Re: Problem with adding value to other value using concmd
 
"kbm_give_points_easy #%i", usrid[id]
should work

fysiks 01-06-2013 16:25

Re: Problem with adding value to other value using concmd
 
Quote:

Originally Posted by Kia (Post 1868186)
Thanks, is working. Had to change "%i " ( using UserID) to "%s" (using Username).

When using user ids with commands you have to use "#%i"


All times are GMT -4. The time now is 13:40.

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