Добавить Лимит денег

gesk1995

Пользователь
Регистрация
8 Июн 2017
Сообщения
339
Симпатии
12
Пол
Мужской
Привет всем
После убийства с базуки , даются деньги , и можно с базуки набить себе хоть сколько денег , например 100 000$.
Хотя на сервере лимит 25 000$ , прошу помощи что бы сделать лимит в плагин)

Код:
#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <fun>
#include <cstrike>
#include <amxmisc>
#include <colorchat> 

#define TE_EXPLOSION        3
#define TE_EXPLFLAG_NONE    0
#define TE_SMOKE               5
#define TE_BLOODSPRITE      115
#define TE_MODEL              106
#define TE_WORLDDECAL       116

new g_sModelIndexFireball, g_sModelIndexSmoke, rocketsmoke
new bool:CanShoot[33], bool:hasBazooka[33]
new mdl_gib_flesh, mdl_gib_head, mdl_gib_legbone, mdl_gib_lung, mdl_gib_meat, mdl_gib_spine, spr_blood_drop, spr_blood_spray
new bazooka_cost

public plugin_init()
{
   register_plugin("BazookaAdvanced", "1.3", "Major Victory")

  // iCvarItemCost = register_cvar("wc3_bazooka_cost", "3000");
   //iCvarOnOffItem = register_cvar("wc3_bazooka_on_off", "1");
   
  // g_itemid_bazooka = wc3_register_extra_item(g_item_name, get_pcvar_num(iCvarItemCost),iCvarOnOffItem,1)
   
   register_cvar("amx_bazooka_damageradius", "250")
   register_cvar("amx_bazooka_maxdamage", "150")
   register_cvar("amx_bazooka_reloadtime", "2.5")
   register_cvar("amx_bazooka_trailtime", "30")
   register_cvar("amx_bazooka_velocity", "700")
   bazooka_cost = register_cvar("amx_bazooka_cost", "3000")
   
   register_event("DeathMsg", "player_die", "a")
   register_event("CurWeapon", "check_model", "be")
   register_event("TextMsg", "bomb_msg", "b", "2=#C4_Plant_At_Bomb_Spot")
   register_event("TextMsg", "ev_RoundRestart", "a", "2=#Game_will_restart_in")
   
   register_clcmd("drop", "handle_drop")
   register_clcmd("say /bazooka", "givebazooka")
   register_clcmd("bazooka", "givebazooka")
   
   register_forward(FM_SetModel, "forward_setmodel")
}

public plugin_precache()
{
   precache_model("models/fire_bazooka.mdl")
   precache_model("models/w_rpg_vechta_new.mdl")
   precache_model("models/v_rpg_vechta_new.mdl")
   precache_model("models/p_rpg_vechta_new.mdl")
   precache_sound("weapons/rocketfire1.wav")
   precache_sound("weapons/nuke_fly.wav")// <-- this is the only non-game sound file, make sure you have it
   precache_sound("weapons/dryfire1.wav")
   spr_blood_drop = precache_model("sprites/blood.spr")
   spr_blood_spray = precache_model("sprites/bloodspray.spr")
   mdl_gib_flesh = precache_model("models/Fleshgibs.mdl")
   mdl_gib_head = precache_model("models/GIB_Skull.mdl")
   mdl_gib_legbone = precache_model("models/GIB_Legbone.mdl")
   mdl_gib_lung = precache_model("models/GIB_Lung.mdl")
   mdl_gib_meat = precache_model("models/GIB_B_Gib.mdl")
   mdl_gib_spine = precache_model("models/GIB_B_Bone.mdl")
   g_sModelIndexFireball = precache_model("sprites/zerogxplode.spr")
   g_sModelIndexSmoke  = precache_model("sprites/steam1.spr")
   rocketsmoke = precache_model("sprites/smoke.spr")
}


public givebazooka(id)
{
    if(!is_user_alive(id))
        return

    new money = cs_get_user_money(id)

    if(money < get_pcvar_num(bazooka_cost)) {
        ColorChat(id, GREEN, "^1[^4Bazooka^1]  ^1У вас ^3не хватает денег ^1на покупку ^4Базуки ^1[^3нужно ^4 9800$^1]")
        return
    }
    else
    {
        give_item(id, "weapon_c4");
        hasBazooka[id] = true;

        cs_set_user_money(id, money - get_pcvar_num(bazooka_cost))
        ColorChat(id, GREEN, "^1[^4Bazooka^1] ^1Поздравляю, ^3Вы купили ^x04Базуку ^1[^3За ^4 9800$ ^1]")
    }
}

public bomb_msg(id)
   if (cs_get_user_plant(id) != 1)
      client_print(id,print_center,"")

public ev_RoundRestart ()
{
   static iMaxPlayers

   if ( iMaxPlayers || ( iMaxPlayers = get_maxplayers () ) )
   {
      for ( new i = 1; i <= iMaxPlayers; i++ )
      {
         if ( !is_user_connected ( i ) )
            continue

         hasBazooka[i] = false
         if (cs_get_user_plant(i) == 1)
            cs_set_user_plant(i,0,0)
      }
   }
}

public fire_rocket(id) {
   CanShoot[id] = false
   
   new data[1]
   data[0] = id
   new rtime = get_cvar_num("amx_bazooka_reloadtime")
   if (cs_get_user_plant(id) != 1)
   {
         set_task((rtime + 0.0), "rpg_reload", id+9477, data, 1)
         new Float:StartOrigin[3], Float:Angle[3]
         
         new PlayerOrigin[3]
         get_user_origin(id, PlayerOrigin, 1)
         
         StartOrigin[0] = float(PlayerOrigin[0])
         StartOrigin[1] = float(PlayerOrigin[1])
         StartOrigin[2] = float(PlayerOrigin[2])
         
         entity_get_vector(id, EV_VEC_v_angle, Angle)
         Angle[0] = Angle[0] * -1.0
         new RocketEnt = create_entity("info_target")
         entity_set_string(RocketEnt, EV_SZ_classname, "rpgrocket")
         entity_set_model(RocketEnt, "models/fire_bazooka.mdl")
         entity_set_origin(RocketEnt, StartOrigin)
         entity_set_vector(RocketEnt, EV_VEC_angles, Angle)
         
         new Float:MinBox[3] = {-1.0, -1.0, -1.0}
         new Float:MaxBox[3] = {1.0, 1.0, 1.0}
         entity_set_vector(RocketEnt, EV_VEC_mins, MinBox)
         entity_set_vector(RocketEnt, EV_VEC_maxs, MaxBox)
         
         entity_set_int(RocketEnt, EV_INT_solid, 2)
         entity_set_int(RocketEnt, EV_INT_movetype, 5)
         entity_set_edict(RocketEnt, EV_ENT_owner, id)
         
         new Float:Velocity[3]
         new myvelocity = get_cvar_num("amx_bazooka_velocity")
         VelocityByAim(id, myvelocity, Velocity)
         entity_set_vector(RocketEnt, EV_VEC_velocity, Velocity)
         
         emit_sound(RocketEnt, CHAN_WEAPON, "weapons/rocketfire1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
         emit_sound(RocketEnt, CHAN_VOICE, "weapons/nuke_fly.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
     
         new CsTeams:iTeam =cs_get_user_team(id)
         new trailtime = get_cvar_num("amx_bazooka_trailtime")
         switch(iTeam) {
               case CS_TEAM_T: { //if team T color=red
                  message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
                  write_byte(22)
                  write_short(RocketEnt)
                  write_short(rocketsmoke)
                  write_byte(trailtime)
                  write_byte(3)
                  write_byte(255)
                  write_byte(0)
                  write_byte(0)
                  write_byte(255)
                  message_end()
               }
               case CS_TEAM_CT: { // if team CT color=blue
                  message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
                  write_byte(22)
                  write_short(RocketEnt)
                  write_short(rocketsmoke)
                  write_byte(trailtime)
                  write_byte(3)
                  write_byte(0)
                  write_byte(0)
                  write_byte(255)
                  write_byte(255)
                  message_end()
               }
         }  
         return PLUGIN_HANDLED
   }
   return PLUGIN_HANDLED
}

public rpg_reload(data[])
   CanShoot[data[0]] = true

public pfn_touch(ptr, ptd) {
   new ClassName[32], ClassNameptd[32]
   
   if ((ptr > 0) && is_valid_ent(ptr)) {
      entity_get_string(ptr, EV_SZ_classname, ClassName, 31)
   }
   
   if ((ptd > 0) && is_valid_ent(ptd)) {
      entity_get_string(ptd, EV_SZ_classname, ClassNameptd, 31)
   }
   
   if (equal(ClassName, "rpgrocket"))
   {
      if (equal(ClassNameptd, "func_breakable"))
      {
         force_use(ptr,ptd)
         remove_task(ptr)
      }
     
      remove_task(ptr)
      new Float:EndOrigin[3]
      entity_get_vector(ptr, EV_VEC_origin, EndOrigin)
     
      message_begin( MSG_BROADCAST, SVC_TEMPENTITY)  // Explosion
      write_byte(TE_EXPLOSION)
      write_coord(floatround(EndOrigin[0]))
      write_coord(floatround(EndOrigin[1]))
      write_coord(floatround(EndOrigin[2])+5)
      write_short(g_sModelIndexFireball)
      write_byte(random_num(0,20) + 20)
      write_byte(12) // framerate
      write_byte(TE_EXPLFLAG_NONE)
      message_end()
     
      message_begin(MSG_BROADCAST, SVC_TEMPENTITY)  // Smoke
      write_byte(TE_SMOKE)
      write_coord(floatround(EndOrigin[0]))
      write_coord(floatround(EndOrigin[1]))
      write_coord(floatround(EndOrigin[2])+15)
      write_short(g_sModelIndexSmoke)
      write_byte(60)
      write_byte(10)
      message_end()
     
      new maxdamage = get_cvar_num("amx_bazooka_maxdamage")
      new damageradius = get_cvar_num("amx_bazooka_damageradius")
      new NonFloatEndOrigin[3]
      new Float:EntPos[3]
      new PlayerPos[3], distance, damage, attacker = entity_get_edict(ptr, EV_ENT_owner)
     
      NonFloatEndOrigin[0] = floatround(EndOrigin[0])
      NonFloatEndOrigin[1] = floatround(EndOrigin[1])
      NonFloatEndOrigin[2] = floatround(EndOrigin[2])
     
      new iEnt = FM_NULLENT;
     
      while( (iEnt = find_ent_by_class( iEnt, "NiceDispenser" )) )
      {
         pev(iEnt, pev_origin, EntPos)
         static NonFloatEntPos[3]
         
         NonFloatEntPos[0] = floatround(EntPos[0])
         NonFloatEntPos[1] = floatround(EntPos[1])
         NonFloatEntPos[2] = floatround(EntPos[2])
         
         distance = get_distance(NonFloatEntPos, NonFloatEndOrigin)
         if (distance <= damageradius) {

            damage = maxdamage - floatround(floatmul(float(maxdamage), floatdiv(float(distance), float(damageradius))))
            entity_set_float(iEnt, EV_FL_health, entity_get_float(iEnt, EV_FL_health) - damage)
         }
      }
     
      iEnt = FM_NULLENT;
     
      while( (iEnt = find_ent_by_class( iEnt, "sentrybase" )) )
      {
         static iSentryEnt

         if ( entity_get_int ( iEnt, EV_INT_iuser1 ) == _:cs_get_user_team ( attacker ) && ( iSentryEnt = entity_get_edict ( iEnt, EV_ENT_euser1 ) ) == 0 )
            continue

         if ( is_valid_ent ( iSentryEnt ) )
         {
            static Float:fPeople[3]
            entity_get_vector ( iSentryEnt, EV_VEC_vuser1, fPeople )
   
            if ( entity_get_int ( iSentryEnt, EV_INT_iuser2 ) == _:cs_get_user_team ( attacker ) && floatround ( fPeople[0] ) != attacker )
               continue
         }

         pev(iEnt, pev_origin, EntPos)
         static NonFloatEntPos[3]
         
         NonFloatEntPos[0] = floatround(EntPos[0])
         NonFloatEntPos[1] = floatround(EntPos[1])
         NonFloatEntPos[2] = floatround(EntPos[2])
         
         distance = get_distance(NonFloatEntPos, NonFloatEndOrigin)
         if (distance <= damageradius) {

            damage = maxdamage - floatround(floatmul(float(maxdamage), floatdiv(float(distance), float(damageradius))))
            entity_set_float(iEnt, EV_FL_health, entity_get_float(iEnt, EV_FL_health) - damage)
         }
      }
     
      iEnt = FM_NULLENT;
     
      while( (iEnt = find_ent_by_class( iEnt, "sentry" )) )
      {
         static Float:fPeople[3]
         entity_get_vector ( iEnt, EV_VEC_vuser1, fPeople )

         if ( entity_get_int ( iEnt, EV_INT_iuser2 ) == _:cs_get_user_team ( attacker ) && floatround ( fPeople[0] ) != attacker )
            continue

         pev(iEnt, pev_origin, EntPos)
         static NonFloatEntPos[3]
         
         NonFloatEntPos[0] = floatround(EntPos[0])
         NonFloatEntPos[1] = floatround(EntPos[1])
         NonFloatEntPos[2] = floatround(EntPos[2])
         
         distance = get_distance(NonFloatEntPos, NonFloatEndOrigin)
         if (distance <= damageradius) {

            damage = maxdamage - floatround(floatmul(float(maxdamage), floatdiv(float(distance), float(damageradius))))
            entity_set_float(iEnt, EV_FL_health, entity_get_float(iEnt, EV_FL_health) - damage)
         }
      }
     
      for (new i = 1; i < 32; i++)
      {
         if (!is_user_alive(i))
            continue
           
         get_user_origin(i, PlayerPos)
         
         distance = get_distance(PlayerPos, NonFloatEndOrigin)
         if (distance <= damageradius) {
            //message_begin(MSG_ONE, get_user_msgid("ScreenShake"), {0,0,0}, i)  // Shake Screen
            //write_short(1<<14)
            //write_short(1<<14)
            //write_short(1<<14)
            //message_end()
           
            damage = maxdamage - floatround(floatmul(float(maxdamage), floatdiv(float(distance), float(damageradius))))
           
            if (get_user_team(attacker) == get_user_team(i))
               continue
            if (damage < get_user_health(i))
               set_user_health(i, get_user_health(i) - damage)
            else {
               set_msg_block(get_user_msgid("DeathMsg"), BLOCK_SET)
               user_kill(i, 1)
               set_msg_block(get_user_msgid("DeathMsg"), BLOCK_NOT)
               
               message_begin(MSG_BROADCAST, get_user_msgid("DeathMsg"))  // Kill-Log oben rechts
               write_byte(attacker)  // Attacker
               write_byte(i)  // Victim
               write_byte(0)  // Headshot
               write_string("bazooka")
               message_end()
               if (damage > 100) { //begin gibs and effects (made by mike_cao)
                  new iOrigin[3]
                  get_user_origin(i,iOrigin) // Effects
                  set_pev(i, pev_effects, EF_NODRAW)
                  fx_gib_explode(iOrigin,3)
                  fx_blood_large(iOrigin,5)
                  fx_blood_small(iOrigin,15)
                  iOrigin[2] = iOrigin[2]-20 // Hide body
                  set_user_origin(i,iOrigin)
               } //end gibs and effects
               
               new f = get_user_frags(attacker)
               new m = cs_get_user_money(attacker)
               
               set_user_frags(attacker, f + 1)
               cs_set_user_money(attacker, min(m + 100, 25000))          
            }
         }
      }
      remove_entity(ptr)
   }
}

public client_PreThink(id)
{
   if (is_user_alive(id))
   {
      new weaponid, clip, ammo
      weaponid = get_user_weapon(id, clip, ammo)
      if ((weaponid == CSW_C4) && hasBazooka[id]) {
         new attack = get_user_button(id) & IN_ATTACK
         new oldattack = get_user_oldbutton(id) & IN_ATTACK
         if (attack && !oldattack  && (cs_get_user_plant(id) != 1))
         {
               if (CanShoot[id])
                  fire_rocket(id)
         }
      }  
   }  

   return FMRES_IGNORED
}

public forward_setmodel(entity, model[]) {
   if (!is_valid_ent(entity))
      return FMRES_IGNORED
     
   if (equal(model, "models/w_backpack.mdl"))
   {
      client_print(0, print_center, "")
      new ClassName[32]
      entity_get_string(entity, EV_SZ_classname, ClassName, 31)
     
      if (equal(ClassName, "weaponbox"))
      {    
         remove_entity(entity)
         
         return FMRES_SUPERCEDE
      }
   }
   return FMRES_IGNORED
}

public check_model(id)
{
   new weaponid, clip, ammo
   
   weaponid = get_user_weapon(id, clip, ammo)
   if ((weaponid == CSW_C4) && (cs_get_user_plant(id) != 1)) {
      entity_set_string(id, EV_SZ_viewmodel, "models/v_rpg_vechta_new.mdl")
      entity_set_string(id, EV_SZ_weaponmodel, "models/p_rpg_vechta_new.mdl")
   }
   return PLUGIN_HANDLED
}

public client_connect(id)
{
   CanShoot[id] = true
   hasBazooka[id] = false
}

public player_die(id)
{
   new victim
   
   victim = read_data(2)
   hasBazooka[victim] = false
   if ((cs_get_user_plant(victim) == 1)) {
      cs_set_user_plant(victim,0,0)
   }
}

public handle_drop(id)
{
   new weaponid, clip, ammo
   weaponid = get_user_weapon(id, clip, ammo)
   if (weaponid == CSW_C4 && cs_set_user_plant(id,0,0)) {
      client_print(id, print_center, "Нельзя выбросить базуку")
      return PLUGIN_HANDLED
   }
   return PLUGIN_CONTINUE
}

/************************************************************
* GIB FUNCTIONS (made by mike_cao)
************************************************************/

static fx_blood_small(origin[3],num)
{
   // Blood decals
   static const blood_small[7] = {190,191,192,193,194,195,197}

   // Small splash
   for (new j = 0; j < num; j++) {
      message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
      write_byte(TE_WORLDDECAL)
      write_coord(origin[0]+random_num(-100,100))
      write_coord(origin[1]+random_num(-100,100))
      write_coord(origin[2]-36)
      write_byte(blood_small[random_num(0,6)]) // index
      message_end()
   }
}

static fx_blood_large(origin[3],num)
{
   // Blood decals
   static const blood_large[2] = {204,205}
   
   // Large splash
   for (new i = 0; i < num; i++) {
      message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
      write_byte(TE_WORLDDECAL)
      write_coord(origin[0]+random_num(-50,50))
      write_coord(origin[1]+random_num(-50,50))
      write_coord(origin[2]-36)
      write_byte(blood_large[random_num(0,1)]) // index
      message_end()
   }
}

static fx_gib_explode(origin[3],num)
{
   new flesh[3], x, y, z
   flesh[0] = mdl_gib_flesh
   flesh[1] = mdl_gib_meat
   flesh[2] = mdl_gib_legbone
   
   // Gib explosion
   // Head
   message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
   write_byte(TE_MODEL)
   write_coord(origin[0])
   write_coord(origin[1])
   write_coord(origin[2])
   write_coord(random_num(-100,100))
   write_coord(random_num(-100,100))
   write_coord(random_num(100,200))
   write_angle(random_num(0,360))
   write_short(mdl_gib_head)
   write_byte(0) // bounce
   write_byte(500) // life
   message_end()
   
   // Spine
   message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
   write_byte(TE_MODEL)
   write_coord(origin[0])
   write_coord(origin[1])
   write_coord(origin[2])
   write_coord(random_num(-100,100))
   write_coord(random_num(-100,100))
   write_coord(random_num(100,200))
   write_angle(random_num(0,360))
   write_short(mdl_gib_spine)
   write_byte(0) // bounce
   write_byte(500) // life
   message_end()
   
   // Lung
   for(new i = 0; i < random_num(1,2); i++) {
      message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
      write_byte(TE_MODEL)
      write_coord(origin[0])
      write_coord(origin[1])
      write_coord(origin[2])
      write_coord(random_num(-100,100))
      write_coord(random_num(-100,100))
      write_coord(random_num(100,200))
      write_angle(random_num(0,360))
      write_short(mdl_gib_lung)
      write_byte(0) // bounce
      write_byte(500) // life
      message_end()
   }
   
   // Parts, 10 times
   for(new i = 0; i < 10; i++) {
      message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
      write_byte(TE_MODEL)
      write_coord(origin[0])
      write_coord(origin[1])
      write_coord(origin[2])
      write_coord(random_num(-100,100))
      write_coord(random_num(-100,100))
      write_coord(random_num(100,200))
      write_angle(random_num(0,360))
      write_short(flesh[random_num(0,2)])
      write_byte(0) // bounce
      write_byte(500) // life
      message_end()
   }
   
   // Blood
   for(new i = 0; i < num; i++) {
      x = random_num(-100,100)
      y = random_num(-100,100)
      z = random_num(0,100)
      for(new j = 0; j < 3; j++) {
         message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
         write_byte(TE_BLOODSPRITE)
         write_coord(origin[0]+(x*j))
         write_coord(origin[1]+(y*j))
         write_coord(origin[2]+(z*j))
         write_short(spr_blood_spray)
         write_short(spr_blood_drop)
         write_byte(229) // color index
         write_byte(15) // size
         message_end()
      }
   }
}
 
Последнее редактирование:

Анатолий

Заблокированные
Пользователь
Регистрация
8 Июн 2017
Сообщения
685
Симпатии
195
Пол
Мужской
ВКонтакте
e1337ace
Может подробнее?
 

gesk1995

Пользователь
Регистрация
8 Июн 2017
Сообщения
339
Симпатии
12
Пол
Мужской
Анатолий, После убийства с базуки , даются деньги , и можно с базуки набить себе хоть сколько денег , например 100 000$.
Хотя на сервере лимит 25 000$ , прошу помощи что бы сделать лимит в плагин)
 

Анатолий

Заблокированные
Пользователь
Регистрация
8 Июн 2017
Сообщения
685
Симпатии
195
Пол
Мужской
ВКонтакте
e1337ace
Анатолий, После убийства с базуки , даются деньги , и можно с базуки набить себе хоть сколько денег , например 100 000$.
Хотя на сервере лимит 25 000$ , прошу помощи что бы сделать лимит в плагин)
Замени это cs_set_user_money(attacker, m + 100)
на это cs_set_user_money(attacker, min(m + 100, 25000))
 

Flymic24

Пользователь
Регистрация
15 Июн 2017
Сообщения
85
Симпатии
43
Пол
Мужской
gesk1995,
Замени
Код:
cs_set_user_money(attacker, m + 100)
на
Код:
cs_set_user_money(attacker, min(m + 100, 25000));
где 100 - сколько даётся за убийство
25000 - максимальный лимит
Гражданин Анатолий, всё уже ответил ))
 

gesk1995

Пользователь
Регистрация
8 Июн 2017
Сообщения
339
Симпатии
12
Пол
Мужской
Flymic24, Спасибо , Анатолий, первый скинул свой вариант сейчас тестирую[DOUBLEPOST=1525632735][/DOUBLEPOST]Анатолий, Спасибо , помогли)
 
Сверху Снизу