Counter-Strike 1.6 Icon CS1.6 Script

Buyknife

SEX! Ok, we got your attention. We are one of the oldest mod sites on the Interwebs. Sign up and maximize your browsing experience.

  • Subscribe: Get notified of new submissions like this.
  • Say Thanks: Show your appreciation by sending Rj. points.
  • Post: Give Rj. your thoughts on this Script.
  • Vote: Help Rj. win the Monthly Awards.
  • Rate: Give this Script a rating out of 10.
  • Flag: Alert moderators and warn members of a problem with this Script.
  • Watch: Get notified when this Script is updated.
Mascot

Interested?

Join GameBanana

Already a Bananite? Login

163 lines | 5 kb | Raw Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <cstrike>
#include <fun>

new bool:BuyTimeAllow
new bool:BuyZoneAllow[33]
new Float:BuyTimeFloat
new BuyTimeNum
new bool:BuyTimeCvar
new bool:BuyZoneCvar

//----------------------------------------------------------------------------------------------
public plugin_init() {
        register_plugin("BuyKnife", "1.0", "AssKicR")
        register_cvar("buy_time","1")
        register_cvar("buy_zone","1")
        register_cvar("buy_knife","1")
        register_cvar("sv_knifecost","100")
        register_event("ResetHUD","newRound","b")
        register_clcmd("buyknife","BuyKnife",ADMIN_USER,"")
        register_event("RoundTime","Round_Time","bc")
        register_event("StatusIcon","Buy_Icon","be","2=buyzone")
        register_concmd("buy_costknife","CostCom",ADMIN_LEVEL_B,"< money >")
}
//----------------------------------------------------------------------------------------------
public strip(){
        if (get_cvar_num("buy_knife")==1) {
                new iEntHandle = create_entity("game_player_equip")
                DispatchKeyValue(iEntHandle, "weapon_knife", "0")
                DispatchSpawn(iEntHandle)
        //  new Ent = create_entity("player_weaponstrip")
        //  Entvars_Set_String(Ent, EV_SZ_targetname, "game_playerspawn")
        }else{
                //Do noting.. We do not want them to loose knife now
        }
        return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public Check(id)
{
   if ( !is_user_alive(id) || (!BuyZoneAllow[id]&&BuyZoneCvar) )
      return false
   if (BuyTimeCvar)
   {
      if (!CheckTime(id))
         return false
   }

   return true
}
//----------------------------------------------------------------------------------------------
public CostCom(id,level,cid)
{
   if (!cmd_access(id,level,cid,3))
      return PLUGIN_HANDLED

   new arg1[4]
   read_argv(1,arg1,7)
   new money = str_to_num(arg1)
   {
      console_print(id,"[AMX] Set knife cost to %d$",money)
      set_cvar_num("sv_knifecost",money)
   }
//----------------------------------------------------------------------------------------------
   return PLUGIN_HANDLED
}

public Round_Time()
{
   if ( (read_data(1)==get_cvar_num("mp_freezetime")) || (read_data(1)==6) )
   {
      remove_task(701)
      BuyTimeAllow = true
      BuyTimeFloat = get_cvar_float("mp_buytime") * 60
      BuyTimeNum = floatround(BuyTimeFloat,floatround_floor)
      BuyTimeCvar = (get_cvar_num("buy_time")) ? true : false
      BuyZoneCvar = (get_cvar_num("buy_zone")) ? true : false
   }
   else
   {
      set_task(BuyTimeFloat,"BuyTimeTask",701)
   }

   return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public BuyTimeTask()
{
   BuyTimeAllow = false
}
//----------------------------------------------------------------------------------------------
public Buy_Icon(id)
{
   if (read_data(1))
   {
      BuyZoneAllow[id] = true
   }
   else
   {
      BuyZoneAllow[id] = false
   }

   return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public CheckTime(id)
{
   if (!BuyTimeAllow)
   {
      client_print(id,print_center,"%d seconds have passed...^n^nYou can't buy anything now!",BuyTimeNum)
      return false
   }
   return true
}
//----------------------------------------------------------------------------------------------

public newRound(id) {
        if (get_cvar_num("buy_knife")!=1) return PLUGIN_HANDLED
        set_task(1.0,"strip",0,"",0)
        client_print(id,print_chat,"[AMX] A knife costs %i$.. Buy it by typing ::: buyknife ::: in console",get_cvar_num("sv_knifecost"))

        return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public BuyKnife(id) {
        if (!Check(id)) return PLUGIN_HANDLED

        if (get_cvar_num("buy_knife")!=1) return PLUGIN_HANDLED
        new cost = get_cvar_num("sv_knifecost")
        new money = cs_get_user_money(id)
        if (money < cost) {
                client_print(id,print_center,"You need $%i to buy a knife",cost)
                return PLUGIN_CONTINUE
        }else{
                WeaponCheck(id,cost)
                }
        return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public WeaponCheck(id,cost)
  {
        // Yeah just givem the weapon if they don't already have it
        new iwpn, iwpns[32]
        get_user_weapons(id, iwpns,iwpn)
        //server_print("CHECKING Giving:%s", weaponName)         
        new ownWeapon[32]
        for(new a = 0; a < iwpn;++a)
        {
                get_weaponname(iwpns[a],ownWeapon,31)
                //server_print("PERSON OWNS %s", ownWeapon)      
 
                if ( equali(ownWeapon, "weapon_knife") ) {
                        client_print(id,print_center,"You already have a knife")
                        return PLUGIN_CONTINUE
                }
        }
        give_item(id, "weapon_knife")
        cs_set_user_money(id, cs_get_user_money(id) - cost,1)
        return PLUGIN_CONTINUE
  }
//----------------------------------------------------------------------------------------------
BuyKnife 1.0 
by AssKicR

-=Requirements=-
Engine
Cstrike
Fun

Description: 
This plugin makes you buy the knife 
(This Plugin is cool to use with Alternate Shop by Sniperbeamer )

CVARs: 
buy_time - take care of buytime (0/1) 
mp_buytime - sets buytime (minutes) 
buy_zone - take care of buyzone (0/1) 
buy_knife - must you buy the knife (0/1) (WARNING::: Can't be changed midround)

Client Command
buyknife - Buys a knife

Admin Command: 
buy_costknife - sets the cost of a the knife( < money > )

Posts

Share

Shareable Image:
Share banner
HTML embed code:
BB embed code:
Markdown embed code:

More embeddable images

Bookmark and Share

Credits

Original Authors
AssKicR
AMXX Script/Codes

Submitter

Rj. avatar
Rj. avatar IN PLAYGROUND
Scripts > Add Script Category
Member Joined 10mo
545 points Ranked 7786th
35 medals 4 legendary 9 rare
  • Submitted 15 Tools Medal icon
  • Submitted 50 Gamefiles Medal icon
  • 15+ Entries! GameBanana’s Christmas Giveaway 2016 Medal icon
  • Thanked 500 submitters Medal icon
  • 2nd Place - Game Poetry Contest Medal icon
  • Submitted 5 Tools Medal icon

Rj. avatar
Rj.

Redistributor
Are you the owner? Request Ownership
Send a Private Message to the submitter

Category

Stats

Posts
1
Views
113
Date Added
8d