AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Give Money (https://forums.alliedmods.net/showthread.php?t=87063)

Emilioneri 03-06-2009 08:47

Give Money
 
PHP Code:

#include <amxmodx>
#include <cstrike>

#define PLUGIN "Admin Rich"
#define VERSION "1.0"
#define AUTHOR "emilioneri"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
// Add your code here...
    
register_concmd("amx_rich""cmd_rich"ADMIN_SLAY"<give user 16000$>")
    return 
PLUGIN_HANDLED
}

public 
cmd_rich(idlevelcid)
{
    new 
Arg1[24]
    new 
Arg2[4]
    
    
read_argv(1Arg123)
    
read_argv(2Arg23)
    
    new 
players[32], num
    get_players
(playersnum)
    new 
i
    
for (i=0i<numi++)
    
    
cs_set_user_money(players[i], 16000)
    return 
PLUGIN_HANDLED


Plugins does not works correctly :(. When I type "amx_rich" I am getting 16000$ but when I type For example: "amx_rich tarasa" he does not gets money! What is wrong :?: :?: :?:

anakin_cstrike 03-06-2009 09:06

Re: Give Money
 
You must check if the arg is a character, for instance @, wich means all players. Then loop trough all player like you did. Otherwise use cmd_target. Here you have an example of doing that: http://wiki.amxmodx.org/Intro_to_AMX_Mod_X_Scripting

TheRadiance 03-06-2009 09:11

Re: Give Money
 
This would be more correctly:
PHP Code:

public cmd_rich(idlevelcid

    if(!
cmd_access(idlevelcid3))
        return 
PLUGIN_HANDLED
    
new Arg1[24
    new 
Arg2[4
     
    
read_argv(1Arg123
    
read_argv(2Arg23
     
    new 
players[32], num 
    get_players
(playersnum
    new 

    
for (i=0i<numi++) 
     
    
cs_set_user_money(players[i], 16000
    return 
PLUGIN_HANDLED 



hleV 03-06-2009 09:12

Re: Give Money
 
Code:
#include <amxmodx> #include <amxmisc> #include <cstrike>   public plugin_init()         register_concmd("amx_rich", "Rich", ADMIN_SLAY, "<name or #userid> - gives $16000");   public Rich(Client, Level, Command) {         if (!cmd_access(Client, Level, Command, 3))                 return PLUGIN_HANDLED;           new Argument[32]         read_argv(1, Argument, 1);           new Target = cmd_target(Client, Argument, CMDTARGET_ALLOW_SELF | CMDTARGET_OBEY_IMMUNITY);           if (Target)         {                 new AdminName[32], TargetName[32];                   get_user_name(Client, AdminName, 31);                 get_user_name(Target, TargetName, 31);                 cs_set_user_money(Target, 16000, 1);                 client_print(0, print_chat, "ADMIN %s :  set %s's money to $16000", AdminName, TargetName);         }           return PLUGIN_HANDLED; }

anakin_cstrike 03-06-2009 09:13

Re: Give Money
 
Quote:

new Argument[32]

read_argv(1, Argument, 1);
->
Code:
read_argv( 1, Argument, 31 );

iNspiratioN 03-06-2009 09:14

Re: Give Money
 
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
 
#define PLUGIN "Admin Rich"
#define VERSION "1.0"
#define AUTHOR "emilioneri"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
// Add your code here...
    
register_concmd("amx_rich""cmd_rich"ADMIN_SLAY"<give user 16000$>")
    return 
PLUGIN_HANDLED 
}
 
public 
cmd_rich(idlevelcid)
{
     if (!
cmd_access(idlevelcid3))
        return 
PLUGIN_HANDLED
 
     
new Arg1[24]
     new 
Arg2[4]
 
     
read_argv(1Arg123)
     
read_argv(2Arg23)
 
     new 
Money str_to_num(Arg2)
 
     if (
Arg1[0] == '@')
     {
          new 
Team 0
          
if (equali(Arg1[1], "CT"))
          {
               
Team 2
          
} else if (equali(Arg1[1], "T")) {
               
Team 1
          
}
          new 
players[32], num
          get_players
(playersnum)
          new 
i
          
for (i=0i<numi++)
          {
               if (!
Team)
               {
                    
cs_set_user_money(players[i], Money)
               } else {
                    if (
get_user_team(players[i]) == Team)
                    {
                         
cs_set_user_money(players[i], Money)
                    }
               }
          }
     } else {
          new 
player cmd_target(idArg11)
          if (!
player)
          {
               
console_print(id"Didn't found %s"Arg1)
               return 
PLUGIN_HANDLED
          
} else {
               
cs_set_user_money(playerMoney)
          }
     }
 
     return 
PLUGIN_HANDLED


EDIT: Dang every1 helped him so fast! :D

Emilioneri 03-06-2009 09:32

Re: Give Money
 
Thanks for helping! :) +karma to all :D

And can you tell me. Whats is the difference:
"ADMIN_KICK" and "ADMIN_LEVEL_C" ??

Thanks again :)

anakin_cstrike 03-06-2009 09:48

Re: Give Money
 
Check out users.ini
PS: There is no need to write a message if the player isn't found.

Emilioneri 03-06-2009 10:51

Re: Give Money
 
Done. I made that plugin. But there is one bug. When I type "amx_rich emilioneri"
I don't get money. I have to type any symbol, letter or number after the name.
for example: "amx_rich emilioneri s" or "amx_rich emilioneri 3" or "amx_rich emilioneri >" and etc.

Here is the code:

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define PLUGIN "Admin Rich"
#define VERSION "1.0"
#define AUTHOR "emilioneri"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
// Add your code here...
    
register_concmd("amx_rich""cmd_rich"ADMIN_SLAY"<name | #userid> - makes player rich!")
    
    return 
PLUGIN_HANDLED
}

public 
cmd_rich(idlevelcid)
{
    if (!
cmd_access(idlevelcid3))
             return 
PLUGIN_HANDLED
         
    
new Argument[32]
    
    
read_argv(1Argument31)
    
    new 
Target cmd_target(idArgumentCMDTARGET_ALLOW_SELF)
    
    if(
Target)
    
    
cs_set_user_money(Target16000)
    
    return 
PLUGIN_HANDLED



padilha007 03-06-2009 11:03

Re: Give Money
 
read_argv(1, Argument, 31)

to:

read_argv(0, Argument, 31)


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

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