[ create a new paste ] login | about

Link: http://codepad.org/DGrDOxeW    [ raw code | fork ]

Raheem - C, pasted on Jul 17:
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#include <dhudmessage>

/*--Variables--*/
new T_Count
new CT_Count
new g_maxplayers
new iNum
new Attacker
new Victim
new Team_attacker
new Team_victim
new money
new onoff
new speed_per_sec

new iPlayers[32]
new plr_money[33]
new plr_cur_money[33]
new g_menuPosition[33]
new g_menuPlayers[33][32]
new g_menuPlayersNum[33]
new g_menuOption[33]
new g_menuSettings[33]
new g_coloredMenus
new imonn[33]

new bool:plr_prespawn[33]
/*-------------*/

public plugin_init()
{
	register_plugin("[ZE] Money-System", "1.2", "Raheem")
	
	/*-------Infection\Kill Bouns--------*/
	register_event("DeathMsg", "death", "a")
	
	/*------Block Kill Command--------*/
	register_forward(FM_ClientKill,"HookKill")
	
	/*------Money Hud Effect------*/
	register_event("Money","update_money","b")
	onoff = register_cvar("amx_mhe_money","1")
	speed_per_sec = register_cvar("amx_mhe_money_speed","10")
	RegisterHam(Ham_Spawn,"player","player_prespawn",0)
	RegisterHam(Ham_Spawn,"player","player_spawn",1)
	money = get_user_msgid("Money")
	register_message(money,"hook_money")
	
	/*------Damage Bonus-------*/
	register_event("Damage", "on_damage", "b", "2!0", "3=0", "4!0")
	
	/*------Donate System-----*/
	register_clcmd("say donate","cmdDonateMenu")
	register_clcmd("say /donate","cmdDonateMenu")
	register_clcmd("say_team donate","cmdDonateMenu")
	register_clcmd("say_team /donate","cmdDonateMenu")
	register_cvar("amx_donate_max","16000")
	register_menucmd(register_menuid("Donate Menu"),1023,"actionDonateMenu")
	
	g_maxplayers = get_maxplayers()
}

/*-----------------Escape Bouns-----------------*/

public ze_roundend()
{
	T_Count = GetPlayersNum(CsTeams:CS_TEAM_T)
	CT_Count = GetPlayersNum(CsTeams:CS_TEAM_CT)
	
	get_players(iPlayers, iNum, "ace", "CT")
	
	for (new i = 0; i < iNum; i++)
	{
		if(CT_Count > T_Count) //Mean CT Win
		{
			cs_set_user_money (iPlayers[i] , cs_get_user_money(iPlayers[i]) + 1000)
			client_print_color(iPlayers[i], "!n[!gMoney!n-!gSystem!n] !n+!t1000!n$ !gEscape Bonus!n.")
		}
		else
		{
			return;
		}
	}
	
	get_players(iPlayers, iNum, "ce", "TERRORIST")
	
	for (new i = 0; i < iNum; i++)
	{
		if(CT_Count > T_Count)
		{
			cs_set_user_money (iPlayers[i] , cs_get_user_money(iPlayers[i]) - 1400) //Don't Change This
		}
		else
		{
			return;
		}
	}
}

/*-----------------Infection\Kill Bouns-----------------*/

public death()
{
	Attacker = read_data(1)
	Victim = read_data(2)
	Team_attacker = get_user_team(Attacker)
	Team_victim = get_user_team(Victim)
	
	if(Team_attacker != Team_victim)
	{
		cs_set_user_money(Attacker, cs_get_user_money(Attacker) + 1500)
		client_print_color(Attacker, "!n[!gMoney!n-!gSystem!n] !n+!t1500!n$ !gInfection!n\!gKill Bonus!n.")
	}
	else
	{
		return;
	}
}

/*-----------------Block Kill Command-----------------*/

public HookKill(id)
{
	client_print(id,print_console,"[Money-System] This command has been disabled.")
	return FMRES_SUPERCEDE
}

/*-----------------Money Hud Effect-----------------*/

public client_disconnect(id) {
	plr_money[id]=0
	plr_cur_money[id]=0
	plr_prespawn[id]=false
	
	remove_task(id)
}

public player_prespawn(id) { 
	if(get_pcvar_num(onoff) && is_user_connected(id)) {
		plr_prespawn[id]=true
		
		plr_money[id]=get_pdata_int(id,115,5)
		plr_cur_money[id]=0
		
		set_pdata_int(id,115,0,5)
		
		set_plr_money(id,0)
	}
}

public player_spawn(id) {
	if(get_pcvar_num(onoff) && is_user_connected(id)) {
		plr_prespawn[id]=false
		
		set_pdata_int(id,115,plr_money[id],5)
		
		set_plr_money(id,plr_money[id])
	}
}

public update_money(id) {
	if(!get_pcvar_num(onoff) || !is_user_connected(id) || plr_prespawn[id]) return PLUGIN_HANDLED
	
	new cur_money=read_data(1)
	
	if(cur_money!=plr_money[id]) {
		plr_money[id]=cur_money

		if(!task_exists(id)) set_task(0.1,"money_effect",id,_,_,"b")
		
		set_plr_money(id,plr_cur_money[id])
	}
	return PLUGIN_HANDLED
}

public hook_money(msg_id,msg_dest,id) {
	if(!get_pcvar_num(onoff)) return PLUGIN_CONTINUE
		
	new cash = get_msg_arg_int(1)
	
	if(plr_cur_money[id]!=cash) return PLUGIN_HANDLED
	
	return PLUGIN_CONTINUE
}

public money_effect(id) {
	static Add
	
	if(plr_cur_money[id]==plr_money[id]) {
		remove_task(id)
		plr_cur_money[id]=plr_money[id]
		
		return PLUGIN_HANDLED
	}
	else if(plr_cur_money[id] < plr_money[id]) {
		Add=(plr_money[id]-plr_cur_money[id])/get_pcvar_num(speed_per_sec)
		
		if(!Add) Add=1
		
		plr_cur_money[id]+=Add
	}
	else {
		Add=(plr_cur_money[id]-plr_money[id])/get_pcvar_num(speed_per_sec)
		
		if(!Add) Add=1
		
		plr_cur_money[id]-=Add
	}
	
	set_plr_money(id,plr_cur_money[id])
	
	return PLUGIN_CONTINUE
}

set_plr_money(id,Money,flash=0) {
	message_begin(MSG_ONE_UNRELIABLE,money,_,id)
	write_long(Money)
	write_byte(flash)
	message_end() 
}

/*-----------------Damage Bonus-----------------*/

public on_damage(id)
{
	static attacker
	attacker = get_user_attacker(id)
	static damage
	damage = read_data(2)
	
	if((damage >= 60) && is_user_connected(attacker) && is_user_alive(attacker) && (cs_get_user_team(attacker) == CS_TEAM_CT))
	{
		cs_set_user_money(attacker, cs_get_user_money(attacker) + 30)
		set_dhudmessage(random(256), random(256), random(256), -1.0, 0.7, 1, 3.0, 3.0, 0.5, 0.5)
		show_dhudmessage(attacker, "[Money-System] +30 $ Damage Bouns.")	
	}
}

/*----------------Donate System---------------*/

public actionDonateMenu(id,key) {
	switch (key) {
		case 7: {
			++g_menuOption[id]
			g_menuOption[id] %= 1
			
			switch (g_menuOption[id]) {
				case 1: g_menuSettings[id] = 3000
			}
			displayDonateMenu(id,g_menuPosition[id])
	}
		case 8: displayDonateMenu(id,++g_menuPosition[id])
		case 9: displayDonateMenu(id,--g_menuPosition[id])
	default: {
		new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key]

		new name2[32]
		get_user_name(player,name2,31)

		new name[32]
		get_user_name(id,name,31)

		imonn[id] = g_menuSettings[id]
	
		new setidmoney[32]
		new setplmoney[32]
		new maxmoney = get_cvar_num("amx_donate_max")
		setplmoney[id] = (cs_get_user_money(player) + imonn[id])

		if (cs_get_user_money(id) < imonn[id]){
			client_print_color(id, "!n[!gMoney!n-!gSystem!n] !tYou don't have enough money!n!")
			return PLUGIN_HANDLED
		}else if (maxmoney < (setplmoney[id])){
			new overplmoney[32]
			overplmoney[id]= (maxmoney - cs_get_user_money(player))
			setidmoney[id] = (cs_get_user_money(id) - overplmoney[id])
			cs_set_user_money(id,setidmoney[id])
			cs_set_user_money(player,maxmoney)
			client_print_color(id, "!n[!gMoney!n-!gSystem!n] !t%d$ !nwas donated to !t%s!n.",imonn[id],name2)
			client_print_color(player, "!n[!gMoney!n-!gSystem!n] !t%d$ !nwas donated from !t%s!n.",imonn[id],name)
			return PLUGIN_HANDLED
		}else{
			setidmoney[id] = (cs_get_user_money(id) - imonn[id])
			cs_set_user_money(id,setidmoney[id])
			cs_set_user_money(player,setplmoney[id])
			client_print_color(id, "!n[!gMoney!n-!gSystem!n] !t%d$ !nwas donated to !t%s!n.",imonn[id],name2)
			client_print_color(player, "!n[!gMoney!n-!gSystem!n] !t%d$ !nwas donated from !t%s!n.",imonn[id],name)
			return PLUGIN_HANDLED
		}

		displayDonateMenu(id,g_menuPosition[id])
		}
	}
	return PLUGIN_HANDLED
}


displayDonateMenu(id,pos) {
  if (pos < 0)  return

  get_players(g_menuPlayers[id],g_menuPlayersNum[id])

  new menuBody[512]
  new b = 0
  new i
  new name[32], team[4]
  new start = pos * 7

  if (start >= g_menuPlayersNum[id])
    start = pos = g_menuPosition[id] = 0

  new len = format(menuBody,511, g_coloredMenus ? 
    "\rDonate Menu \r%d/%d^n \r^n" : "\y[\rMoney-System\y] \w- \yPlayer-List \r%d\w/\r%d^n^n",
    pos+1,(  g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0 )) )
    
  new end = start + 7
  new keys = MENU_KEY_0|MENU_KEY_8
  
  if (end > g_menuPlayersNum[id])
    end = g_menuPlayersNum[id]

  for (new a = start; a < end; ++a) {
    i = g_menuPlayers[id][a]
    get_user_name(i,name,31)
    get_user_team(i,team,3)

    if ( is_user_bot(i)||i == id) {
      ++b   
      if ( g_coloredMenus )
        len += format(menuBody[len],511-len,"\d%d. %s\R%s^n\w", b,name,team)
      else
        len += format(menuBody[len],511-len,"\d%d. %s\R%s^n\w", b,name,team)
    }
    else
    {
      keys |= (1<<b)

      len += format(menuBody[len],511-len, g_coloredMenus ? 
        "%d. %s\R%s^n\w" : "\y%d. \w%s\r\R%s^n",++b,name,team)
    }
  }

  if ( g_menuOption[id] )
    len += format(menuBody[len],511-len,"^n\y8. \wThe amount of money : \r$ %d^n",g_menuSettings[id] )
  else
    len += format(menuBody[len],511-len,"^n\y8. \wThe amount of money : \r$ 1000^n")
  if (end != g_menuPlayersNum[id]) {
    format(menuBody[len],511-len,"^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
    keys |= MENU_KEY_9
  }
  else format(menuBody[len],511-len,"^n\y0. \w%L", id, pos ? "BACK" : "EXIT")

  show_menu(id,keys,menuBody,-1,"Donate Menu")
}

public cmdDonateMenu(id,level,cid)
{
  if (!cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
  g_menuOption[id] = 0
  g_menuSettings[id] = 1000

  displayDonateMenu(id,g_menuPosition[id] = 0)
  return PLUGIN_HANDLED 
}


/*-----------------Get Players Number Stock-----------------*/

stock GetPlayersNum(CsTeams:iTeam) {
    new iNum;
    for( new i = 1; i <= g_maxplayers; i++ ) {
        if( is_user_connected(i) && is_user_alive(i) && cs_get_user_team(i) == iTeam )
            iNum++;
    }
    return iNum;
}

/*-----------------Colored Message Stock-----------------*/

stock client_print_color(const id, const input[], any:...)  
{  
    new count = 1, players[32];  
    static msg[191];  
    vformat(msg, 190, input, 3);  

    replace_all(msg, 190, "!g", "^x04"); // Green Color  
    replace_all(msg, 190, "!n", "^x01"); // Default Color  
    replace_all(msg, 190, "!t", "^x03"); // Team Color  

    if (id) players[0] = id; else get_players(players, count, "ch");  
    {  
        for (new i = 0; i < count; i++)  
        {  
            if (is_user_connected(players[i]))  
            {  
                message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);  
                write_byte(players[i]);  
                write_string(msg);  
                message_end();  
            }  
        }  
    }  
}  


Create a new paste based on this one


Comments: