Raised This Month: $ Target: $400
 0% 

admin command problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 04-18-2011 , 12:24   admin command problem
Reply With Quote #1

so i made a plugin that gives, takes or sets a player's ammo pack to a specified amount
the problem is that when i try to exec this on a specified person it sets the admin's ammo packs to the specified amount instead of the specified player's
also it displays the admin's name a second time instead of the player's
Example:
instead of
ADMIN Admin: give 57 ammo pack(s) to Player
it does
ADMIN Admin: give 57 ammo pack(s) to Admin
please help...explain to me what i've done wrong
here's the code:
PHP Code:
#include <amxmodx>
#include <chatcolor>
#include <zombieplaguenm>

new g_maxplayersbool:g_isconnected[33], show_activity

#define is_user_valid_connected(%1) (1 <= %1 <= g_maxplayers && g_isconnected[%1])

public plugin_init()
{
    
register_plugin("[ZPNM] Sub-Plugin: Manage Ammo Packs""1.0""9 3 () |2 9 ! /<")
    
    
register_dictionary_colored("zpnm_manage_ampks.txt")
    
    
register_concmd("zpnm_set_ampks""CmdSetAmpks"ADMIN_RCON"<*/@surv/@snip/@hm/@nem/@zm/name> <amount to set/+/-> <amount>")
    
    
g_maxplayers get_maxplayers()
}

public 
client_putinserver(id)
    
g_isconnected[id] = true

public client_disconnect(id)
    
g_isconnected[id] = false

public CmdSetAmpks(idlevelaid)
{
    if (!
cmd_access(idlevel aid3)
    || !
is_user_valid_connected(id))
        return;
    
    static 
arg1[32], arg2[32], arg3[32], idname[33], aname[33], iarg2numarg3num
    
    read_argv
(1arg131)
    
read_argv(2arg231)
    
read_argv(3arg331)
    
    
get_user_name(ididname32)
    
get_user_name(aidaname32)
    
    
arg2num str_to_num(arg2)
    
arg3num str_to_num(arg3)
    
    
show_activity get_cvar_num("amx_show_activity")
    
    if (!
equali(arg1"*") && !equali(arg1"@surv") && !equali(arg1"@snip")
    && !
equali(arg1"@hm") && !equali(arg1"@nem") && !equali(arg1"@zm"))
    {
        if (
equali(arg2"+"))
        {
            
zp_set_user_ammo_packs(idzp_get_user_ammo_packs(id) + arg3num)
            
            if (
show_activity == 1)
                
client_print_color(0Blue"%L"LANG_PLAYER"ZPNM_GIVE_PLAYER1"arg3numidname//, arg3 > 1 ? "s" : ""
            
else if (show_activity == 2)
                
client_print_color(0DontChange"%L"LANG_PLAYER"ZPNM_GIVE_PLAYER2"anamearg3numidname)
        }
        else if (
equali(arg2"-"))
        {
            
zp_set_user_ammo_packs(idzp_get_user_ammo_packs(id) - arg3num)
            
            if (
show_activity == 1)
                
client_print_color(0Blue"%L"LANG_PLAYER"ZPNM_TAKE_PLAYER1"arg3numidname)
            else if (
show_activity == 2)
                
client_print_color(0DontChange"%L"LANG_PLAYER"ZPNM_TAKE_PLAYER2"anamearg3numidname)
        }
        else
        {
            
zp_set_user_ammo_packs(idarg2num)
            
            if (
show_activity == 1)
                
client_print_color(0Blue"%L"LANG_PLAYER"ZPNM_SET_PLAYER1"idnamearg2num)
            else if (
show_activity == 2)
                
client_print_color(0DontChange"%L"LANG_PLAYER"ZPNM_SET_PLAYER2"anameidnamearg2num)
        }
        
        return;
    }
    
    for (
1<= g_maxplayersi++)
    {
        if (
equali(arg1"*"))
        {
            if (
equali(arg2"+"))
            {
                
zp_set_user_ammo_packs(izp_get_user_ammo_packs(i) + arg3num)
                
                if (
show_activity == 1)
                    
client_print_color(iBlue"%L"i"ZPNM_GIVE_PLAYERS1"arg3num)
                else if (
show_activity == 2)
                    
client_print_color(iDontChange"%L"i"ZPNM_GIVE_PLAYERS2"anamearg3num)
            }
            else if (
equali(arg2"-"))
            {
                
zp_set_user_ammo_packs(izp_get_user_ammo_packs(i) - arg3num)
                
                if (
show_activity == 1)
                    
client_print_color(iBlue"%L"i"ZPNM_TAKE_PLAYERS1"arg3num)
                else if (
show_activity == 2)
                    
client_print_color(iDontChange"%L"i"ZPNM_TAKE_PLAYERS2"anamearg3num)
            }
            else
            {
                
zp_set_user_ammo_packs(iarg2num)
                
                if (
show_activity == 1)
                    
client_print_color(iBlue"%L"i"ZPNM_SET_PLAYERS1"arg2num)
                else if (
show_activity == 2)
                    
client_print_color(iDontChange"%L"i"ZPNM_SET_PLAYERS2"anamearg2num)
            }
        }
        else if (
equali(arg1"@surv"))
        {
            if (
equali(arg2"+"))
            {
                if (
zp_get_user_survivor(i))
                    
zp_set_user_ammo_packs(izp_get_user_ammo_packs(i) + arg3num)
                
                if (
show_activity == 1)
                    
client_print_color(iBlue"%L"i"ZPNM_GIVE_SURVIVORS1"arg3num)
                else if (
show_activity == 2)
                    
client_print_color(iDontChange"%L"i"ZPNM_GIVE_SURVIVORS2"anamearg3num)
            }
            else if (
equali(arg2"-"))
            {
                if (
zp_get_user_survivor(i))
                    
zp_set_user_ammo_packs(izp_get_user_ammo_packs(i) - arg3num)
                
                if (
show_activity == 1)
                    
client_print_color(iBlue"%L"i"ZPNM_TAKE_SURVIVORS1"arg3num)
                else if (
show_activity == 2)
                    
client_print_color(iDontChange"%L"i"ZPNM_TAKE_SURVIVORS2"anamearg3num)
            }
            else
            {
                if (
zp_get_user_survivor(i))
                    
zp_set_user_ammo_packs(iarg2num)
                
                if (
show_activity == 1)
                    
client_print_color(iBlue"%L"i"ZPNM_SET_SURVIVORS1"arg2num)
                else if (
show_activity == 2)
                    
client_print_color(iDontChange"%L"i"ZPNM_SET_SURVIVORS2"anamearg2num)
            }
        }
        else if (
equali(arg1"@snip"))
        {
            if (
equali(arg2"+"))
            {
                if (
zpnm_get_user_sniper(i))
                    
zp_set_user_ammo_packs(izp_get_user_ammo_packs(i) + arg3num)
                
                if (
show_activity == 1)
                    
client_print_color(iBlue"%L"i"ZPNM_GIVE_SNIPERS1"arg3num)
                else if (
show_activity == 2)
                    
client_print_color(iDontChange"%L"i"ZPNM_GIVE_SNIPERS2"anamearg3num)
            }
            else if (
equali(arg2"-"))
            {
                if (
zpnm_get_user_sniper(i))
                    
zp_set_user_ammo_packs(izp_get_user_ammo_packs(i) - arg3num)
                
                if (
show_activity == 1)
                    
client_print_color(iBlue"%L"i"ZPNM_TAKE_SNIPERS1"arg3num)
                else if (
show_activity == 2)
                    
client_print_color(iDontChange"%L"i"ZPNM_TAKE_SNIPERS2"anamearg3num)
            }
            else
            {
                if (
zpnm_get_user_sniper(i))
                    
zp_set_user_ammo_packs(iarg2num)
                
                if (
show_activity == 1)
                    
client_print_color(iBlue"%L"i"ZPNM_SET_SNIPERS1"arg2num)
                else if (
show_activity == 2)
                    
client_print_color(iDontChange"%L"i"ZPNM_SET_SNIPERS2"anamearg2num)
            }
        }
        else if (
equali(arg1"@hm"))
        {
            if (
equali(arg2"+"))
            {
                if (!
zp_get_user_zombie(i) && !zp_get_user_survivor(i) && !zpnm_get_user_sniper(i))
                    
zp_set_user_ammo_packs(izp_get_user_ammo_packs(i) + arg3num)
                
                if (
show_activity == 1)
                    
client_print_color(iBlue"%L"i"ZPNM_GIVE_HUMANS1"arg3num)
                else if (
show_activity == 2)
                    
client_print_color(iDontChange"%L"i"ZPNM_GIVE_HUMANS2"anamearg3num)
            }
            else if (
equali(arg2"-"))
            {
                if (!
zp_get_user_zombie(i) && !zp_get_user_survivor(i) && !zpnm_get_user_sniper(i))
                    
zp_set_user_ammo_packs(izp_get_user_ammo_packs(i) - arg3num)
                
                if (
show_activity == 1)
                    
client_print_color(iBlue"%L"i"ZPNM_TAKE_HUMANS1"arg3num)
                else if (
show_activity == 2)
                    
client_print_color(iDontChange"%L"i"ZPNM_TAKE_HUMANS2"anamearg3num)
            }
            else
            {
                if (!
zp_get_user_zombie(i) && !zp_get_user_survivor(i) && !zpnm_get_user_sniper(i))
                    
zp_set_user_ammo_packs(iarg2num)
                
                if (
show_activity == 1)
                    
client_print_color(iBlue"%L"i"ZPNM_SET_HUMANS1"arg2num)
                else if (
show_activity == 2)
                    
client_print_color(iDontChange"%L"i"ZPNM_SET_HUMANS2"anamearg2num)
            }
        }
        else if (
equali(arg1"@nem"))
        {
            if (
equali(arg2"+"))
            {
                if (
zp_get_user_nemesis(i))
                    
zp_set_user_ammo_packs(izp_get_user_ammo_packs(i) + arg3num)
                
                if (
show_activity == 1)
                    
client_print_color(iBlue"%L"i"ZPNM_GIVE_NEMESIS1"arg3num)
                else if (
show_activity == 2)
                    
client_print_color(iDontChange"%L"i"ZPNM_GIVE_NEMESIS2"anamearg3num)
            }
            else if (
equali(arg2"-"))
            {
                if (
zp_get_user_nemesis(i))
                    
zp_set_user_ammo_packs(izp_get_user_ammo_packs(i) - arg3num)
                
                if (
show_activity == 1)
                    
client_print_color(iBlue"%L"i"ZPNM_TAKE_NEMESIS1"arg3num)
                else if (
show_activity == 2)
                    
client_print_color(iDontChange"%L"i"ZPNM_TAKE_NEMESIS2"anamearg3num)
            }
            else
            {
                if (
zp_get_user_nemesis(i))
                    
zp_set_user_ammo_packs(iarg2num)
                
                if (
show_activity == 1)
                    
client_print_color(iBlue"%L"i"ZPNM_SET_NEMESIS1"arg2num)
                else if (
show_activity == 2)
                    
client_print_color(iDontChange"%L"i"ZPNM_SET_NEMESIS2"anamearg2num)
            }
        }
        else if (
equali(arg1"@zm"))
        {
            if (
equali(arg2"+"))
            {
                if (
zp_get_user_zombie(i) && !zp_get_user_nemesis(i))
                    
zp_set_user_ammo_packs(izp_get_user_ammo_packs(i) + arg3num)
                
                if (
show_activity == 1)
                    
client_print_color(iBlue"%L"i"ZPNM_GIVE_ZOMBIES1"arg3num)
                else if (
show_activity == 2)
                    
client_print_color(iDontChange"%L"i"ZPNM_GIVE_ZOMBIES2"anamearg3num)
            }
            else if (
equali(arg2"-"))
            {
                if (
zp_get_user_zombie(i) && !zp_get_user_nemesis(i))
                    
zp_set_user_ammo_packs(izp_get_user_ammo_packs(i) - arg3num)
                
                if (
show_activity == 1)
                    
client_print_color(iBlue"%L"i"ZPNM_TAKE_ZOMBIES1"arg3num)
                else if (
show_activity == 2)
                    
client_print_color(iDontChange"%L"i"ZPNM_TAKE_ZOMBIES2"anamearg3num)
            }
            else
            {
                if (
zp_get_user_zombie(i) && !zp_get_user_nemesis(i))
                    
zp_set_user_ammo_packs(iarg2num)
                
                if (
show_activity == 1)
                    
client_print_color(iBlue"%L"i"ZPNM_SET_ZOMBIES1"arg2num)
                else if (
show_activity == 2)
                    
client_print_color(iDontChange"%L"i"ZPNM_SET_ZOMBIES2"anamearg2num)
            }
        }
    }
}

stock is_user_admin(id)
{
    new 
__flags=get_user_flags(id);
    return (
__flags>&& !(__flags&ADMIN_USER));
}

stock cmd_access(idlevelcidnumbool:accesssilent false
{
    new 
has_access 0;
    if ( 
id==(is_dedicated_server()?0:1) ) 
    {
        
has_access 1;
    }
    else if ( 
level==ADMIN_ADMIN )
    {
        if ( 
is_user_admin(id) )
        {
            
has_access 1;
        }
    }
    else if ( 
get_user_flags(id) & level )
    {
        
has_access 1;
    }
    else if (
level == ADMIN_ALL
    {
        
has_access 1;
    }

    if ( 
has_access==
    {
        if (!
accesssilent)
        {
#if defined AMXMOD_BCOMPAT
            
console_print(idSIMPLE_T("You have no access to that command."));
#else
            
console_print(id,"%L",id,"NO_ACC_COM");
#endif
        
}
        return 
0;
    }
    if (
read_argc() < num
    {
        new 
hcmd[32], hinfo[128], hflag;
        
get_concmd(cid,hcmd,31,hflag,hinfo,127,level);
#if defined AMXMOD_BCOMPAT
        
console_print(idSIMPLE_T("Usage:  %s %s"), hcmdSIMPLE_T(hinfo));
#else
        
console_print(id,"%L:  %s %s",id,"USAGE",hcmd,hinfo);
#endif
        
return 0;
    }
    
    return 
1;

Attached Files
File Type: sma Get Plugin or Get Source (zpnm_manage_ampks.sma - 594 views - 10.1 KB)
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-18-2011 , 12:53   Re: admin command problem
Reply With Quote #2

The third argument in public CmdSetAmpks(id, level, aid) is teh Command ID, yet you are using it in get_user_name().
__________________
fysiks is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 04-18-2011 , 12:57   Re: admin command problem
Reply With Quote #3

command id meaning the admin id, right?
so what if i'm using it in get_user_name? o_O
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-18-2011 , 13:00   Re: admin command problem
Reply With Quote #4

Quote:
Originally Posted by georgik57 View Post
command id meaning the admin id, right?
so what if i'm using it in get_user_name? o_O
The command id is the id of the COMMAND zpnm_set_ampks used in get_concmd().
__________________
fysiks is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 04-18-2011 , 13:02   Re: admin command problem
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
The command id is the id of the COMMAND zpnm_set_ampks used in get_concmd().
so then the id is the id of the admin, right?
how can i get the id of the target player then?
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-18-2011 , 13:03   Re: admin command problem
Reply With Quote #6

Quote:
Originally Posted by georgik57 View Post
so then the id is the id of the admin, right?
how can i get the id of the target player then?
"id" is the entity index of the player which executed the command.
cmd_target().
__________________
fysiks is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 04-18-2011 , 13:04   Re: admin command problem
Reply With Quote #7

Quote:
Originally Posted by fysiks View Post
"id" is the entity index of the player which executed the command.
cmd_target().
show me an example about how to use that cmd_target thingy please :D
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-18-2011 , 13:05   Re: admin command problem
Reply With Quote #8

Quote:
Originally Posted by georgik57 View Post
show me an example about how to use that cmd_target thingy please
It's used in every other plugin. Look in one. admincmd.sma
__________________
fysiks is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 04-18-2011 , 13:15   Re: admin command problem
Reply With Quote #9

are the flags(3rd argument) really necessary to specify?
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-18-2011 , 13:16   Re: admin command problem
Reply With Quote #10

Quote:
Originally Posted by georgik57 View Post
are the flags(3rd argument) really necessary to specify?
No but if you don't then the default will be used. Default is CMDTARGET_OBEY_IMMUNITY.

Open include/amxmisc.inc
__________________
fysiks 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 20:10.


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