Jump to content
GIGN Forum

Palīdziet Pārveidot Pluginu


Recommended Posts

Mēģinu pārtaisīt pluginu, lai šis strādātu adminiem, kuriem ir nevis KICK komanda, bet gan C levels ( o burts ). Sanāk šādi:

#define PLUGIN             "Deathrun Shop"
#define VERSION         "3.0"
#define AUTHOR             "tuty"

#define PICKUP_SND        "items/gunpickup2.wav"
#define ADMIN_ACCESS_CMD    ADMIN_LEVEL_C

Diemžēl kā par spīti, tas plugins iet arī adminiem, kuriem nav C leveļa. Kur vaina?

Link to comment
Share on other sites

#include <fakemeta_util>

#define PLUGIN             "Deathrun Shop"
#define VERSION         "3.0"
#define AUTHOR             "tuty"

#define PICKUP_SND        "items/gunpickup2.wav"
#define ADMIN_ACCESS_CMD    ADMIN_LEVEL_C    

new gDrShopOn, gHeCost, gBothGrenadesCost, gSilentCost, gHealthCost, gArmorCost, gSpeedCost, gGravityCost,
gInvisCost, gMaxPlayers, gSpeedCvar, gGravityCvar, gAdvertiseCvar,
gHealthPointCvar, gArmorPointCvar, gAdvertiseTimeCvar, gInvisPercent, gKillerPointsCvar, gSuiciderPointsCvar;

new HasHe[ 33 ], HasBothGren[ 33 ], HasSilent[ 33 ], HasHealth[ 33 ],
HasArmor[ 33 ], HasSpeed[ 33 ], HasGravity[ 33 ], HasInvis[ 33 ];

new gKillerPoints[ 33 ] = 0;
new bool:bSilent[ 33 ];

const KEYS_M = MENU_KEY_0 | MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_7 | MENU_KEY_8 | MENU_KEY_9;

public plugin_init()
{
    register_plugin( PLUGIN, VERSION, AUTHOR );
    register_cvar( "drshop_version", VERSION, FCVAR_SERVER | FCVAR_SPONLY );

    register_forward( FM_PlayerPreThink, "forward_player_prethink" );
    register_logevent( "logevent_round_start", 2, "1=Round_Start" );
    register_event( "DeathMsg", "Hook_Deathmessage", "a" );

    register_concmd( "amx_deathrun_points", "cmdSetPoints", ADMIN_ACCESS_CMD, "<name> <points> - set points to a player" );
    
    register_clcmd( "say /drshop", "DeathrunShop" );
    register_clcmd( "say_team /drshop", "DeathrunShop" );
    register_clcmd( "say /mypoints", "ShowPoints" );
    register_clcmd( "say_team /mypoints", "ShowPoints" );
    
    register_menucmd( register_menuid( "Deathrun Shop" ), KEYS_M, "menu_shop" );

    gDrShopOn = register_cvar( "deathrun_shop", "1" );
    gHeCost = register_cvar( "deathrun_he_cost", "2" ); // 2 points
    gBothGrenadesCost = register_cvar( "deathrun_bothgrenades_cost", "5" );// 5 points
    gSilentCost = register_cvar( "deathrun_silent_cost", "4" );// 4 points
    gHealthCost = register_cvar( "deathrun_health_cost", "6" );// 6 points
    gArmorCost = register_cvar( "deathrun_armor_cost", "2" );// 2 points
    gSpeedCost = register_cvar( "deathrun_speed_cost", "7" );// 7 points
    gGravityCost = register_cvar( "deathrun_gravity_cost", "5" );// 5 points
    gInvisCost = register_cvar( "deathrun_invisibility_cost", "16" );// 16 points
    gSpeedCvar = register_cvar( "deathrun_speed_power", "400.0" );
    gGravityCvar = register_cvar( "deathrun_gravity_power", "0.5" );
    gAdvertiseCvar = register_cvar( "deathrun_advertise_message", "1" );
    gHealthPointCvar = register_cvar( "deathrun_health_points", "255" );
    gArmorPointCvar = register_cvar( "deathrun_armor_points", "255" );
    gAdvertiseTimeCvar = register_cvar( "deathrun_advertise_time", "7.0" );
    gInvisPercent = register_cvar( "deathrun_invisibility_percentage", "100" );// from 0 to 255
    gKillerPointsCvar = register_cvar( "deathrun_killer_bonuspoints", "5" ); // set here the bonus for killer
    gSuiciderPointsCvar = register_cvar( "deathrun_suicider_loose_points", "3" );
    
    gMaxPlayers = get_maxplayers();
    register_dictionary( "deathrunshop.txt" );
}
public plugin_precache()
{
    precache_sound( PICKUP_SND );
}
public plugin_cfg()
{
    if( get_pcvar_num( gDrShopOn ) != 0 )
    {
        new iCfgDir[ 32 ], iFile[ 192 ];
        get_configsdir( iCfgDir, charsmax( iCfgDir ) );
        formatex( iFile, charsmax( iFile ), "%s/deathrun_shop.cfg", iCfgDir );
        
        if( !file_exists( iFile ) )
        {
            server_print( "*** File %s doesn't exist! ***", iFile );
            server_print( "*** Creating a deafult Configuration file! ***" );
            
            write_file( iFile, "// DeathrunShop Configuration file!" );
            write_file( iFile, "// You can edit the cvars like u want :D" );
            write_file( iFile, " " );
            write_file( iFile, " " );
            write_file( iFile, "// DeathrunShop enabled? Set 0 to disable de plugin" );
            write_file( iFile, "deathrun_shop ^"1^"" );
            write_file( iFile, " " );
            write_file( iFile, "// Cost for single he grenade item" );
            write_file( iFile, "deathrun_he_cost ^"2^"" );
            write_file( iFile, " " );
            write_file( iFile, "// Cost for both grenades. FB+HE" );
            write_file( iFile, "deathrun_bothgrenades_cost ^"5^"" );
            write_file( iFile, " " );
            write_file( iFile, "// Cost for silent-footsteps" );
            write_file( iFile, "deathrun_silent_cost ^"4^"" );
            write_file( iFile, " " );
            write_file( iFile, "// Cost for Health Points item" );
            write_file( iFile, "deathrun_health_cost ^"6^"" );
            write_file( iFile, " " );
            write_file( iFile, "// Cost for Armor Points item" );
            write_file( iFile, "deathrun_armor_cost ^"2^"" );
            write_file( iFile, " " );
            write_file( iFile, "// Cost for Speed item" );
            write_file( iFile, "deathrun_speed_cost ^"7^"" );
            write_file( iFile, " " );
            write_file( iFile, "// Cost for Gravity item" );
            write_file( iFile, "deathrun_gravity_cost ^"5^"" );
            write_file( iFile, " " );
            write_file( iFile, "// Cost for invisibility item. Only terrorist's can have this item!" );
            write_file( iFile, "deathrun_invisibility_cost ^"16^"" );
            write_file( iFile, " " );
            write_file( iFile, "// Set here the speed power. Default 400.0" );
            write_file( iFile, "deathrun_speed_power ^"400.0^"" );
            write_file( iFile, " " );
            write_file( iFile, "// Set here the gravity power. Default is 0.5" );
            write_file( iFile, "deathrun_gravity_power ^"0.5^"" );
            write_file( iFile, " " );
            write_file( iFile, "// Enable / disable the advertise message when a player join the server" );
            write_file( iFile, "// Default is 1" );
            write_file( iFile, "deathrun_advertise_message ^"1^"" );
            write_file( iFile, " " );
            write_file( iFile, "// Set here the Health Points. Default 255" );
            write_file( iFile, "deathrun_health_points ^"255^"" );
            write_file( iFile, " " );
            write_file( iFile, "// Set here the Armor Points. Default 255" );
            write_file( iFile, "deathrun_armor_points ^"255^"" );
            write_file( iFile, " " );
            write_file( iFile, "// Set here the advertise message time. Default is 7.0" );
            write_file( iFile, "deathrun_advertise_time ^"7.0^"" );
            write_file( iFile, " " );
            write_file( iFile, "// Set here the invizibility percentage from 0 to 255. Default: 100" );
            write_file( iFile, "deathrun_invisibility_percentage ^"100^"" );
            write_file( iFile, " " );
            write_file( iFile, "// Set here the bonus points for killer. Default: 5" );
            write_file( iFile, "deathrun_killer_bonuspoints ^"5^"" );
            write_file( iFile, " " );
            write_file( iFile, "// Set here the loosing points for suicider. Default: 3" );
            write_file( iFile, "deathrun_suicider_loose_points ^"3^"" );
            write_file( iFile, " " );
        }
        server_cmd( "exec %s", iFile );
    }
}
public client_connect( id )
{
    HasHe[ id ] = false;
    HasBothGren[ id ] = false;
    HasSilent[ id ] = false;
    HasHealth[ id ] = false;
    HasArmor[ id] = false;
    HasSpeed[ id ] = false;
    HasGravity[ id ] = false;
    HasInvis[ id ] = false;
    gKillerPoints[ id ] = 0;
}
public client_disconnect( id )
{
    bSilent[ id ] = false;
    HasHe[ id ] = false;
    HasBothGren[ id ] = false;
    HasSilent[ id ] = false;
    HasHealth[ id ] = false;
    HasArmor[ id] = false;
    HasSpeed[ id ] = false;
    HasGravity[ id ] = false;
    HasInvis[ id ] = false;
    gKillerPoints[ id ] = 0;
}
public client_putinserver( id )
{
    if( get_pcvar_num( gAdvertiseCvar ) != 0 )
    {
        set_task( get_pcvar_float( gAdvertiseTimeCvar ), "ShowPlayerInfo", id );
    }
}
public forward_player_prethink( id )
{
    if( bSilent[ id ] )
    {
        set_pev( id, pev_flTimeStepSound, 999 );
    }
}
public DeathrunShop( id )
{
    if( get_pcvar_num( gDrShopOn ) != 1 )
    {
        client_print( id, print_chat, "%L", id, "DRSHOP_DISABLED" );
        return PLUGIN_HANDLED;
    }
    if( !is_user_alive( id ) )
    {
        client_print( id, print_chat, "%L", id, "DRSHOP_ONLY_ALIVE" );
        return PLUGIN_HANDLED;
    }
    
    new szBuffer[ 512 ], iLen;
    iLen = formatex( szBuffer, charsmax( szBuffer ), "%L", id, "DRSHOP_MENU_TITLE", VERSION );
    iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "%L", id, "DRSHOP_ITEM_1", get_pcvar_num( gHeCost ) );
    iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "%L", id, "DRSHOP_ITEM_2", get_pcvar_num( gBothGrenadesCost ) );
    iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "%L", id, "DRSHOP_ITEM_3", get_pcvar_num( gSilentCost ) );
    iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "%L", id, "DRSHOP_ITEM_4", get_pcvar_num( gHealthPointCvar ), get_pcvar_num( gHealthCost ) );
    iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "%L", id, "DRSHOP_ITEM_5", get_pcvar_num( gArmorPointCvar ), get_pcvar_num( gArmorCost ) );
    iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "%L", id, "DRSHOP_ITEM_6", get_pcvar_num( gSpeedCost ) );
    iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "%L", id, "DRSHOP_ITEM_7", get_pcvar_num( gGravityCost ) );
    iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "%L", id, "DRSHOP_ITEM_8", get_pcvar_num( gInvisPercent ), get_pcvar_num( gInvisCost ) );
    iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "%L", id, "DRSHOP_MENU_EXIT" );
    show_menu( id, KEYS_M, szBuffer );
    
    return PLUGIN_CONTINUE;
}
public menu_shop( id, key )
{
    new points = gKillerPoints[ id ];
    
    switch( key )
    {
        case 0:
        {
            if( HasHe[ id ] )
            {
                allready_have( id );
                return PLUGIN_HANDLED;
            }
            if( points < get_pcvar_num( gHeCost ) )
            {
                dont_have( id );
                return PLUGIN_HANDLED;
            }
            fm_give_item( id, "weapon_hegrenade" );
            client_print( id, print_chat, "%L", id, "DRSHOP_GRENADE_ITEM" );
            HasHe[ id ] = true;
            gKillerPoints[ id ] -= get_pcvar_num( gHeCost );
        }
        case 1:
        {
            if( HasBothGren[ id ] )
            {
                allready_have( id );
                return PLUGIN_HANDLED;
            }
            if( points < get_pcvar_num( gBothGrenadesCost ) )
            {
                dont_have( id );
                return PLUGIN_HANDLED;
            }    
            fm_give_item( id, "weapon_hegrenade" );
            fm_give_item( id, "weapon_flashbang" );
            fm_give_item( id, "weapon_flashbang" );
            client_print( id, print_chat, "%L", id, "DRSHOP_BOTHGREN_ITEM" );
            HasBothGren[ id ] = true;
            gKillerPoints[ id ] -= get_pcvar_num( gBothGrenadesCost );
        }
        case 2:
        {
            if( HasSilent[ id ] )
            {
                allready_have( id );
                return PLUGIN_HANDLED;
            }
            if( points < get_pcvar_num( gSilentCost ) )
            {
                dont_have( id );
                return PLUGIN_HANDLED;
            }    
            fm_set_user_footsteps( id, 1 );
            client_print( id, print_chat, "%L", id, "DRSHOP_SILENTWALK_ITEM" );
            client_sound_play( id );
            HasSilent[ id ] = true;
            gKillerPoints[ id ] -= get_pcvar_num( gSilentCost );
        }
        case 3:
        {
            if( HasHealth[ id ] )
            {
                allready_have( id );
                return PLUGIN_HANDLED;
            }
            if( points < get_pcvar_num( gHealthCost ) )
            {
                dont_have( id );
                return PLUGIN_HANDLED;
            }    
            fm_set_user_health( id, get_user_health( id ) + get_pcvar_num( gHealthPointCvar ) );
            client_print( id, print_chat, "%L", id, "DRSHOP_HEALTH_ITEM", get_pcvar_num( gHealthPointCvar ) );
            client_sound_play( id );
            HasHealth[ id ] = true;
            gKillerPoints[ id ] -= get_pcvar_num( gHealthCost );
        }
        case 4:
        {
            if( HasArmor[ id ] )
            {
                allready_have( id );
                return PLUGIN_HANDLED;
            }
            if( points < get_pcvar_num( gArmorCost ) )
            {
                dont_have( id );
                return PLUGIN_HANDLED;
            }
            fm_set_user_armor( id, get_user_armor( id ) + get_pcvar_num( gArmorPointCvar ) );
            client_print( id, print_chat, "%L", id, "DRSHOP_ARMOR_ITEM", get_pcvar_num( gArmorPointCvar ) );
            client_sound_play( id );
            HasArmor[ id ] = true;
            gKillerPoints[ id ] -= get_pcvar_num( gArmorCost );
        }
        case 5:
        {
            if( HasSpeed[ id ] )
            {
                allready_have( id );
                return PLUGIN_HANDLED;
            }
            if( points < get_pcvar_num( gSpeedCost ) )
            {
                dont_have( id );
                return PLUGIN_HANDLED;
            }
            fm_set_user_maxspeed( id, get_pcvar_float( gSpeedCvar ) );
            client_print( id, print_chat, "%L", id, "DRSHOP_SPEED_ITEM" );
            client_sound_play( id );
            HasSpeed[ id ] = true;
            gKillerPoints[ id ] -= get_pcvar_num( gSpeedCost );
        }
        case 6:
        {
            if( HasGravity[ id ] )
            {
                allready_have( id );
                return PLUGIN_HANDLED;
            }
            if( points < get_pcvar_num( gGravityCost ) )
            {
                dont_have( id );
                return PLUGIN_HANDLED;
            }
            fm_set_user_gravity( id, get_pcvar_float( gGravityCvar ) );
            client_print( id, print_chat, "%L", id, "DRSHOP_GRAVITY_ITEM" );
            client_sound_play( id );
            HasGravity[ id ] = true;
            gKillerPoints[ id ] -= get_pcvar_num( gGravityCost );
        }
        case 7:
        {
            if( HasInvis[ id ] )
            {
                allready_have( id );
                return PLUGIN_HANDLED;
            }
            if( get_user_team( id ) == 2 )
            {
                client_print( id, print_chat, "%L", id, "DRSHOP_ONLY_T" );
                return PLUGIN_HANDLED;
            }
            if( points < get_pcvar_num( gInvisCost ) )
            {
                dont_have( id );
                return PLUGIN_HANDLED;
            }
            fm_set_rendering( id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 100 );
            client_print( id, print_chat, "%L", id, "DRSHOP_INVISIBILITY_ITEM" );
            client_sound_play( id );
            HasInvis[ id ] = true;
            gKillerPoints[ id ] -= get_pcvar_num( gInvisCost );
        }
        case 8:
        {
            client_print( id, print_chat, "%L", id, "DRSHOP_MENU_CLOSED" );
            return PLUGIN_HANDLED;
        }
            
    }
    return PLUGIN_HANDLED;
}
public cmdSetPoints( id, level, cid )
{
    if( !cmd_access( id, level, cid, 2 ) || !get_pcvar_num( gDrShopOn ) )
    {
        return PLUGIN_HANDLED; 
    }
    
    new argument[ 32 ];
       read_argv( 1, argument, charsmax( argument ) );
    new player = cmd_target( id, argument, 6 );

    if( !player ) 
    {
           return PLUGIN_HANDLED;
    }
    
    new give_points[ 5 ];
    read_argv( 2, give_points, charsmax( give_points ) );
    
    new gift = str_to_num( give_points );
    
    gKillerPoints[ player ] = gift;
    
    return PLUGIN_HANDLED;
}    
public ShowPoints( id )
{
    set_hudmessage( 255, 42, 212, 0.03, 0.86, 2, 6.0, 5.0 );
    show_hudmessage( id, "%L", id, "DRSHOP_POINTS_INFO", gKillerPoints[ id ] );
    
    return PLUGIN_CONTINUE;
}
public ShowPlayerInfo( id )
{
    set_hudmessage( 0, 0, 255, -1.0, 0.82, 0, 6.0, 12.0 );
    show_hudmessage( id, "%L", id, "DRSHOP_HUD_INFO" );
}    
public logevent_round_start()
{
    if( get_pcvar_num( gDrShopOn ) == 1 )
    {
        for( new id = 1; id <= gMaxPlayers; id++ )
        {
            HasHe[ id ] = false;
            HasBothGren[ id ] = false;
            HasSilent[ id ] = false;
            HasHealth[ id ] = false;
            HasArmor[ id] = false;
            HasSpeed[ id ] = false;
            HasGravity[ id ] = false;
            HasInvis[ id ] = false;
            fm_set_user_gravity( id, 1.0 );    
            fm_set_user_maxspeed( id, 0.0 );
            fm_set_user_footsteps( id, 0 );
        }
    }
    return PLUGIN_CONTINUE;
}
public Hook_Deathmessage()
{
    if( get_pcvar_num( gDrShopOn ) == 1 )
    {
        new killer = read_data( 1 );
        new victim = read_data( 2 );

        if( killer == victim )
        {
            gKillerPoints[ victim ] -= get_pcvar_num( gSuiciderPointsCvar );
            return PLUGIN_HANDLED;
        }
        
        gKillerPoints[ killer ] += get_pcvar_num( gKillerPointsCvar );
    
        HasHe[ victim ] = false;
        HasBothGren[ victim ] = false;
        HasSilent[ victim ] = false;
        HasHealth[ victim ] = false;
        HasArmor[ victim ] = false;
        HasSpeed[ victim ] = false;
        HasGravity[ victim ] = false;
        HasInvis[ victim ] = false;
        
        fm_set_user_rendering( victim );
        fm_set_user_gravity( victim, 1.0 );    
        fm_set_user_maxspeed( victim, 0.0 );
        fm_set_user_footsteps( victim, 0 );
    }
    return PLUGIN_CONTINUE;
}    
stock allready_have( id)
{
    client_print( id, print_chat, "%L", id, "DRSHOP_ALLREADY_HAVE" );
}    
stock dont_have( id )
{
    client_print( id, print_chat, "%L", id, "DRSHOP_DONTHAVE_POINTS" );
}
stock client_sound_play( index )
{
    client_cmd( index, "speak %s", PICKUP_SND );
}    
stock fm_set_user_footsteps( index, set = 1 )
{
    if( set )
    {
        set_pev( index, pev_flTimeStepSound, 999 );
        bSilent[ index ] = true;
    }
    else
    {
        set_pev( index, pev_flTimeStepSound, 400 );
        bSilent[ index ] = false;
    }
    return 1;
}

Par manu aksesa likšanas prasmi vari nesatraukties :)

Link to comment
Share on other sites

Tava problēma:

Diemžēl kā par spīti, tas plugins iet arī adminiem, kuriem nav C leveļa. Kur vaina?

/drshop komanda ies visiem, jo admin only ir tikai give points komanda.

Ja nu tomēr tu esi to sapratis.. Tad visticamāk esi editējis source uz 'o' flagu, bet aizmirsis sakompilēt, vai arī sakompilēji ar citu nosaukumu utt.

Edited by shine
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...