I have a bug in DeathRun Shop plugin. Can anyone fix it?
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <hamsandwich>
#include <fakemeta>
/* --| Let's force the semicolon on every endline */
#pragma semicolon 1
/* --| Some defines :) */
#define PICKUP_SND "items/gunpickup2.wav"
#define HEALTH_SOUND "items/smallmedkit1.wav"
#define ARMOR_SOUND "items/ammopickup2.wav"
#define CLOACK_SOUND "hornet/ag_buzz1.wav"
#define LJ_SOUND "fvox/powermove_on.wav"
#define ADMIN_ACCESS_CMD ADMIN_KICK
#define OFFSET_MONEY 115
/* --| Plugin informations */
new const PLUGIN[] = "Deathrun Shop";
new const VERSION[] = "Ninja Edition";
new const AUTHOR[] = "tuty/other";
/* --| Zomg lot of globals :) */
new gDrShopOn;
new gHeCost;
new gBothGrenadesCost;
new gSilentCost;
new gHealthCost;
new gArmorCost;
new gSpeedCost;
new gGravityCost;
new gInvisCost;
new gSpeedCvar;
new gGravityCvar;
new gAdvertiseCvar;
new gHealthPointCvar;
new gArmorPointCvar;
new gAdvertiseTimeCvar;
new gInvisPercent;
new gDeagleCost;
new gMsgItemPickup;
new gLongJumpTime;
new gLongJumpCost;
new gMsgMoney;
new g_ADSpr;
new gEffectType;
/* --| Item variables */
new HasHe[ 33 ];
new HasBothGren[ 33 ];
new HasSilent[ 33 ];
new HasHealth[ 33 ];
new HasArmor[ 33 ];
new HasSpeed[ 33 ];
new HasGravity[ 33 ];
new HasInvis[ 33 ];
new HasDeagle[ 33 ];
new HasLongJump[ 33 ];
new gName[ 32 char ];
new g_b_Invisible[ 33 ];
/* --| So, let's get started */
public plugin_init()
{
/* --| Registering the plugin to show when you type amx_plugins.. */
register_plugin( PLUGIN, VERSION, AUTHOR );
/* --| Registering a little cvar to see wich servers using this plugin */
register_cvar( "drshop_version", VERSION, FCVAR_SERVER | FCVAR_SPONLY );
/* --| Register some usefull events */
register_logevent( "logevent_round_start", 2, "1=Round_Start" );
register_event( "DeathMsg", "Hook_Deathmessage", "a" );
register_event( "CurWeapon", "HookCurWeapon", "be", "1=1" );
/* --| Command for setting money to player/@all */
register_concmd( "deathrun_set_money", "cmdSetMoney", ADMIN_ACCESS_CMD, "<name/@all> <money> - set money to a player" );
/* --| Command for reseting money to palyer/@all */
register_concmd( "deathrun_reset_money", "cmdResetMoney", ADMIN_ACCESS_CMD, "<name/@all> - reset player money" );
/* --| Command for opening the menu */
register_clcmd( "say /drshop", "DeathrunShop" );
register_clcmd( "say_team /drshop", "DeathrunShop" );
register_clcmd( "/shop", "DeathrunShop" );
/* --| Command to see our points :) */
register_clcmd( "say /money", "ShowPoints" );
register_clcmd( "say_team /money", "ShowPoints" );
register_clcmd( "/money", "ShowPoints" );
/* --| Let's register the cvars, a lot of cvars but huh.. stf :) */
gDrShopOn = register_cvar( "deathrun_shop", "1" );
gHeCost = register_cvar( "deathrun_he_cost", "3000" );
gBothGrenadesCost = register_cvar( "deathrun_bothgrenades_cost", "4000" );
gSilentCost = register_cvar( "deathrun_silent_cost", "4000" );
gHealthCost = register_cvar( "deathrun_health_cost", "4000" );
gArmorCost = register_cvar( "deathrun_armor_cost", "4000" );
gSpeedCost = register_cvar( "deathrun_speed_cost", "8000" );
gGravityCost = register_cvar( "deathrun_gravity_cost", "8000" );
gInvisCost = register_cvar( "deathrun_invisibility_cost", "16000" );
gSpeedCvar = register_cvar( "deathrun_speed_power", "400.0" );
gDeagleCost = register_cvar( "deathrun_deagle_cost", "16000" );
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", "400" );
gAdvertiseTimeCvar = register_cvar( "deathrun_advertise_time", "7.0" );
gInvisPercent = register_cvar( "deathrun_invisibility_percentage", "0" );
gLongJumpTime = register_cvar( "deathrun_longjump_duration", "8" );
gLongJumpCost = register_cvar( "deathrun_longjump_cost", "10000" );
gEffectType = register_cvar( "deathrun_effect_type", "3" );
/* --| Let's find/do some stuff here */
gMsgItemPickup = get_user_msgid( "ItemPickup" );
gMsgMoney = get_user_msgid( "Money" );
/* --| Register the multilingual file */
register_dictionary( "DeathrunShopLang.txt" );
}
/* --| Precache stuff */
public plugin_precache()
{
precache_sound( PICKUP_SND );
precache_sound( HEALTH_SOUND );
precache_sound( ARMOR_SOUND );
precache_sound( CLOACK_SOUND );
precache_sound( LJ_SOUND );
g_ADSpr = precache_model("sprites/shockwave.spr");
}
/* --| Plugin cfg, here we do some ugly shit ever -.- */
public plugin_cfg()
{
new iCfgDir[ 32 ], iFile[ 192 ];
/* --| We need to find the configs directory, and to add the configuration file */
get_configsdir( iCfgDir, charsmax( iCfgDir ) );
formatex( iFile, charsmax( iFile ), "%s/DeathrunShop_Cfg.cfg", iCfgDir );
/* --| If file not exists, let's create one but empty */
if( !file_exists( iFile ) )
{
server_print( "[DrShop] %L", LANG_SERVER, "DRSHOP_SVPRINT", iFile );
write_file( iFile, " ", -1 );
}
/* --| Else, let's load the cvars from cfg */
else
{
server_print( "[DrShop] %L", LANG_SERVER, "DRSHOP_SVPRINT_DONE", iFile );
server_cmd( "exec %s", iFile );
}
/* --| Set the server maxspeed to a high value, need it for speed item */
server_cmd( "sv_maxspeed 99999999.0" );
}
/* --| When client is connecting, let's reset stuff and load client's points */
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;
HasDeagle[ id ] = false;
HasLongJump[ id ] = false;
g_b_Invisible[ id ] = false;
}
/* --| When client has disconnected let's reset stuff and save points */
public client_disconnect( 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;
HasDeagle[ id ] = false;
HasLongJump[ id ] = false;
g_b_Invisible[ id ] = false;
}
/* --| When client has entered on sv, need to show him a hudmessage :) */
public client_putinserver( id )
{
if( get_pcvar_num( gAdvertiseCvar ) != 0 )
{
/* --| Need to set task, 7 default because need to wait for player choosing a team or something */
set_task( get_pcvar_float( gAdvertiseTimeCvar ), "ShowPlayerInfo", id );
}
}
/* --| Deathrun shop menu with items ^^ */
public DeathrunShop( id )
{
/* --| If cvar is set to 0, player can't open the shop */
if( get_pcvar_num( gDrShopOn ) != 1 )
{
client_print( id, print_chat, "[DrShop] %L", id, "DRSHOP_DISABLED" );
return PLUGIN_HANDLED;
}
/* --| If player is dead, cant buy items :) */
if( !is_user_alive( id ) )
{
client_print( id, print_chat, "[DrShop] %L", id, "DRSHOP_ONLY_ALIVE" );
return PLUGIN_HANDLED;
}
/* --| Menu stuff */
new szText[ 555 char ];
formatex( szText, charsmax( szText ), "%L", id, "DRSHOP_MENU_TITLE", VERSION, fm_get_user_money(id) );
new menu = menu_create( szText, "shop_handler" );
/* --| Menu item 1 */
formatex( szText, charsmax( szText ), "%L", id, "DRSHOP_ITEM_1", get_pcvar_num( gHeCost ) );
menu_additem( menu, szText, "1", 0 );
/* --| Menu item 2 */
formatex( szText, charsmax( szText ), "%L", id, "DRSHOP_ITEM_2", get_pcvar_num( gBothGrenadesCost ) );
menu_additem( menu, szText, "2", 0 );
/* --| Menu item 3 */
formatex( szText, charsmax( szText ), "%L", id, "DRSHOP_ITEM_3", get_pcvar_num( gSilentCost ) );
menu_additem( menu, szText, "3", 0 );
/* --| Menu item 4 */
formatex( szText, charsmax( szText ), "%L", id, "DRSHOP_ITEM_4", get_pcvar_num( gHealthPointCvar ), get_pcvar_num( gHealthCost ) );
menu_additem( menu, szText, "4", 0 );
/* --| Menu item 5 */
formatex( szText, charsmax( szText ), "%L", id, "DRSHOP_ITEM_5", get_pcvar_num( gArmorPointCvar ), get_pcvar_num( gArmorCost ) );
menu_additem( menu, szText, "5", 0 );
/* --| Menu item 6 */
formatex( szText, charsmax( szText ), "%L", id, "DRSHOP_ITEM_6", get_pcvar_num( gSpeedCost ) );
menu_additem( menu, szText, "6", 0 );
/* --| Menu item 7 */
formatex( szText, charsmax( szText ), "%L", id, "DRSHOP_ITEM_7", get_pcvar_num( gGravityCost ) );
menu_additem( menu, szText, "7", 0 );
/* --| Menu item 8 */
/* formatex( szText, charsmax( szText ), "%L", id, "DRSHOP_ITEM_8", get_pcvar_num( gInvisPercent ), get_pcvar_num( gInvisCost ) ); */
if(get_pdata_int(id, 114) == 1)
{
formatex(szText, charsmax(szText), "\w%d%% from 255 Invisible \r(Only Terrorist) \w- \y%d$",
get_pcvar_num(gInvisPercent), get_pcvar_num(gInvisCost));
}
else
{
formatex(szText, charsmax(szText), "\d%d%% from 255 Invisible (Only Terrorist) - %d$",
get_pcvar_num(gInvisPercent), get_pcvar_num(gInvisCost));
}
menu_additem( menu, szText, "8", 0 );
/* --| Menu item 9 */
formatex( szText, charsmax( szText ), "%L", id, "DRSHOP_ITEM_9", get_pcvar_num( gDeagleCost ) );
menu_additem( menu, szText, "9", 0 );
/* --| Menu item 10 */
formatex( szText, charsmax( szText ), "%L", id, "DRSHOP_ITEM_10", get_pcvar_num( gLongJumpTime ), get_pcvar_num( gLongJumpCost ) );
menu_additem( menu, szText, "10", 0 );
menu_setprop( menu, MPROP_EXIT, MEXIT_ALL );
/* --| Show the menu, with current page 0 */
menu_display( id, menu, 0 );
return PLUGIN_CONTINUE;
}
/* --| Menu commands */
public shop_handler( id, menu, item )
{
/* --| If key is 0, let's close the menu */
if( item == MENU_EXIT )
{
menu_destroy( menu );
return PLUGIN_HANDLED;
}
/* --| Getting the menu information */
new data[ 6 ], iName[ 64 ], access, callback;
menu_item_getinfo( menu, item, access, data, charsmax( data ), iName, charsmax( iName ), callback );
/* --| Get menu keys */
new key = str_to_num( data );
/* --| Here we find the player points */
new money = fm_get_user_money(id);
static Float:originF[3];
pev(id, pev_origin, originF);
switch( key )
{
/* --| Menu item 1 */
case 1:
{
/* --| If already has item, show a damn print and return */
if( HasHe[ id ] )
{
allready_have( id );
return PLUGIN_HANDLED;
}
/* --| If player does not have enough points, show a print and return */
if( money < get_pcvar_num( gHeCost ) )
{
dont_have( id );
return PLUGIN_HANDLED;
}
if( get_pcvar_num( gEffectType ) == 1 )
{
if( !g_b_Invisible[ id ] )
{
set_user_rendering( id, kRenderFxGlowShell, 0, 255, 0, kRenderTransAlpha, 16 );
set_task(2.0, "Remove_Rendering", id);
}
screen_fade(id, 1, 1, 0, 255, 0, 50);
}
if( get_pcvar_num( gEffectType ) == 2 )
{
Effects(originF);
screen_fade(id, 1, 1, 0, 255, 0, 50);
}
if( get_pcvar_num( gEffectType ) == 3 )
{
if( !g_b_Invisible[ id ] )
{
set_user_rendering( id, kRenderFxGlowShell, 0, 255, 0, kRenderTransAlpha, 16 );
set_task(2.0, "Remove_Rendering", id);
}
screen_fade(id, 1, 1, 0, 255, 0, 50);
Effects(originF);
}
/* --| Let's give the item, and do some stuff */
give_item( id, "weapon_hegrenade" );
client_print( id, print_chat, "[DrShop] %L", id, "DRSHOP_GRENADE_ITEM" );
HasHe[ id ] = true;
fm_set_user_money(id, money - get_pcvar_num(gHeCost));
emit_sound( id, CHAN_ITEM, PICKUP_SND, VOL_NORM , ATTN_NORM , 0 , PITCH_NORM );
menu_display( id, menu, 0 );
}
/* --| Menu item 2 */
case 2:
{
/* --| If already has item, show a damn print and return */
if( HasBothGren[ id ] )
{
allready_have( id );
return PLUGIN_HANDLED;
}
/* --| If player does not have enough points, show a print and return */
if( money < get_pcvar_num( gBothGrenadesCost ) )
{
dont_have( id );
return PLUGIN_HANDLED;
}
if( get_pcvar_num( gEffectType ) == 1 )
{
if( !g_b_Invisible[ id ] )
{
set_user_rendering( id, kRenderFxGlowShell, 0, 255, 0, kRenderTransAlpha, 16 );
set_task(2.0, "Remove_Rendering", id);
}
screen_fade(id, 1, 1, 0, 255, 0, 50);
}
if( get_pcvar_num( gEffectType ) == 2 )
{
Effects(originF);
screen_fade(id, 1, 1, 0, 255, 0, 50);
}
if( get_pcvar_num( gEffectType ) == 3 )
{
if( !g_b_Invisible[ id ] )
{
set_user_rendering( id, kRenderFxGlowShell, 0, 255, 0, kRenderTransAlpha, 16 );
set_task(2.0, "Remove_Rendering", id);
}
screen_fade(id, 1, 1, 0, 255, 0, 50);
Effects(originF);
}
/* --| Let's give the item, and do some stuff */
give_item( id, "weapon_flashbang" );
give_item( id, "weapon_smokegrenade" );
client_print( id, print_chat, "[DrShop] %L", id, "DRSHOP_BOTHGREN_ITEM" );
HasBothGren[ id ] = true;
fm_set_user_money(id, money - get_pcvar_num(gBothGrenadesCost));
emit_sound( id, CHAN_ITEM, PICKUP_SND, VOL_NORM , ATTN_NORM , 0 , PITCH_NORM );
menu_display( id, menu, 0 );
}
/* --| Menu item 3 */
case 3:
{
/* --| If already has item, show a damn print and return */
if( HasSilent[ id ] )
{
allready_have( id );
return PLUGIN_HANDLED;
}
/* --| If player does not have enough points, show a print and return */
if( money < get_pcvar_num( gSilentCost ) )
{
dont_have( id );
return PLUGIN_HANDLED;
}
if( get_pcvar_num( gEffectType ) == 1 )
{
if( !g_b_Invisible[ id ] )
{
set_user_rendering( id, kRenderFxGlowShell, 0, 255, 0, kRenderTransAlpha, 16 );
set_task(2.0, "Remove_Rendering", id);
}
screen_fade(id, 1, 1, 0, 255, 0, 50);
}
if( get_pcvar_num( gEffectType ) == 2 )
{
Effects(originF);
screen_fade(id, 1, 1, 0, 255, 0, 50);
}
if( get_pcvar_num( gEffectType ) == 3 )
{
if( !g_b_Invisible[ id ] )
{
set_user_rendering( id, kRenderFxGlowShell, 0, 255, 0, kRenderTransAlpha, 16 );
set_task(2.0, "Remove_Rendering", id);
}
screen_fade(id, 1, 1, 0, 255, 0, 50);
Effects(originF);
}
/* --| Let's give the item, and do some stuff */
set_user_footsteps( id, 1 );
client_print( id, print_chat, "[DrShop] %L", id, "DRSHOP_SILENTWALK_ITEM" );
HasSilent[ id ] = true;
fm_set_user_money(id, money - get_pcvar_num(gSilentCost));
emit_sound( id, CHAN_ITEM, PICKUP_SND, VOL_NORM , ATTN_NORM , 0 , PITCH_NORM );
menu_display( id, menu, 0 );
}
/* --| Menu item 4 */
case 4:
{
/* --| If already has item, show a damn print and return */
if( HasHealth[ id ] )
{
allready_have( id );
return PLUGIN_HANDLED;
}
/* --| If player does not have enough points, show a print and return */
if( money < get_pcvar_num( gHealthCost ) )
{
dont_have( id );
return PLUGIN_HANDLED;
}
if( get_pcvar_num( gEffectType ) == 1 )
{
if( !g_b_Invisible[ id ] )
{
set_user_rendering( id, kRenderFxGlowShell, 0, 255, 0, kRenderTransAlpha, 16 );
set_task(2.0, "Remove_Rendering", id);
}
screen_fade(id, 1, 1, 0, 255, 0, 50);
}
if( get_pcvar_num( gEffectType ) == 2 )
{
Effects(originF);
screen_fade(id, 1, 1, 0, 255, 0, 50);
}
if( get_pcvar_num( gEffectType ) == 3 )
{
if( !g_b_Invisible[ id ] )
{
set_user_rendering( id, kRenderFxGlowShell, 0, 255, 0, kRenderTransAlpha, 16 );
set_task(2.0, "Remove_Rendering", id);
}
screen_fade(id, 1, 1, 0, 255, 0, 50);
Effects(originF);
}
/* --| Let's give the item, and do some stuff */
set_user_health( id, get_user_health( id ) + get_pcvar_num( gHealthPointCvar ) );
client_print( id, print_chat, "[DrShop] %L", id, "DRSHOP_HEALTH_ITEM", get_pcvar_num( gHealthPointCvar ) );
HasHealth[ id ] = true;
fm_set_user_money(id, money - get_pcvar_num(gHealthCost));
emit_sound( id, CHAN_ITEM, HEALTH_SOUND, VOL_NORM , ATTN_NORM , 0 , PITCH_NORM );
menu_display( id, menu, 0 );
}
/* --| Menu item 5 */
case 5:
{
/* --| If already has item, show a damn print and return */
if( HasArmor[ id ] )
{
allready_have( id );
return PLUGIN_HANDLED;
}
/* --| If player does not have enough points, show a print and return */
if( money < get_pcvar_num( gArmorCost ) )
{
dont_have( id );
return PLUGIN_HANDLED;
}
if( get_pcvar_num( gEffectType ) == 1 )
{
if( !g_b_Invisible[ id ] )
{
set_user_rendering( id, kRenderFxGlowShell, 0, 255, 0, kRenderTransAlpha, 16 );
set_task(2.0, "Remove_Rendering", id);
}
screen_fade(id, 1, 1, 0, 255, 0, 50);
}
if( get_pcvar_num( gEffectType ) == 2 )
{
Effects(originF);
screen_fade(id, 1, 1, 0, 255, 0, 50);
}
if( get_pcvar_num( gEffectType ) == 3 )
{
if( !g_b_Invisible[ id ] )
{
set_user_rendering( id, kRenderFxGlowShell, 0, 255, 0, kRenderTransAlpha, 16 );
set_task(2.0, "Remove_Rendering", id);
}
screen_fade(id, 1, 1, 0, 255, 0, 50);
Effects(originF);
}
/* --| Let's give the item, and do some stuff */
set_user_armor( id, get_user_armor( id ) + get_pcvar_num( gArmorPointCvar ) );
client_print( id, print_chat, "[DrShop] %L", id, "DRSHOP_ARMOR_ITEM", get_pcvar_num( gArmorPointCvar ) );
HasArmor[ id ] = true;
fm_set_user_money(id, money - get_pcvar_num(gArmorCost));
emit_sound( id, CHAN_ITEM, ARMOR_SOUND, VOL_NORM , ATTN_NORM , 0 , PITCH_NORM );
menu_display( id, menu, 0 );
}
/* --| Menu item 6 */
case 6:
{
/* --| If already has item, show a damn print and return */
if( HasSpeed[ id ] )
{
allready_have( id );
return PLUGIN_HANDLED;
}
/* --| If player does not have enough points, show a print and return */
if( money < get_pcvar_num( gSpeedCost ) )
{
dont_have( id );
return PLUGIN_HANDLED;
}
if( get_pcvar_num( gEffectType ) == 1 )
{
if( !g_b_Invisible[ id ] )
{
set_user_rendering( id, kRenderFxGlowShell, 0, 255, 0, kRenderTransAlpha, 16 );
set_task(2.0, "Remove_Rendering", id);
}
screen_fade(id, 1, 1, 0, 255, 0, 50);
}
if( get_pcvar_num( gEffectType ) == 2 )
{
Effects(originF);
screen_fade(id, 1, 1, 0, 255, 0, 50);
}
if( get_pcvar_num( gEffectType ) == 3 )
{
if( !g_b_Invisible[ id ] )
{
set_user_rendering( id, kRenderFxGlowShell, 0, 255, 0, kRenderTransAlpha, 16 );
set_task(2.0, "Remove_Rendering", id);
}
screen_fade(id, 1, 1, 0, 255, 0, 50);
Effects(originF);
}
/* --| Let's give the item, and do some stuff */
set_user_maxspeed( id, get_pcvar_float( gSpeedCvar ) );
client_print( id, print_chat, "[DrShop] %L", id, "DRSHOP_SPEED_ITEM" );
HasSpeed[ id ] = true;
fm_set_user_money(id, money - get_pcvar_num(gSpeedCost));
emit_sound( id, CHAN_ITEM, PICKUP_SND, VOL_NORM , ATTN_NORM , 0 , PITCH_NORM );
menu_display( id, menu, 0 );
}
/* --| Menu item 7 */
case 7:
{
/* --| If already has item, show a damn print and return */
if( HasGravity[ id ] )
{
allready_have( id );
return PLUGIN_HANDLED;
}
/* --| If player does not have enough points, show a print and return */
if( money < get_pcvar_num( gGravityCost ) )
{
dont_have( id );
return PLUGIN_HANDLED;
}
if( get_pcvar_num( gEffectType ) == 1 )
{
if( !g_b_Invisible[ id ] )
{
set_user_rendering( id, kRenderFxGlowShell, 0, 255, 0, kRenderTransAlpha, 16 );
set_task(2.0, "Remove_Rendering", id);
}
screen_fade(id, 1, 1, 0, 255, 0, 50);
}
if( get_pcvar_num( gEffectType ) == 2 )
{
Effects(originF);
screen_fade(id, 1, 1, 0, 255, 0, 50);
}
if( get_pcvar_num( gEffectType ) == 3 )
{
if( !g_b_Invisible[ id ] )
{
set_user_rendering( id, kRenderFxGlowShell, 0, 255, 0, kRenderTransAlpha, 16 );
set_task(2.0, "Remove_Rendering", id);
}
screen_fade(id, 1, 1, 0, 255, 0, 50);
Effects(originF);
}
/* --| Let's give the item, and do some stuff */
set_user_gravity( id, get_pcvar_float( gGravityCvar ) );
client_print( id, print_chat, "[DrShop] %L", id, "DRSHOP_GRAVITY_ITEM" );
HasGravity[ id ] = true;
fm_set_user_money(id, money - get_pcvar_num(gGravityCost));
emit_sound( id, CHAN_ITEM, PICKUP_SND, VOL_NORM , ATTN_NORM , 0 , PITCH_NORM );
menu_display( id, menu, 0 );
}
/* --| Menu item 8 */
case 8:
{
/* --| If already has item, show a damn print and return */
if( HasInvis[ id ] )
{
allready_have( id );
return PLUGIN_HANDLED;
}
if( get_user_team( id ) == 2 )
{
client_print( id, print_chat, "[DrShop] %L", id, "DRSHOP_ONLY_T" );
menu_display(id, menu, 1);
return PLUGIN_HANDLED;
}
/* --| If player does not have enough points, show a print and return */
if( money < get_pcvar_num( gInvisCost ) )
{
dont_have( id );
return PLUGIN_HANDLED;
}
if( get_pcvar_num( gEffectType ) == 1 )
{
if( !g_b_Invisible[ id ] )
{
set_user_rendering( id, kRenderFxGlowShell, 0, 255, 0, kRenderTransAlpha, 16 );
set_task(2.0, "Remove_Rendering_Invisible", id);
}
screen_fade(id, 1, 1, 0, 255, 0, 50);
}
if( get_pcvar_num( gEffectType ) == 2 )
{
Effects(originF);
screen_fade(id, 1, 1, 0, 255, 0, 50);
}
if( get_pcvar_num( gEffectType ) == 3 )
{
if( !g_b_Invisible[ id ] )
{
set_user_rendering( id, kRenderFxGlowShell, 0, 255, 0, kRenderTransAlpha, 16 );
set_task(2.0, "Remove_Rendering_Invisible", id);
}
screen_fade(id, 1, 1, 0, 255, 0, 50);
Effects(originF);
}
/* --| Let's give the item, and do some stuff */
client_print( id, print_chat, "[DrShop] %L", id, "DRSHOP_INVISIBILITY_ITEM" );
HasInvis[ id ] = true;
g_b_Invisible[ id ] = true;
fm_set_user_money(id, money - get_pcvar_num(gInvisCost));
emit_sound( id, CHAN_ITEM, CLOACK_SOUND, VOL_NORM , ATTN_NORM , 0 , PITCH_NORM );
menu_display( id, menu, 1 );
}
/* --| Menu item 9 */
case 9:
{
/* --| If already has item, show a damn print and return */
if( HasDeagle[ id ] || user_has_weapon( id, CSW_DEAGLE ) )
{
allready_have( id );
return PLUGIN_HANDLED;
}
/* --| If player does not have enough points, show a print and return */
if( money < get_pcvar_num( gDeagleCost ) )
{
dont_have( id );
return PLUGIN_HANDLED;
}
if( get_pcvar_num( gEffectType ) == 1 )
{
if( !g_b_Invisible[ id ] )
{
set_user_rendering( id, kRenderFxGlowShell, 0, 255, 0, kRenderTransAlpha, 16 );
set_task(2.0, "Remove_Rendering", id);
}
screen_fade(id, 1, 1, 0, 255, 0, 50);
}
if( get_pcvar_num( gEffectType ) == 2 )
{
Effects(originF);
screen_fade(id, 1, 1, 0, 255, 0, 50);
}
if( get_pcvar_num( gEffectType ) == 3 )
{
if( !g_b_Invisible[ id ] )
{
set_user_rendering( id, kRenderFxGlowShell, 0, 255, 0, kRenderTransAlpha, 16 );
set_task(2.0, "Remove_Rendering", id);
}
screen_fade(id, 1, 1, 0, 255, 0, 50);
Effects(originF);
}
/* --| Let's give the item, and do some stuff */
give_item( id, "weapon_deagle" );
client_print( id, print_chat, "[DrShop] %L", id, "DRSHOP_DEAGLE_ITEM" );
HasDeagle[ id ] = true;
fm_set_user_money(id, money - get_pcvar_num(gDeagleCost));
emit_sound( id, CHAN_ITEM, PICKUP_SND, VOL_NORM , ATTN_NORM , 0 , PITCH_NORM );
menu_display( id, menu, 1 );
}
/* --| Menu item 10 */
case 10:
{
/* --| If already has item, show a damn print and return */
if( HasLongJump[ id ] )
{
allready_have( id );
return PLUGIN_HANDLED;
}
/* --| If player does not have enough points, show a print and return */
if( money < get_pcvar_num( gLongJumpCost ) )
{
dont_have( id );
return PLUGIN_HANDLED;
}
if( get_pcvar_num( gEffectType ) == 1 )
{
if( !g_b_Invisible[ id ] )
{
set_user_rendering( id, kRenderFxGlowShell, 0, 255, 0, kRenderTransAlpha, 16 );
set_task(2.0, "Remove_Rendering", id);
}
screen_fade(id, 1, 1, 0, 255, 0, 50);
}
if( get_pcvar_num( gEffectType ) == 2 )
{
Effects(originF);
screen_fade(id, 1, 1, 0, 255, 0, 50);
}
if( get_pcvar_num( gEffectType ) == 3 )
{
if( !g_b_Invisible[ id ] )
{
set_user_rendering( id, kRenderFxGlowShell, 0, 255, 0, kRenderTransAlpha, 16 );
set_task(2.0, "Remove_Rendering", id);
}
screen_fade(id, 1, 1, 0, 255, 0, 50);
Effects(originF);
}
/* --| Let's give the item, and do some stuff */
/* --| Setting the temporary long jump */
set_temporary_longjump( id );
client_print( id, print_chat, "[DrShop] %L", id, "DRSHOP_LJ_ITEM" );
HasLongJump[ id ] = true;
fm_set_user_money(id, money - get_pcvar_num(gLongJumpCost));
emit_sound( id, CHAN_ITEM, LJ_SOUND, VOL_NORM , ATTN_NORM , 0 , PITCH_NORM );
menu_display( id, menu, 1 );
}
}
return PLUGIN_HANDLED;
}
public Remove_Rendering( id )
{
set_user_rendering( id, kRenderFxGlowShell, 0, 0, 0, kRenderNormal, 16 );
}
public Remove_Rendering_Invisible( id )
{
set_user_rendering( id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, get_pcvar_num( gInvisPercent ) );
}
/* --| Command for setting points | admin only ;/ */
public cmdSetMoney( id, level, cid )
{
/* --| If user doesn't have acces to command, return */
if( !cmd_access( id, level, cid, 2 ) || !get_pcvar_num( gDrShopOn ) )
{
return PLUGIN_HANDLED;
}
/* --| Need to read the first argument */
new argument[ 32 ];
read_argv( 1, argument, charsmax( argument ) );
/* --| Need to read second argument */
new give_points[ 6 ];
read_argv( 2, give_points, charsmax( give_points ) );
/* --| We are getting the gift from second argument */
new gift = str_to_num( give_points );
new iPlayer[ 32 ], iNum, all;
get_players( iPlayer, iNum, "c" );
/* --| Lets see if argument 1 is @all */
if( equal( argument, "@all" ) )
{
for( new i; i < iNum; i++ )
{
/* --| Find the index :) */
all = iPlayer[ i ];
/* --| Set points to all */
new i_Money;
i_Money = fm_get_user_money(all);
fm_set_user_money(all, i_Money + gift);
/* --| Show a print in chat */
get_user_name( id, gName, charsmax( gName ) );
client_print( 0, print_chat, "[DrShop] %L", LANG_PLAYER, "DRSHOP_SHOW_ALLCMD", gName, gift );
}
}
else
{
/* --| Now, we find the target */
new player = cmd_target( id, argument, 10 );
/* --| If is not a valid target, return */
if( !player )
{
return PLUGIN_HANDLED;
}
/* --| Get admin, and target name */
new TargetName[ 32 char ];
get_user_name( player, TargetName, charsmax( TargetName ) );
get_user_name( id, gName, charsmax( gName ) );
/* --| Setting target points */
new i_Money;
i_Money = fm_get_user_money(player);
fm_set_user_money(player, i_Money + gift);
client_print( 0, print_chat, "[DrShop] %L", LANG_PLAYER, "DRSHOP_SHOW_CMD", gName, gift, TargetName );
}
return PLUGIN_HANDLED;
}
/* --| Command for reseting points | admin only ;/ */
public cmdResetMoney( id, level, cid )
{
/* --| If user doesn't have acces to command, return */
if( !cmd_access( id, level, cid, 2 ) || !get_pcvar_num( gDrShopOn ) )
{
return PLUGIN_HANDLED;
}
/* --| Need to read the first argument */
new argument[ 32 ];
read_argv( 1, argument, charsmax( argument ) );
new iPlayer[ 32 ], iNum, all;
get_players( iPlayer, iNum, "c" );
/* --| Lets see if argument 1 is @all */
if( equal( argument, "@all" ) )
{
for( new i; i < iNum; i++ )
{
/* --| Find the index :) */
all = iPlayer[ i ];
/* --| Set points to all */
fm_set_user_money(all, 0, 1);
/* --| Show a print in chat */
get_user_name( id, gName, charsmax( gName ) );
client_print( 0, print_chat, "[DrShop] %L", LANG_PLAYER, "DRSHOP_SHOWRESET_ALLCMD", gName );
}
}
else
{
/* --| Now, we find the target */
new player = cmd_target( id, argument, 10 );
/* --| If is not a valid target, return */
if( !player )
{
return PLUGIN_HANDLED;
}
/* --| Get admin, and target name */
new TargetName[ 32 char ];
get_user_name( player, TargetName, charsmax( TargetName ) );
get_user_name( id, gName, charsmax( gName ) );
/* --| Setting target points */
fm_set_user_money(player, 0, 1);
client_print( 0, print_chat, "[DrShop] %L", LANG_PLAYER, "DRSHOP_SHOWRESET_CMD", gName, TargetName );
}
return PLUGIN_HANDLED;
}
/* --| We need to check is player has changed his weapon */
public HookCurWeapon( id )
{
/* --| If plugin is on, and user has speed item, let's set the speed again */
if( get_pcvar_num( gDrShopOn ) != 0 && HasSpeed[ id ] )
{
set_user_maxspeed( id, get_pcvar_float( gSpeedCvar ) );
}
}
/* --| Command for show points */
public ShowPoints( id )
{
/* --| Set a hud message */
set_hudmessage( 255, 42, 212, 0.03, 0.86, 2, 6.0, 5.0 );
/* --| We show player points on hud */
show_hudmessage( id, "[DrShop] %L", id, "DRSHOP_MONEY_INFO", fm_get_user_money(id) );
/* --| We show player points on chat */
client_print( id, print_chat, "[DrShop] %L", id, "DRSHOP_MONEY_INFO", fm_get_user_money(id) );
return PLUGIN_CONTINUE;
}
/* --| Here we show player hud information about this god damn shop */
public ShowPlayerInfo( id )
{
/* --| Set a hud message */
set_hudmessage( 0, 189, 255, -1.0, 0.82, 0, 6.0, 12.0 );
/* --| Now we show the info message in hud channel */
show_hudmessage( id, "%L", id, "DRSHOP_HUD_INFO" );
}
/* --| Event for round start */
public logevent_round_start()
{
/* --| If plugin is on... */
if( get_pcvar_num( gDrShopOn ) == 1 )
{
/* --| I used this native because with get_maxplayers will recieve a damn error with invalid player id.. */
/* --| This is good because we can skip the damn bots */
new iPlayers[ 32 ], iNum, i, id;
get_players( iPlayers, iNum, "c" );
for( i = 0; i < iNum; i++ )
{
/* --| Find the index :) */
id = iPlayers[ i ];
/* --| Reseting items */
HasHe[ id ] = false;
HasBothGren[ id ] = false;
HasSilent[ id ] = false;
HasHealth[ id ] = false;
HasArmor[ id] = false;
HasSpeed[ id ] = false;
HasGravity[ id ] = false;
HasInvis[ id ] = false;
HasDeagle[ id ] = false;
HasLongJump[ id ] = false;
set_user_gravity( id, 1.0 );
set_user_maxspeed( id, 0.0 );
set_user_footsteps( id, 0 );
set_user_rendering( id );
remove_task( id );
}
}
}
/* --| Event when player died */
public Hook_Deathmessage()
{
/* --| If plugin is on... */
if( get_pcvar_num( gDrShopOn ) == 1 )
{
/* --| Get the killer and attacker */
new victim = read_data( 2 );
/* --| If player has died with world / trigger_hurt */
if(!(1 <= victim <= 32) || read_data(1) == victim)
{
return PLUGIN_HANDLED;
}
/* --| Reseting items */
HasHe[ victim ] = false;
HasBothGren[ victim ] = false;
HasSilent[ victim ] = false;
HasHealth[ victim ] = false;
HasArmor[ victim ] = false;
HasSpeed[ victim ] = false;
HasGravity[ victim ] = false;
HasInvis[ victim ] = false;
HasDeagle[ victim ] = false;
HasLongJump[ victim ] = false;
set_user_gravity( victim, 1.0 );
set_user_maxspeed( victim, 0.0 );
set_user_footsteps( victim, 0 );
set_user_rendering( victim );
remove_task( victim );
}
return PLUGIN_CONTINUE;
}
/* --| Now we need to remove the longjump */
public remove_lj( index )
{
HasLongJump[ index ] = false;
engfunc( EngFunc_SetPhysicsKeyValue, index, "slj", "0" );
client_print( index, print_chat, "[DrShop] %L", index, "DRSHOP_LJ_OFF", get_pcvar_num( gLongJumpTime ) );
}
/* --| Usefull stocks on this plugin */
/* --| Display a message in chat if player already have the item */
stock allready_have( id )
{
client_print( id, print_chat, "[DrShop] %L", id, "DRSHOP_ALLREADY_HAVE" );
}
/* --| Display a message in chat if player don't have enough points */
stock dont_have( id )
{
client_print( id, print_chat, "[DrShop] %L", id, "DRSHOP_DONTHAVE_MONEY" );
}
/* --| Flame jetpack effect stock */
stock create_flame( origin[ 3 ] )
{
message_begin( MSG_PVS, SVC_TEMPENTITY, origin );
write_byte( TE_SPRITE );
write_coord( origin[ 0 ] );
write_coord( origin[ 1 ] );
write_coord( origin[ 2 ] );
write_short( gJetSprite );
write_byte( 3 );
write_byte( 99 );
message_end();
}
/* --| Setting temporary longjump stock */
stock set_temporary_longjump( index )
{
/* --| Let's show to player the jetpack item on hud */
message_begin( MSG_ONE_UNRELIABLE, gMsgItemPickup, _, index );
write_string( "item_longjump" );
message_end();
/* --| Setting the jetpack on */
engfunc( EngFunc_SetPhysicsKeyValue, index, "slj", "1" );
/* --| Setting the time before jetpack will go off */
set_task( float( get_pcvar_num( gLongJumpTime ) ), "remove_lj", index );
}
stock fm_get_user_money( index )
{
new money = get_pdata_int( index, OFFSET_MONEY );
return money;
}
stock fm_set_user_money( index, money, flash = 1 )
{
set_pdata_int( index, OFFSET_MONEY, money );
fm_set_money( index, money, flash );
return 1;
}
stock fm_set_money( index, money, flash )
{
message_begin( MSG_ONE_UNRELIABLE, gMsgMoney, {0, 0, 0}, index );
write_long( money );
write_byte( flash ? 1 : 0 );
message_end();
}
stock screen_fade(index, iDuration, iHoldTime, r, g, b, alpha)
{
message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, index );
write_short(fade_units_to_seconds(iDuration));
write_short(fade_units_to_seconds(iHoldTime));
write_short(0x0000);
write_byte(r);
write_byte(g);
write_byte(b);
write_byte(alpha);
message_end();
}
stock fade_units_to_seconds(num)
{
return ((1<<12) * (num));
}
Effects(const Float:originF3[3])
{
// Largest ring
engfunc( EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF3, 0 );
write_byte( TE_BEAMCYLINDER ); // TE id
engfunc( EngFunc_WriteCoord, originF3[0] ); // x
engfunc( EngFunc_WriteCoord, originF3[1] ); // y
engfunc( EngFunc_WriteCoord, originF3[2] ); // z
engfunc( EngFunc_WriteCoord, originF3[0] ); // x axis
engfunc( EngFunc_WriteCoord, originF3[1] ); // y axis
engfunc( EngFunc_WriteCoord, originF3[2]+100.0 ); // z axis
write_short( g_ADSpr ); // sprite
write_byte( 0 ); // startframe
write_byte( 0 ); // framerate
write_byte( 4 ); // life
write_byte( 60 ); // width
write_byte( 0 ); // noise
write_byte( 0 ); // red
write_byte( 255 ); // green
write_byte( 50 ); // blue
write_byte( 200 ); // brightness
write_byte( 0 ); // speed
message_end();
}
/* --| Enf of plugin... */
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
*/