Русское сообщество по скриптингу

[Help] Custom command

Scripting help for english speaking users. While not very active, you still have a chance to get help here.
Правила форума
We cannot maintain english version version of our forum rules, but shortly (it's simple) - Don't be a dick. If you really want to know our rules you should check appropriate thread.

[Help] Custom command

Сообщение VenomIvanof » 29 апр 2016, 23:30

Hi all, can somebody make this? When someone say /marvel to use only 1 time per map?

Код: Выделить всё
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <fakemeta_util>
#include <hamsandwich>
#include <cstrike>
#include <fun>
#include <colorchat>

#define PLUGIN "Marvel stuff"
#define VERSION "1.0"
#define AUTHOR "Skumek"

//A little config 
#define COST 100
#define FLASH_SPEED 310.0
#define DAMAGE_HULK 2.0
#define CATWOMAN_ARMOR 160
#define CATWOMAN_HP 160
#define IRONMAN_ARMOR 200
#define IRONMAN_HP 200
#define HP_RESTORE_ARMOUNT 1
#define AMOUNT_INVISIBLE 16

//Macros
#define Get_BitVar(%1,%2)        (%1 & (1 << (%2 & 31)))
#define Set_BitVar(%1,%2)        (%1 |= (1 << (%2 & 31)));
#define UnSet_BitVar(%1,%2)        (%1 &= ~(1 << (%2 & 31)));

#define MAX_NAME 7

new const g_Names[MAX_NAME][] = {
    "The Hulk",
    "Cat Woman",
    "Iron Man",
    "Dracula",
    "Invisible Woman",
    "Wolverine",
    "Flash"
}

//Classes
new g_Hulk, g_CatWoman, g_IronMan, g_Vampire, g_Invisible, g_Wolverine, g_Flash

//Get 'em
new g_MaxPlayers 

//Some stuffs
new g_MaxHealth[33]

public plugin_init() {
    register_plugin( PLUGIN, VERSION, AUTHOR )
     
    //Ham
    RegisterHam(Ham_Spawn, "player", "fw_Spawn", 1)
    RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
     
    //Event
    register_event("CurWeapon", "Event_CurWeapon", "be", "1=1")
    register_event( "TextMsg", "Event_RoundRestart", "a", "2&#Game_C", "2&#Game_w" )
    register_event("DeathMsg", "DeathMessage", "a")
     
    //Get em
    g_MaxPlayers = get_maxplayers()
     
    //Cmd
    register_clcmd( "say /marvel", "Open_SkinMenu" )
    register_clcmd( "sayteam /marvel", "Open_SkinMenu" )
}

public client_connect( id ) ResetAll( id )
public client_disconnect( id ) ResetAll( id )
public Event_RoundRestart( id ) ResetAll( id )

public Event_CurWeapon( id )
{
    if( is_user_alive( id ))
    {
        if( Get_BitVar(g_Flash, id )) set_user_maxspeed( id, FLASH_SPEED) 
        else if( Get_BitVar(g_Wolverine, id )) set_task(1.0, "Regen_Health", 2152, _, _, "b")
            else if( Get_BitVar(g_Invisible, id )) fm_set_user_rendering( id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, AMOUNT_INVISIBLE )         
        }
}

public fw_TakeDamage(Victim, Attacker, Float: Damage, DamageType)
{     
    if(!is_user_alive(Attacker))
        return HAM_IGNORED;
     
    if(Get_BitVar(g_Hulk, Attacker))
    {     
        SetHamParamFloat(4, Damage * DAMAGE_HULK)
        return HAM_HANDLED;
    }
    return HAM_IGNORED;
}

public fw_Spawn( id )
{
    if(!is_user_alive(id))
        return 
     
    new CsArmorType:ArmorType 
     
    g_MaxHealth[id] = get_user_health(id)
     
    if(Get_BitVar(g_IronMan, id ))
    {
        cs_set_user_armor( id, IRONMAN_ARMOR, ArmorType )
        set_user_health(id, IRONMAN_HP )
    }
    else if(Get_BitVar(g_CatWoman, id ))
    {
        cs_set_user_armor( id, CATWOMAN_ARMOR, ArmorType )
        set_user_health( id, CATWOMAN_HP )
    }
     
}

public Open_SkinMenu( id )
{
    if(!is_user_alive( id ))
        return PLUGIN_CONTINUE
     
    static  Title[ 64 ]
     
    formatex( Title, charsmax( Title ), "Class Selection^n" )
     
    static iMenu; iMenu = menu_create( Title, "MenuHandle_SkinMenu" )
     
    new Num, NumStr[ 3 ]
     
    for( new i = 0; i < MAX_NAME; i++ )
    {     
        Num = i
        num_to_str( Num, NumStr, charsmax( NumStr ) )
        menu_additem( iMenu, g_Names[ Num ], NumStr, 0 )
    }
     
    menu_setprop( iMenu, MPROP_EXIT, MEXIT_ALL )
    menu_display( id, iMenu )
     
    return PLUGIN_HANDLED
}

public MenuHandle_SkinMenu( id, iMenu, iItem )
{
    if( iItem == MENU_EXIT )
        return PLUGIN_CONTINUE
    if( !is_user_connected( id ) )
        return PLUGIN_CONTINUE
    if(cs_get_user_money(id) < 100)
        {
        ColorChat(id, GREY, "^4Sorry, you dont have enough money")
        return PLUGIN_CONTINUE
    }
         
    new _Trash, Key[ 3 ]
    menu_item_getinfo( iMenu, iItem, _Trash, Key, charsmax( Key ), "", 0, _Trash )
     
    new KeyItem = str_to_num( Key ) 
     
    if( is_user_alive( id ) )
    {
        switch( KeyItem )
        {
            case 0: Set_BitVar( g_Hulk, id )
                case 1: Set_BitVar( g_CatWoman, id )
                case 2: Set_BitVar( g_IronMan, id)
                case 3: Set_BitVar( g_Vampire, id )
                case 4: Set_BitVar( g_Invisible, id )
                case 5: Set_BitVar( g_Wolverine, id )
                case 6: Set_BitVar( g_Flash, id )
                default: ResetAll(id)
             
        }
        cs_set_user_money(id, (cs_get_user_money(id) - COST))
        ColorChat( id, GREY, "^3You have chosen Class: ^4[%s]",  g_Names[ KeyItem ] )
    }
    menu_destroy( iMenu );
    return PLUGIN_HANDLED;
}

public Regen_Health()
{
    static id, hp
     
    for(id=1; id<=g_MaxPlayers; id++){
        if(!is_user_alive(id))
            continue
         
        hp = get_user_health(id)
        if(hp >= g_MaxHealth[id])
            g_MaxHealth[id] = hp
        else
            set_user_health(id, hp+HP_RESTORE_ARMOUNT)
    }
}   
public DeathMessage()
{
    new killer = read_data(1);
    new victim = read_data(2);
     
    if(Get_BitVar(g_Vampire, killer))
    {     
        if(is_user_alive(killer) && get_user_team(killer) != get_user_team(victim))
        {
            DeathMsg(killer,victim,read_data(3));
        }
    }
}

public DeathMsg(kid, vid, hs)
    set_user_health(kid, min(get_user_health(kid)+(hs?30:15),255));

public ResetAll( id )
{
    UnSet_BitVar(g_Hulk, id)
    UnSet_BitVar(g_CatWoman, id)
    UnSet_BitVar(g_Flash, id)
    UnSet_BitVar(g_Invisible, id)
    UnSet_BitVar(g_IronMan, id)
    UnSet_BitVar(g_CatWoman, id)
    UnSet_BitVar(g_Wolverine, id)
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1042\\ f0\\ fs16 \n\\ par }
*/ 
Аватара пользователя
VenomIvanof
 
Сообщения: 66
Зарегистрирован: 02 апр 2016, 13:26
Благодарил (а): 17 раз.
Поблагодарили: 1 раз.
Языки программирования: Counter-Strike 1.6

Re: [Help] Custom command

Сообщение Pafos » 30 апр 2016, 10:19

When someone say /marvel to use only 1 time per map

Код: Выделить всё
#include <amxmodx>

#define MAX_PLAYERS 32

new const g_szMessageUsed[] = "You have already used";

new Trie:tOne , g_szAuthid[MAX_PLAYERS+1][28];

public plugin_init()
{
    register_plugin("once for the map" , "1.0" , "pafos");
    
    register_clcmd
("say /once" , "CmdOnce");
    
    tOne 
= TrieCreate();
}
public plugin_end()
{
    TrieDestroy(tOne);
}
public client_putinserver(nClientIndex)
{
    get_user_authid(nClientIndex , g_szAuthid[nClientIndex] , charsmax(g_szAuthid[]));
}
public CmdOnce(nClientIndex)
{
    if(is_user_connected(nClientIndex))
    {
        if(TrieKeyExists(tOne , g_szAuthid[nClientIndex]))
        {
            client_print(nClientIndex , print_chat , g_szMessageUsed);
            return PLUGIN_HANDLED;
        }
        
        
// code ...
        
        TrieSetString
(tOne , g_szAuthid[nClientIndex] , "0");
    }
    return PLUGIN_HANDLED;
}
Аватара пользователя
Pafos
 
Сообщения: 574
Зарегистрирован: 07 апр 2014, 18:03
Откуда: pfnClientConnect
Забанен
Благодарил (а): 129 раз.
Поблагодарили: 97 раз.
Опыт программирования: Больше трех лет
Языки программирования: Pawn


Вернуться в Scripting

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 3