Dupa ce mori sa nu mai beneficiezi de nici un beneficiu din shop , doar daca vei cumpara din nou.
1.Gravity 420 [15 P]
2.Speed 400 [30 P]
3.HP 50+ [50 P]
4.Dmg x2 [100 P]
5.Echipament adversar [200 P]
Code: Select all
#include < amxmodx >
#include < hamsandwich >
#include < fakemeta >
#include < fun >
#include < ColorChat >
#include < message_const >
new const PLUGIN_NAME[ ] = "Points System - SHOP",
PLUGIN_VERSION[ ] = "1.0",
PLUGIN_AUTHOR[ ] = "CsG";
#define is_user_player(%1) ( 1 <= %1 <= 32 )
#define MAX_ITEMS 5
native set_user_points( id, amount );
native get_user_points( id );
new const g_szTag[ ] = "[CsG-Shop]^x01";
new const NameShop[ ] = "PAINT.CSGAMERS.RO";
new Ham:Ham_Player_ResetMaxSpeed = Ham_Item_PreFrame;
new bool:Dmg[ 33 ];
new bool:Health[ 33 ];
new bool:Gravity[ 33 ];
new bool:Speed[ 33 ];
new bool:NoFlash[ 33 ];
new gCvarCostHealth,
gCvarHealth,
gCvarMaxHealth,
gCvarCostMultiDmg,
gCvarCostGravity,
gCvarGravity,
gCvarCostSpeed,
gCvarSpeed,
gCvarCostNoFlash;
public plugin_init( ) {
register_plugin( PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR );
register_clcmd( "say /shop", "OpenMenu" );
register_clcmd( "say_team /shop", "OpenMenu" );
register_event( "CurWeapon", "event_CurWeapon", "be", "1=1" );
register_event( "DeathMsg", "event_DeathMsg", "a" );
RegisterHam( Ham_Player_ResetMaxSpeed, "player", "Ham_ResetMaxSpeedPost", 1 );
RegisterHam( Ham_TakeDamage, "player", "Ham_TakeDamagePre" );
register_message( get_user_msgid( "ScreenFade" ), "MessageScreenFade" );
gCvarCostHealth = register_cvar( "shop_cost_hp", "40" );
gCvarHealth = register_cvar( "shop_hp", "50" );
gCvarMaxHealth = register_cvar( "shop_max_hp", "250" );
gCvarCostMultiDmg = register_cvar( "shop_cost_multidmg", "100" );
gCvarCostGravity = register_cvar( "shop_cost_gravity", "15" );
gCvarGravity = register_cvar( "shop_gravity", "450.0" );
gCvarCostSpeed = register_cvar( "shop_cost_speed", "30" );
gCvarSpeed = register_cvar( "shop_speed", "600.0" );
gCvarCostNoFlash = register_cvar( "shop_cost_noflash", "50" );
}
public plugin_cfg( )
set_cvar_float( "sv_maxspeed", 1000.0 );
public client_disconnect( id ) {
Dmg[ id ] = false;
Gravity[ id ] = false;
Speed[ id ] = false;
NoFlash[ id ] = false;
}
public client_putinserver( id ) {
Dmg[ id ] = false;
Gravity[ id ] = false;
Speed[ id ] = false;
NoFlash[ id ] = false;
}
public event_CurWeapon( id ) {
if( !is_user_alive( id ) || is_user_bot( id ) )
return 1;
if( Health[ id ] ) {
set_user_health( id, get_user_health( id ) + get_pcvar_num( gCvarHealth ) );
} else {
return 1;
}
if( Gravity[ id ] ) {
set_user_gravity( id, get_pcvar_num( gCvarGravity ) / 0.00125 );
} else {
return 1;
}
return 0;
}
public event_DeathMsg( ) {
if( read_data( 1 ) == read_data( 2 ) || !is_user_alive( read_data( 1 ) ) )
return 1;
Dmg[ read_data( 2 ) ] = false;
Gravity[ read_data( 2 ) ] = false;
Speed[ read_data( 2 ) ] = false;
NoFlash[ read_data( 2 ) ] = false;
return 0;
}
public Ham_ResetMaxSpeedPost( id ) {
if( is_user_alive( id ) && get_user_maxspeed( id ) != 1.0 ) {
new Float:flMaxSpeed;
if( Speed[ id ] ) {
flMaxSpeed = float( get_pcvar_num( gCvarSpeed ) );
}
if( flMaxSpeed > 0.0 ) {
set_pev( id, pev_maxspeed, flMaxSpeed );
}
}
}
public Ham_TakeDamagePre( iVictim, iInflictor, iAttacker, Float:fDamage ) {
if( iVictim == iAttacker || !is_user_player( iAttacker ) || !is_user_alive( iAttacker ) )
return HAM_HANDLED;
if( Dmg[ iAttacker ] && is_user_player( iAttacker ) ) {
SetHamParamFloat( 4, fDamage * 2.0 );
return HAM_HANDLED;
}
return HAM_IGNORED;
}
public MessageScreenFade( iMsgId, iMsgDest, id ) {
if( is_user_alive( id ) && NoFlash[ id ] ) {
static szData[ 4 ];
szData[ 0 ] = get_msg_arg_int( 4 );
szData[ 1 ] = get_msg_arg_int( 5 );
szData[ 2 ] = get_msg_arg_int( 6 );
szData[ 3 ] = get_msg_arg_int( 7 );
if( szData[ 0 ] == 255 && szData[ 1 ] == 255 && szData[ 2 ] == 255 && szData[ 3] > 199 )
return 1;
}
return 0;
}
public OpenMenu( id ) {
if( !is_user_connected( id ) || is_user_bot( id ) )
return 1;
if( !is_user_alive( id ) ) {
ColorChat( id, GREEN, "%s^x01 Trebuie sa fii in viata ca sa poti accesa^x03 shop-ul^x01 !!!", g_szTag );
return 1;
} else if( get_user_team( id ) == 3 ) {
ColorChat( id, GREEN, "%s^x01 Nu poti accesa shop-ul cat timp esti spectator !!!", g_szTag );
return 1;
} else {
ShowShopMenu( id );
}
return 1;
}
public ShowShopMenu( id ) {
new szMenuName[ 64 ];
formatex( szMenuName, sizeof( szMenuName ) - 1, "\w%s \rv1.0^n\yYour Points:\r %i\w", NameShop, get_user_points( id ) );
new iMenu = menu_create( szMenuName, "MenuHandler" );
new szBuffer[ MAX_ITEMS ][ 64 ];
new szBufferKey[ MAX_ITEMS - 1 ];
new iBufferKey = 1;
if( Gravity[ id ] )
formatex( szBuffer[ 0 ], sizeof( szBuffer[ ] ) - 1, "\d%i Gravity\r [\w%i $\r]", get_pcvar_num( gCvarGravity ), get_pcvar_num( gCvarCostGravity ) );
else
formatex( szBuffer[ 0 ], sizeof( szBuffer[ ] ) - 1, "\y%i Gravity\r [\w%i $\r]", get_pcvar_num( gCvarGravity ), get_pcvar_num( gCvarCostGravity ) );
if( Speed[ id ] )
formatex( szBuffer[ 1 ], sizeof( szBuffer[ ] ) - 1, "\d%i Speed\r [\w%i $\r]", get_pcvar_num( gCvarSpeed ), get_pcvar_num( gCvarCostSpeed ) );
else
formatex( szBuffer[ 1 ], sizeof( szBuffer[ ] ) - 1, "\y%i Speed\r [\w%i $\r]", get_pcvar_num( gCvarSpeed ), get_pcvar_num( gCvarCostSpeed ) );
if( get_user_health( id ) >= get_pcvar_num( gCvarMaxHealth ) )
formatex( szBuffer[ 2 ], sizeof( szBuffer[ ] ) - 1, "\d%i HP\r [\w%i $\r]", get_pcvar_num( gCvarHealth ), get_pcvar_num( gCvarCostHealth ) );
else
formatex( szBuffer[ 2 ], sizeof( szBuffer[ ] ) - 1, "\y%i HP\r [\w%i $\r]", get_pcvar_num( gCvarHealth ), get_pcvar_num( gCvarCostHealth ) );
if( NoFlash[ id ] )
formatex( szBuffer[ 3 ], sizeof( szBuffer[ ] ) - 1, "\dNo Flash\r [\w%i $\r]", get_pcvar_num( gCvarCostNoFlash ) );
else
formatex( szBuffer[ 3 ], sizeof( szBuffer[ ] ) - 1, "\yNo Flash\r [\w%i $\r]", get_pcvar_num( gCvarCostNoFlash ) );
if( Dmg[ id ] )
formatex( szBuffer[ 4 ], sizeof( szBuffer[ ] ) - 1, "\dx2 Dmg\r [\w%i $\r]", get_pcvar_num( gCvarCostMultiDmg ) );
else
formatex( szBuffer[ 4 ], sizeof( szBuffer[ ] ) - 1, "\yx2 Dmg\r [\w%i $\r]", get_pcvar_num( gCvarCostMultiDmg ) );
for( new i = 0; i < MAX_ITEMS; i++ ) {
formatex( szBufferKey, sizeof( szBufferKey ) -1, "%i", iBufferKey );
menu_additem( iMenu, szBuffer[ i ], szBufferKey, 0 );
iBufferKey++;
}
menu_setprop( iMenu, MPROP_EXITNAME, "\wIesire" );
menu_display( id, iMenu, 0 );
return 1;
}
public MenuHandler( id, szMenu, szItem ) {
if( szItem == MENU_EXIT ) {
menu_destroy( szMenu );
return PLUGIN_HANDLED;
}
new szData[ 6 ], szName[ 64 ];
new iAccess, iCallBack;
menu_item_getinfo( szMenu, szItem, iAccess, szData, charsmax( szData ), szName, charsmax( szName ), iCallBack );
new iKey = str_to_num( szData );
switch( iKey ) {
case 1: {
new CostGravity = get_pcvar_num( gCvarCostGravity );
new Points = get_user_points( id ) - CostGravity;
if( Points < 0 ) {
ColorChat( id, GREEN, "%s Mai ai nevoie de^x03 %i^x01 puncte pentru a cumpara gravitate!", g_szTag, CostGravity - get_user_points( id ) );
set_task( 0.3, "ShowShopMenu", id );
return 1;
} else if( Gravity[ id ] ) {
ColorChat( id, GREEN, "%s Ai deja acest item!", g_szTag );
set_task( 0.3, "ShowShopMenu", id );
return 1;
} else {
Gravity[ id ] = true;
ColorChat( id, GREEN, "%s Tocmai ti-ai crescut^x03 gravitatea^x01.", g_szTag );
set_user_points( id, Points );
return 1;
}
}
case 2: {
new CostSpeed = get_pcvar_num( gCvarCostSpeed );
new Points = get_user_points( id ) - CostSpeed;
if( Points < 0 ) {
ColorChat( id, GREEN, "%s Mai ai nevoie de^x03 %i^x01 puncte pentru a cumpara viteza!", g_szTag, CostSpeed - get_user_points( id ) );
set_task( 0.3, "ShowShopMenu", id );
return 1;
} else if( Speed[ id ] ) {
ColorChat( id, GREEN, "%s Ai deja acest item!", g_szTag );
set_task( 0.3, "ShowShopMenu", id );
return 1;
} else {
Speed[ id ] = true;
set_user_maxspeed( id, get_pcvar_float( gCvarSpeed ) );
ColorChat( id, GREEN, "%s Ai devenit mai rapid cu^x03 %0.1f^x01 unitati.", g_szTag, get_pcvar_float( gCvarSpeed ) - get_user_maxspeed( id ) );
set_user_points( id, Points );
return 1;
}
}
case 3: {
new CostHealth = get_pcvar_num( gCvarCostHealth );
new Points = get_user_points( id ) - CostHealth;
if( Points < 0 ) {
ColorChat( id, GREEN, "%s Mai ai nevoie de^x03 %i^x01 puncte pentru a cumpara viata in plus!", g_szTag, CostHealth - get_user_points( id ) );
set_task( 0.3, "ShowShopMenu", id );
return 1;
} else if( get_user_health( id ) >= get_pcvar_num( gCvarMaxHealth ) ) {
ColorChat( id, GREEN, "%s Ai ajuns la numarul maxim de viata(^x04%i^x01).", g_szTag, get_pcvar_num( gCvarMaxHealth ) );
set_task( 0.3, "ShowShopMenu", id );
return 1;
} else {
Health[ id ] = true;
ColorChat( id, GREEN, "%s Viata ta este acum cu^x03 %i^x01 mai mare.", g_szTag, Health );
set_user_points( id, Points );
return 1;
}
}
case 4: {
new CostNoFlash = get_pcvar_num( gCvarCostNoFlash );
new Points = get_user_points( id ) - CostNoFlash;
if( Points < 0 ) {
ColorChat( id, GREEN, "%s Mai ai nevoie de^x03 %i^x01 puncte pentru a cumpara no flash !", g_szTag, CostNoFlash - get_user_points( id ) );
set_task( 0.3, "ShowShopMenu", id );
return 1;
} else if( NoFlash[ id ] ) {
ColorChat( id, GREEN, "%s Ai deja acest item!", g_szTag );
set_task( 0.3, "ShowShopMenu", id );
return 1;
} else {
NoFlash[ id ] = true;
ColorChat( id, GREEN, "%s Ai devenit imun la flashbang-uri^x01.", g_szTag );
set_user_points( id, Points );
return 1;
}
}
case 5: {
new CostMultiDmg = get_pcvar_num( gCvarCostMultiDmg );
new Points = get_user_points( id ) - CostMultiDmg;
if( Points < 0 ) {
ColorChat( id, GREEN, "%s Mai ai nevoie de^x03 %i^x01 puncte pentru a cumpara dublu dmg!", g_szTag, CostMultiDmg - get_user_points( id ) );
set_task( 0.3, "ShowShopMenu", id );
return 1;
} else if( Dmg[ id ] ) {
ColorChat( id, GREEN, "%s Ai deja acest item!", g_szTag );
set_task( 0.3, "ShowShopMenu", id );
return 1;
} else {
Dmg[ id ] = true;
ColorChat( id, GREEN, "%s Acum dmg-ul tau este mai mare cu 20%^x01.", g_szTag );
set_user_points( id, Points );
return 1;
}
}
}
menu_destroy( szMenu );
return PLUGIN_HANDLED;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/