Skocz do zawartości

Witamy w Nieoficjalnym polskim support'cie AMX Mod X

Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.
  • Rozpoczynaj nowe tematy i odpowiedaj na inne
  • Zapisz się do tematów i for, aby otrzymywać automatyczne uaktualnienia
  • Dodawaj wydarzenia do kalendarza społecznościowego
  • Stwórz swój własny profil i zdobywaj nowych znajomych
  • Zdobywaj nowe doświadczenia

Dołączona grafika Dołączona grafika

Guest Message by DevFuse
 

Zdjęcie

Sklepik - bonus na określony czas


  • Zamknięty Temat jest zamknięty
2 odpowiedzi w tym temacie

#1 simivar

    Zaawansowany

  • Użytkownik

Reputacja: 26
Życzliwy

  • Postów:106
  • Lokalizacja:aaaaa
Offline

Napisano 31.08.2009 00:40

Witam!
Przystosowując pewien skrypt do swych wymagań (co w nim jest, czego niema, co co robi etc.) chciałem dodać opcję, iż dany bonus jest tylko na określony w sekundach czas. Oto skrypt, do którego chcę dodać ta opcję:
/* 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"

#pragma semicolon 1
#define PICKUP_SND	"items/gunpickup2.wav"
#define OFFSET_MONEY	115
#define ADVERTISE_JOIN_TIME 7.0

new gDrShopOn;
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 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 /shop", "DeathrunShop" );
	register_clcmd( "say_team /shop", "DeathrunShop" );
	register_clcmd( "say shop", "DeathrunShop" );
	register_clcmd( "say_team shop", "DeathrunShop" );
	register_clcmd( "/shop", "DeathrunShop" );
	register_clcmd( "shop", "DeathrunShop" );

	gMenu = register_menuid( "Deathrun Shop" );
	register_menucmd( gMenu, 1023, "menu_shop" );

	gDrShopOn = register_cvar( "deathrun_shop", "1" );
	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 )
{
	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;
	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 ), "rDeathrun Shop^n^n");
	iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "r1. wSilent Walk - y%d$^n", get_pcvar_num( gSilentCost ) );
	iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "r2. w+150 Health Points - y%d$^n", get_pcvar_num( gHealthCost ) );
	iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "r3. w+150 Armor Points - y%d$^n", get_pcvar_num( gArmorCost ) );
	iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "r4. wFaster Speed r(20 seconds) w- y%d$^n", get_pcvar_num( gSpeedCost ) );
	iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "r5. wGravity r(20 seconds) w- y%d$^n", get_pcvar_num( gGravityCost ) );
	iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "r6. w80(percent) Invisible r(20 seconds) w- y%d$^n^n^n", get_pcvar_num( gInvisCost ) );
	iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "r7. wExit" );
	
	new keys = ( 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6 );
	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( 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 1:
		{
			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, 150 );
			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 2:
		{
			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, 150 );
			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 3:
		{
			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 4:
		{
			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 5:
		{
			if( HasInvis[ id ] )
			{
				allready_have( id );
				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 6:
		{
			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++ )
		{
			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 );
	
		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;
}
Dodać chcę ją do dwóch-trzech bonusów, nie do wszystkich. Tak, aby po zakupie zmieniało przykładowo gravity na xx, po upływie tego czasu zmieniało z powrotem na standardowe.

Pozdrawiam!
  • +
  • -
  • 0

#2 R3X

    Godlike

  • Przyjaciel

Reputacja: 2 987
Godlike

  • Postów:4 248
  • Lokalizacja:Nie
Offline

Napisano 31.08.2009 20:57

Do usunięcia efektu (np. zmiana grawitacji na zwykłą) użyj http://amxx.pl/topic... ... vt5758.htm

Przykład

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "R3X"

new gEfekt1Czas[33];
new gcvarEfekt1Limit;

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	gcvarEfekt1Limit=register_cvar("efekt1_limit","1");
	register_clcmd("say efekt1","cmd_efekt1");
}
public cmd_efekt1(id){
	//aktualny czas
	new iTeraz=get_systime();
	
	//zamień minuty na sekundy
	new iCzas=get_pcvar_num(gcvarEfekt1Limit)*60;
	
	//Oblicz różnicę
	iCzas -= (iTeraz - gEfekt1Czas[id]);
	
	//Gdy mniejsza od 0, wystarczająco długo czekał
	if(iCzas < 0){
		client_print(id, print_chat, "Masz Efekt1!");
		gEfekt1Czas[id]=iTeraz;
		//set_user_gravity(id, 0.5);
		//Usuń Efekt1
		set_task(float(iCzas),"koniecLimitu",id);
	}
	//A gdy nie, to go o tym poinformuj
	else{
		client_print(id, print_chat, "Poczekaj jeszcze %d sekund!", iCzas);
	}
}
public koniecLimitu(id){
	//set_user_gravity(id, 1.0);
	client_print(id, print_chat, "Koniec Efektu1!");
}

  • +
  • -
  • 0

#3 simivar

    Zaawansowany

  • Autor tematu
  • Użytkownik

Reputacja: 26
Życzliwy

  • Postów:106
  • Lokalizacja:aaaaa
Offline

Napisano 31.08.2009 23:27

No tak... tylko, że mówiąc "Przystosowując pewien skrypt do swych wymagań" miałem na myśli: usunąłem kilka bonusów, ile co czego dodaje, ale na PAWNie się totalnie nie znam i z Twojego postu wywnioskowałem tylko to, co jest poniżej: wiem, tylu błędów jeszcze nigdy nie widzieliście :]
/* 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"

#pragma semicolon 1
#define PICKUP_SND	"items/gunpickup2.wav"
#define OFFSET_MONEY	115
#define ADVERTISE_JOIN_TIME 7.0

new gDrShopOn;
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 HasSilent[ 33 ];
new HasHealth[ 33 ];
new HasArmor[ 33 ];
new HasSpeed[ 33 ];
new HasGravity[ 33 ];
new HasInvis[ 33 ];
new bool:bSilent[ 33 ];
new gEfekt1Czas[33];
new gcvarEfekt1Limit; 

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 /shop", "DeathrunShop" );
	register_clcmd( "say_team /shop", "DeathrunShop" );
	register_clcmd( "say shop", "DeathrunShop" );
	register_clcmd( "say_team shop", "DeathrunShop" );
	register_clcmd( "/shop", "DeathrunShop" );
	register_clcmd( "shop", "DeathrunShop" );

	gMenu = register_menuid( "Deathrun Shop" );
	register_menucmd( gMenu, 1023, "menu_shop" );

	gDrShopOn = register_cvar( "deathrun_shop", "1" );
	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" );
	gcvarEfekt1Limit = register_cvar(" efekt1_limit", "20" ); 

	gMsgMoney = get_user_msgid( "Money" );
	gMaxPlayers = get_maxplayers();
	register_dictionary( "deathrunshop.txt" );
}
public plugin_precache()
{
	engfunc( EngFunc_PrecacheSound, PICKUP_SND );
}	
public client_connect( id )
{
	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;
	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 ), "rDeathrun Shop^n^n");
	iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "r1. wSilent Walk - y%d$^n", get_pcvar_num( gSilentCost ) );
	iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "r2. w150 Health Points - y%d$^n", get_pcvar_num( gHealthCost ) );
	iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "r3. w150 Armor Points - y%d$^n", get_pcvar_num( gArmorCost ) );
	iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "r4. wFaster Speed r(20 seconds) w- y%d$^n", get_pcvar_num( gSpeedCost ) );
	iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "r5. wGravity r(20 seconds) w- y%d$^n", get_pcvar_num( gGravityCost ) );
	iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "r6. w80(percent) Invisible r(20 seconds) w- y%d$^n^n^n", get_pcvar_num( gInvisCost ) );
	iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "r7. wExit" );
	
	new keys = ( 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6 );
	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( 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 1:
		{
			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, 150 );
			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 2:
		{
			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, 150 );
			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 3:
		{
			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 ) );
			  new iTeraz=get_systime();
				new iCzas=get_pcvar_num(gcvarEfekt1Limit)*60;
				iCzas -= (iTeraz - gEfekt1Czas[id]);
				if(iCzas < 0){ 
			client_print( id, print_chat, "%L", id, "DRSHOP_SPEED_ITEM" );
			gEfekt1Czas[id]=iTeraz; 
			fm_set_user_money( id, whichmoney - get_pcvar_num( gSpeedCost ) );
			client_sound_play( id );
			HasSpeed[ id ] = true;
			}
			public koniecLimitu(id){
				set_user_maxspeed(id, 600.0);
			client_print(id, print_chat, "[Shop] Speed bonus sie skonczyl!");
			} 
		}
		case 4:
		{
			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 5:
		{
			if( HasInvis[ id ] )
			{
				allready_have( id );
				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 6:
		{
			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++ )
		{
			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 );
	
		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;
}
Patrz linijka 70, 71, 100, 243 - 246, 248, 252-256.
  • +
  • -
  • 0




Użytkownicy przeglądający ten temat: 0

0 użytkowników, 0 gości, 0 anonimowych