AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Giving a frag, ARGs (https://forums.alliedmods.net/showthread.php?t=108545)

t3hNox 11-06-2009 16:35

Giving a frag, ARGs
 
It's my third attempt to try to script something. I was trying to make something that includes client command usage and arguments - simple frag giving.
Code:

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

public plugin_init() {
        register_plugin("Give Frag", "0.1", "Nick");
        register_clcmd("say /give", "CmdGive");
}

public cmdGive(id, level, cid) {
        new arg[32], name2[32], name[32]
        read_argv(1, arg, 31)
        new player = cmd_target(id, arg)
       
        if (!player)
                return PLUGIN_HANDLED
       
        get_user_name(player, name2, 31) 
        get_user_name(id, name, 31)

        if (is_user_bot(player)){
                client_print( id, print_chat, "[Frag] Client ^"%s^" is a bot, no acton was taken.", name2)
                return PLUGIN_HANDLED
        }
        if(!is_user_alive(id)){
                client_print( id, print_chat, "[Frag] You cannot give frags while dead !")
                return PLUGIN_HANDLED
        }
        if(get_user_flags(id) > 1){
                set_user_frags(id, get_user_flags(id) - 1)
                set_user_frags(player, get_user_flags(player) + 1)
                client_print( id, print_chat, "[Frag] You gave 1 frag to %s.", name2)
                client_print( player, print_chat, "[Frag] %s gave you 1 frag.", name)
        }
        else
        {
                client_print( id, print_chat, "[Frag] You don't have any frags to give !")
        }       
        return PLUGIN_HANDLED
}

I've no doubt that this code may be badly written. I'm just trying things out. As it completed with no errors and server's console showed nothing I want to figure out what is wrong.

Arkshine 11-06-2009 16:38

Re: Giving a frag, ARGs
 
get_user_flags -> get_user_frags

t3hNox 11-07-2009 06:58

Re: Giving a frag, ARGs
 
Lol. Thanks :D


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

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