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.
409.
410.
411.
412.
413.
414.
415.
416.
417.
418.
419.
420.
421.
422.
423.
424.
425.
426.
427.
428.
429.
430.
431.
432.
433.
434.
435. | /* AMX Mod X script.
*
* Deathrun Shop
* Copyright (C) 2009 tuty
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
* Credits:
* --------
* - xPaw ( for menu because new amxx menu doesnt suport cvars... thank you )
* - connor ( sugestion )
*/
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <fakemeta_util>
#define PLUGIN "Deathrun Shop"
#define VERSION "1.0"
#define AUTHOR "tuty" // spolszczone by exTez
#pragma semicolon 1
#define PICKUP_SND "items/gunpickup2.wav"
#define OFFSET_MONEY 115
#define ADVERTISE_JOIN_TIME 7.0
new gDrShopOn;
new gHeCost;
new gBothGrenadesCost;
new gSilentCost;
new gHealthCost;
new gArmorCost;
new gSpeedCost;
new gGravityCost;
new gInvisCost;
new gMsgMoney;
new gMaxPlayers;
new gMenu;
new gSpeedCvar;
new gGravityCvar;
new gAdvertiseCvar;
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 bool:bSilent[ 33 ];
public plugin_init()
{
register_plugin( PLUGIN, VERSION, AUTHOR );
register_forward( FM_PlayerPreThink, "forward_player_prethink" );
register_logevent( "logevent_round_start", 2, "1=Round_Start" );
register_event( "DeathMsg", "Hook_Deathmessage", "a" );
register_clcmd( "say /sklep", "DeathrunShop" );
register_clcmd( "say_team /sklep", "DeathrunShop" );
register_clcmd( "say sklep", "DeathrunShop" );
register_clcmd( "say_team sklep", "DeathrunShop" );
register_clcmd( "/sklep", "DeathrunShop" );
register_clcmd( "sklep", "DeathrunShop" );
gMenu = register_menuid( "Deathrun Shop" );
register_menucmd( gMenu, 1023, "menu_shop" );
gDrShopOn = register_cvar( "deathrun_shop", "1" );
gHeCost = register_cvar( "deathrun_he_cost", "2500" );
gBothGrenadesCost = register_cvar( "deathrun_bothgrenades_cost", "5000" );
gSilentCost = register_cvar( "deathrun_silent_cost", "4000" );
gHealthCost = register_cvar( "deathrun_health_cost", "6000" );
gArmorCost = register_cvar( "deathrun_armor_cost", "6000" );
gSpeedCost = register_cvar( "deathrun_speed_cost", "16000" );
gGravityCost = register_cvar( "deathrun_gravity_cost", "8000" );
gInvisCost = register_cvar( "deathrun_invisibility_cost", "16000" );
gSpeedCvar = register_cvar( "deathrun_speed_power", "400.0" );
gGravityCvar = register_cvar( "deathrun_gravity_power", "0.5" );
gAdvertiseCvar = register_cvar( "deathrun_advertise_message", "1" );
gMsgMoney = get_user_msgid( "Money" );
gMaxPlayers = get_maxplayers();
register_dictionary( "deathrunshop.txt" );
}
public plugin_precache()
{
engfunc( EngFunc_PrecacheSound, PICKUP_SND );
}
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;
}
public client_disconnect( id )
{
bSilent[ id ] = false;
HasHe[ id ] = false;
HasBothGren[ id ] = false;
HasSilent[ id ] = false;
HasHealth[ id ] = false;
HasArmor[ id] = false;
HasSpeed[ id ] = false;
HasGravity[ id ] = false;
HasInvis[ id ] = false;
}
public client_putinserver( id )
{
if( get_pcvar_num( gAdvertiseCvar ) != 0 )
{
set_task( ADVERTISE_JOIN_TIME, "ShowPlayerInfo", id );
}
}
public forward_player_prethink( id )
{
if( bSilent[ id ] )
{
set_pev( id, pev_flTimeStepSound, 999 );
}
}
public DeathrunShop( id )
{
if( get_pcvar_num( gDrShopOn ) != 1 )
{
client_print( id, print_chat, "%L", id, "DRSHOP_DISABLED" );
return PLUGIN_HANDLED;
}
if( !is_user_alive( id ) )
{
client_print( id, print_chat, "%L", id, "DRSHOP_ONLY_ALIVE" );
return PLUGIN_HANDLED;
}
new szBuffer[ 512 ];
new iLen;
iLen = formatex( szBuffer, charsmax( szBuffer ), "\rSklep Deathrun^n^n");
iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "\r1. \wHE Grenade - \y%d$^n", get_pcvar_num( gHeCost ) );
iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "\r2. \wHE + Flash Grenade - \y%d$^n", get_pcvar_num( gBothGrenadesCost ) );
iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "\r3. \wCichy bieg - \y%d$^n", get_pcvar_num( gSilentCost ) );
iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "\r4. \w+250 Zycia - \y%d$^n", get_pcvar_num( gHealthCost ) );
iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "\r5. \w+250 Obrony - \y%d$^n", get_pcvar_num( gArmorCost ) );
iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "\r6. \wSzybsze bieganie \r(Dopoki umrzesz) \w- \y%d$^n", get_pcvar_num( gSpeedCost ) );
iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "\r7. \wGrawitacja \r(Dopoki umrzesz) \w- \y%d$^n", get_pcvar_num( gGravityCost ) );
iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "\r8. \w80 procent nie widzialnosci \r(Dopoki umrzesz - Tylko terro) \w- \y%d$^n^n^n", get_pcvar_num( gInvisCost ) );
iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "\r9. \wWyjscie" );
new keys = ( 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6 | 1<<7 | 1<<8 );
show_menu( id, keys, szBuffer );
return PLUGIN_CONTINUE;
}
public menu_shop( id, key )
{
new whichmoney = fm_get_user_money( id );
switch( key )
{
case 0:
{
if( HasHe[ id ] )
{
allready_have( id );
return PLUGIN_HANDLED;
}
if( whichmoney < get_pcvar_num( gHeCost ) )
{
dont_have( id );
return PLUGIN_HANDLED;
}
fm_give_item( id, "weapon_hegrenade" );
client_print( id, print_chat, "%L", id, "DRSHOP_GRENADE_ITEM" );
fm_set_user_money( id, whichmoney - get_pcvar_num( gHeCost ) );
client_sound_play( id );
HasHe[ id ] = true;
}
case 1:
{
if( HasBothGren[ id ] )
{
allready_have( id );
return PLUGIN_HANDLED;
}
if( whichmoney < get_pcvar_num( gBothGrenadesCost ) )
{
dont_have( id );
return PLUGIN_HANDLED;
}
fm_give_item( id, "weapon_hegrenade" );
fm_give_item( id, "weapon_flashbang" );
client_print( id, print_chat, "%L", id, "DRSHOP_BOTHGREN_ITEM" );
fm_set_user_money( id, whichmoney - get_pcvar_num( gBothGrenadesCost ) );
client_sound_play( id );
HasBothGren[ id ] = true;
}
case 2:
{
if( HasSilent[ id ] )
{
allready_have( id );
return PLUGIN_HANDLED;
}
if( whichmoney < get_pcvar_num( gSilentCost ) )
{
dont_have( id );
return PLUGIN_HANDLED;
}
fm_set_user_footsteps( id, 1 );
client_print( id, print_chat, "%L", id, "DRSHOP_SILENTWALK_ITEM" );
fm_set_user_money( id, whichmoney - get_pcvar_num( gSilentCost ) );
client_sound_play( id );
HasSilent[ id ] = true;
}
case 3:
{
if( HasHealth[ id ] )
{
allready_have( id );
return PLUGIN_HANDLED;
}
if( whichmoney < get_pcvar_num( gHealthCost ) )
{
dont_have( id );
return PLUGIN_HANDLED;
}
fm_set_user_health( id, get_user_health( id ) + 255 );
client_print( id, print_chat, "%L", id, "DRSHOP_HEALTH_ITEM" );
fm_set_user_money( id, whichmoney - get_pcvar_num( gHealthCost ) );
client_sound_play( id );
HasHealth[ id ] = true;
}
case 4:
{
if( HasArmor[ id ] )
{
allready_have( id );
return PLUGIN_HANDLED;
}
if( whichmoney < get_pcvar_num( gArmorCost ) )
{
dont_have( id );
return PLUGIN_HANDLED;
}
fm_set_user_armor( id, get_user_armor( id ) + 255 );
client_print( id, print_chat, "%L", id, "DRSHOP_ARMOR_ITEM" );
fm_set_user_money( id, whichmoney - get_pcvar_num( gArmorCost ) );
client_sound_play( id );
HasArmor[ id ] = true;
}
case 5:
{
if( HasSpeed[ id ] )
{
allready_have( id );
return PLUGIN_HANDLED;
}
if( whichmoney < get_pcvar_num( gSpeedCost ) )
{
dont_have( id );
return PLUGIN_HANDLED;
}
fm_set_user_maxspeed( id, get_pcvar_float( gSpeedCvar ) );
client_print( id, print_chat, "%L", id, "DRSHOP_SPEED_ITEM" );
fm_set_user_money( id, whichmoney - get_pcvar_num( gSpeedCost ) );
client_sound_play( id );
HasSpeed[ id ] = true;
}
case 6:
{
if( HasGravity[ id ] )
{
allready_have( id );
return PLUGIN_HANDLED;
}
if( whichmoney < get_pcvar_num( gGravityCost ) )
{
dont_have( id );
return PLUGIN_HANDLED;
}
fm_set_user_gravity( id, get_pcvar_float( gGravityCvar ) );
client_print( id, print_chat, "%L", id, "DRSHOP_GRAVITY_ITEM" );
fm_set_user_money( id, whichmoney - get_pcvar_num( gGravityCost ) );
client_sound_play( id );
HasGravity[ id ] = true;
}
case 7:
{
if( HasInvis[ id ] )
{
allready_have( id );
return PLUGIN_HANDLED;
}
if( get_user_team( id ) == 2 )
{
client_print( id, print_chat, "%L", id, "DRSHOP_ONLY_T" );
return PLUGIN_HANDLED;
}
if( whichmoney < get_pcvar_num( gInvisCost ) )
{
dont_have( id );
return PLUGIN_HANDLED;
}
fm_set_rendering( id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 100 );
client_print( id, print_chat, "%L", id, "DRSHOP_INVISIBILITY_ITEM" );
fm_set_user_money( id, whichmoney - get_pcvar_num( gInvisCost ) );
client_sound_play( id );
HasInvis[ id ] = true;
}
case 8:
{
client_print( id, print_chat, "%L", id, "DRSHOP_MENU_CLOSED" );
return PLUGIN_HANDLED;
}
}
return PLUGIN_HANDLED;
}
public logevent_round_start()
{
if( get_pcvar_num( gDrShopOn ) == 1 )
{
for( new id = 1; id <= gMaxPlayers; 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;
fm_set_user_gravity( id, 1.0 );
fm_set_user_maxspeed( id, 0.0 );
fm_set_user_footsteps( id, 0 );
}
}
return PLUGIN_CONTINUE;
}
public Hook_Deathmessage()
{
if( get_pcvar_num( gDrShopOn ) == 1 )
{
new id = read_data( 2 );
HasHe[ id ] = false;
HasBothGren[ id ] = false;
HasSilent[ id ] = false;
HasHealth[ id ] = false;
HasArmor[ id] = false;
HasSpeed[ id ] = false;
HasGravity[ id ] = false;
HasInvis[ id ] = false;
fm_set_rendering( id );
fm_set_user_gravity( id, 1.0 );
fm_set_user_maxspeed( id, 0.0 );
fm_set_user_footsteps( id, 0 );
}
return PLUGIN_CONTINUE;
}
public ShowPlayerInfo( id )
{
set_hudmessage( 0, 0, 255, -1.0, 0.82, 0, 6.0, 12.0 );
show_hudmessage( id, "%L", id, "DRSHOP_HUD_INFO" );
}
allready_have( id)
{
client_print( id, print_chat, "%L", id, "DRSHOP_ALLREADY_HAVE" );
}
dont_have( id )
{
client_print( id, print_chat, "%L", id, "DRSHOP_DONTHAVE_MONEY" );
}
client_sound_play( index )
{
client_cmd( index, "speak %s", PICKUP_SND );
}
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 fm_set_user_footsteps( index, set = 1 )
{
if( set )
{
set_pev( index, pev_flTimeStepSound, 999 );
bSilent[ index ] = true;
}
else
{
set_pev( index, pev_flTimeStepSound, 400 );
bSilent[ index ] = false;
}
return 1;
}
|