AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   some newbie questions :o (https://forums.alliedmods.net/showthread.php?t=3360)

blaah 07-04-2004 15:44

some newbie questions :o
 
hi,
i want to write a little, useless plugin, that allows to spend each other 1$.
as i don't have written any other plugins before i tryed to put some code together and to get it running. :roll:
now i have some questions:
- how can i put a counter in there, to check how often someone spends money
- how can i change the concmd so that there must be at least 2 arguments instead of 3

Code:

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

public plugin_init(){
        register_plugin("Spendmoney","0.1","Jens")
        //register_clcmd("say a", "give")
        register_concmd("amx_spend","give", ADMIN_LEVEL_A,"<nick> OR <#userid>")
}

public give(id,level,cl){
        if (!cmd_access(id,level,cl,3)){
                return PLUGIN_HANDLED
        }
        new frst[32], name2[32], name[32]
        read_argv(1,frst,31)

        new player = cmd_target(id,frst)
        if (!player) return PLUGIN_HANDLED
       
          get_user_name(id,name,31)
        get_user_name(player,name2,31)
        cs_set_user_money(player,cs_get_user_money(player)+1,1)
        set_hudmessage(6,13,28,0.05,0.86,2, 3.0, 2.0, 0.2, 3.0, 1)
        show_hudmessage(0, "%s spendet %s $1,00..", name, name2)
        client_print(id,print_chat,"Yeah! Du hast %s $1,00 gespendet..",name2)
        return PLUGIN_HANDLED
}

beginnig is always hard :roll:

Downtown1 07-04-2004 15:49

Code:
   if (!cmd_access(id,level,cl,3)){            return PLUGIN_HANDLED    }

The 3 there is how many arguments AMXX wants you to have before it lets you use the command, so change it to '2' and people will be able to have 2 arguments provided the rest of your plugin reads the second argument.

So use this:
Code:
   if (!cmd_access(id,level,cl,2)){            return PLUGIN_HANDLED    }

blaah 07-04-2004 16:08

ah, okay.. thaaanks! :)

blaah 07-05-2004 13:37

new day - new plugins - news question *g* :roll:
how can i choose a randoom player?

i tryed to make a small plugin to test an idea.. but it doesent realy works :cry:
Code:

        new rnd = 0;
        new res = 0;
        while(res == 0){
                rnd = random(15);
                new hp = get_user_health(rnd)
                if (!hp){
                        client_print(0,print_chat,"%d %d exsists not",rnd, player);
                }else{
                        res = rnd;
                        client_print(0,print_chat,"%d %d exists",rnd, player);
                }
        }



All times are GMT -4. The time now is 14:48.

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