Modificare plugin bonus box

Modificari necesare ale pluginurilor

Moderators: Moderatori ajutatori, Moderatori, Echipa eXtreamCS.com

Post Reply
EDwardddd.
Membru, skill +2
Membru, skill +2
Posts: 806
Joined: 18 Jun 2010, 10:30
Detinator Steam: Da
SteamID: edwarddwd
Reputatie: Membru Club eXtreamCS (trei luni)
Fost Moderator ajutator
Nume anterioare: Elk, eDward /R/
Has thanked: 16 times
Been thanked: 49 times

21 May 2013, 13:10

Salut tuturor.

Am pluginul bonus box
| Afiseaza codul
[code]#include < amxmodx >

#include < cstrike >
#include < hamsandwich >

#include < fakemeta >
#include < engine >

#include < fun >
#include < cellarray >
#include < xs >

#pragma semicolon 1


#define PLUGIN "FMU Gifts"
#define VERSION "0.3.2b"

/* --| ColorChat |-- */

enum Color
{
	NORMAL = 1, 		// Culoarea care o are jucatorul setata in cvar-ul scr_concolor.
	GREEN, 			// Culoare Verde.
	TEAM_COLOR, 		// Culoare Rosu, Albastru, Gri.
	GREY, 			// Culoarea Gri.
	RED, 			// Culoarea Rosu.
	BLUE, 			// Culoarea Albastru.
};

new TeamName[  ][  ] = 
{
	"",
	"TERRORIST",
	"CT",
	"SPECTATOR"
};

/* --| ColorChat |-- */


/* Extras din Super Spawns */
#define SS_VERSION	"1.0"
#define SS_MIN_DISTANCE	250.0
#define SS_MAX_LOOPS	100000

new Array:g_vecSsOrigins;
new Array:g_vecSsSpawns;
new Array:g_vecSsUsed;
new Float:g_flSsMinDist;
new g_iSsTime;

new const g_szStarts[][] =
{
	"info_player_start",
	"info_player_deathmatch"
};

new const Float:g_flOffsets[] =
{
	3500.0,
	3500.0,
	1500.0
};

enum
{
	
	GIFT_HP, 
	GIFT_AP,
	GIFT_HP_AP,
	GIFT_MONEY,
	GIFT_HE
	
}

new const g_szFmuGiftsModels[  7  ][   ]  =
{
	
	"models/fmu_gift_cyan.mdl",
	"models/fmu_gift_green.mdl",
	"models/fmu_gift_orange.mdl",
	"models/fmu_gift_pink.mdl",
	"models/fmu_gift_red.mdl",
	"models/fmu_gift_yellow.mdl",
	"models/fmu_gift_random.mdl"
	
};

new const g_iFmuGiftsColors[  7  ][  3  ]  =
{
	{ 0, 255, 255 },
	{ 0, 255, 125 },
	{ 255, 125, 65 },
	{ 255, 0, 125 },
	{ 255, 25, 25 },
	{ 255, 255, 0 },
	{ 255, 255, 255 }
};


new const g_szFmuGiftClassName[    ]  =  "fmu_gift";
new const FMU_TAG[    ]  =  "[Furien Gifts]";

// Floats
new Float:fMaxs[ 3 ]  =  {  13.0, 13.0, 35.0  };
new Float:fMins[ 3 ]  =  {  -13.0, -13.0, 0.0  };

new gCvarGiftHP;
new gCvarGiftAP;
new gCvarGiftMoney;

new gCvarEnableRespawn;
new gCvarRespawnTime;
new gCvarGiftsNum;

public plugin_precache(    )
{
	
	for( new i = 0; i < 7; i++ )
	{
		precache_model( g_szFmuGiftsModels[ i ] );
	}
	
}
		
public plugin_init( )
{
	//Autor original al plugin-ului: KronoS .
	//Am pornit acest plugin pe baza plugin`ului facut de el.
	register_plugin( PLUGIN, VERSION, "Askhanar" );
	
	gCvarGiftHP = register_cvar( "fmu_gifts_hp", "25" );
	gCvarGiftAP = register_cvar( "fmu_gifts_ap", "25" );
	gCvarGiftMoney = register_cvar( "fmu_gifts_money", "5500" );
	
	gCvarEnableRespawn = register_cvar( "fmu_enable_giftsrespawn", "1" );
	gCvarRespawnTime = register_cvar( "fmu_gifts_respawntime", "45" );
	gCvarGiftsNum = register_cvar( "fmu_gifts_num", "35" );
	
	register_clcmd( "amx_reloadgifts", "ClCmdReloadGifts" );
	register_touch( g_szFmuGiftClassName, "player", "FwdPlayerTouchGift" );
	
	SsInit(800.0);
	SsScan();
	
	LoadAllGifts( );
}

public ClCmdReloadGifts( id )
{
	if( !( get_user_flags( id ) & ADMIN_CFG ) )
		return 1;
		
	SsClean();
	SsInit(800.0);
	SsScan();
	
	new iFoundEntity;

	while ( ( iFoundEntity = find_ent_by_class(  iFoundEntity, g_szFmuGiftClassName  ) )  !=  0  )
	{
		engfunc( EngFunc_RemoveEntity, iFoundEntity );
	}
	
	LoadAllGifts( );
	
	new szName[ 32 ];
	get_user_name( id, szName, sizeof ( szName ) -1 );
	ColorChat( 0, RED, "^x04%s^x01 Adminul^x03 %s^x01 a reincarcat toate cadourile de pe harta!", FMU_TAG, szName );
	return 1;
}

public FwdPlayerTouchGift(  const iEnt, const id  )
{
	
	if( is_valid_ent(  iEnt  )  && ( 1 <= id <= 32 ) &&  is_user_alive(  id  )  )
	{
		
		if( get_pcvar_num( gCvarEnableRespawn ) )
		{
			new iParm[ 3 ];
			new Float:flOrigin[ 3 ], iOrigin[ 3 ];
			
			entity_get_vector( iEnt, EV_VEC_origin, flOrigin );
			
			FVecIVec( flOrigin, iOrigin );
			iParm[ 0 ] = iOrigin[ 0 ];
			iParm[ 1 ] = iOrigin[ 1 ];
			iParm[ 2 ] = iOrigin[ 2 ];
			
			set_task( float( get_pcvar_num( gCvarRespawnTime ) ), "Respawn_Entity", _, iParm, 3 );
			
		}
		
		
		new iRandomGift = random_num( GIFT_HP, GIFT_HE );
		while(  iRandomGift  ==  GIFT_HE   &&  user_has_weapon(  id,  CSW_HEGRENADE  )  )
			iRandomGift = random_num( GIFT_HP, GIFT_HE );
			
		GivePlayerGift( id, iRandomGift );
		remove_entity( iEnt  );
		
	}
	
	return 0;
}

public GivePlayerGift(  id, const  iGiftType  )
{
	
	switch(  iGiftType  )
	{
		
		case GIFT_HP:
		{
			set_user_health(  id,  get_user_health(  id  )  +  get_pcvar_num( gCvarGiftHP )  );
			ColorChat(  id, RED,  "^x04%s^x01 Mosul ti-a oferit cadou^x03 %i HP^x01!",  FMU_TAG, get_pcvar_num( gCvarGiftHP )  );
			
		}
		case GIFT_AP:
		{
			set_user_armor(  id,  get_user_armor(  id  )  +  get_pcvar_num( gCvarGiftAP ) );
			ColorChat(  id, RED,  "^x04%s^x01 Mosul ti-a oferit cadou^x03 %i AP^x01!",  FMU_TAG, get_pcvar_num( gCvarGiftAP )  );
			
		}
		case GIFT_HP_AP:
		{
			static iHP;
			iHP = get_pcvar_num( gCvarGiftHP );
			static iAP;
			iAP = get_pcvar_num( gCvarGiftAP );
			set_user_health(  id,  get_user_health(  id  )  +  iHP  );
			set_user_armor(  id,  get_user_armor(  id  )  +  iAP  );
			
			ColorChat(  id, RED,  "^x04%s^x01 Mosul ti-a oferit cadou^x03 %i HP^x01 si^x03 %i AP^x01!",  FMU_TAG, iHP, iAP );
		}
		case GIFT_MONEY:
		{
			cs_set_user_money(  id,  clamp(  cs_get_user_money(  id  )  +  get_pcvar_num( gCvarGiftMoney ), 0, 16000  )  );
			ColorChat(  id, RED,  "^x04%s^x01 Mosul ti-a oferit cadou^x03 %i$^x01!",  FMU_TAG, get_pcvar_num( gCvarGiftMoney ) );
		}
		case GIFT_HE:
		{
			
			give_item(  id,  "weapon_hegrenade"  );
			ColorChat(  id, RED,  "^x04%s^x01 Mosul ti-a oferit cadou un^x03 HE^x01!",  FMU_TAG  );
			
		}
		
	}
}

public Respawn_Entity( iParm[ ] )
{
	new Float:flOrigin[ 3 ], iOrigin[ 3 ];
	
	iOrigin[ 0 ] = iParm[ 0 ];
	iOrigin[ 1 ] = iParm[ 1 ];
	iOrigin[ 2 ] = iParm[ 2 ];
	
	IVecFVec( iOrigin, flOrigin );
	CreateGift(  flOrigin );
	
	return 0;
}
	
public CreateGift(  const Float:fOrigin[ 3 ] )
{
	
	new iEnt = create_entity( "info_target" );
	if ( !is_valid_ent(iEnt) ) return 0;
	
	new iRandom = random_num( 0, 6 );
	
	entity_set_string(  iEnt, EV_SZ_classname, g_szFmuGiftClassName  );
	entity_set_origin(  iEnt, fOrigin  );
	entity_set_model(  iEnt, g_szFmuGiftsModels[  iRandom  ]  );
	entity_set_int(  iEnt, EV_INT_movetype, MOVETYPE_NONE  );
	entity_set_int(  iEnt, EV_INT_solid, SOLID_BBOX );
	entity_set_size(  iEnt, fMins, fMaxs  );
	
	set_rendering( iEnt,
			kRenderFxGlowShell,
			g_iFmuGiftsColors[ iRandom ][ 0 ],
			g_iFmuGiftsColors[ iRandom ][ 1 ],
			g_iFmuGiftsColors[ iRandom ][ 2 ],
			kRenderNormal,
			255 );
	
	drop_to_floor(  iEnt  );
	
	return 1;
}

public LoadAllGifts( )
{
	
	new Float:fOrigin[ 3 ];
	
	for( new i = 1; i <= get_pcvar_num( gCvarGiftsNum ); i++ )
		if( SsGetOrigin( fOrigin ) )
			CreateGift( fOrigin );
	
		
}


/*====================================
========Inceput Super Spawns========*/

public SsInit(Float:mindist)
{
	
	register_cvar("sv_superspawns", SS_VERSION, (FCVAR_SERVER|FCVAR_SPONLY));
	register_concmd("_ss_dump", "SsDump");

	g_flSsMinDist = mindist;
	g_vecSsOrigins = ArrayCreate(3, 1);
	g_vecSsSpawns = ArrayCreate(3, 1);
	g_vecSsUsed = ArrayCreate(3, 1);
}

stock SsClean()
{
	g_flSsMinDist = 0.0;
	ArrayClear(g_vecSsOrigins);
	ArrayClear(g_vecSsSpawns);
	ArrayClear(g_vecSsUsed);
}

stock SsGetOrigin(Float:origin[3])
{
	new Float:data[3], size;
	new ok = 1;

	while((size = ArraySize(g_vecSsOrigins)))
	{
		new idx = random_num(0, size - 1);

		ArrayGetArray(g_vecSsOrigins, idx, origin);

		new used = ArraySize(g_vecSsUsed);
		for(new i = 0; i < used; i++)
		{
			ok = 0;
			ArrayGetArray(g_vecSsUsed, i, data);
			if(get_distance_f(data, origin) >= g_flSsMinDist)
			{
				ok = 1;
				break;
			}
		}

		ArrayDeleteItem(g_vecSsOrigins, idx);
		if(ok)
		{
			ArrayPushArray(g_vecSsUsed, origin);
			return true;
		}
	}
	return false;
}

public SsDump()
{
	new Float:origin[3];
	new count = ArraySize(g_vecSsOrigins);
	server_print("-------------------------------------------------------");
	for(new i = 0; i < count; i++)
	{
		ArrayGetArray(g_vecSsOrigins, i, origin);
		server_print("Origin: %f %f %f", origin[0], origin[1], origin[2]);
	}
	server_print("-------------------------------------------------------");
	server_print("Number of origins: %i", count);
	server_print("Time: %i", g_iSsTime);
	server_print("-------------------------------------------------------");
}

public SsScan()
{
	new start, Float:origin[3], starttime;
	starttime = get_systime();
	for(start = 0; start < sizeof(g_szStarts); start++)
	{
		server_print("Searching for %s", g_szStarts[start]);
		new ent;
		if((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", g_szStarts[start])))
		{
			new counter;
			pev(ent, pev_origin, origin);
			ArrayPushArray(g_vecSsSpawns, origin);
			while(counter < SS_MAX_LOOPS)
			{
				counter = GetLocation(origin, counter);
			}
		}
	}
	g_iSsTime = get_systime();
	g_iSsTime -= starttime;
}

GetLocation(Float:start[3], &counter)
{
	new Float:end[3];
	for(new i = 0; i < 3; i++)
	{
		end += random_float(0.0 - g_flOffsets, g_flOffsets);
	}

	if(IsValid(start, end))
	{
		start[0] = end[0];
		start[1] = end[1];
		start[2] = end[2];
		ArrayPushArray(g_vecSsOrigins, end);
	}
	counter++;
	return counter;
}

IsValid(Float:start[3], Float:end[3])
{
	SetFloor(end);
	end[2] += 36.0;
	new point = engfunc(EngFunc_PointContents, end);
	if(point == CONTENTS_EMPTY)
	{
		if(CheckPoints(end) && CheckDistance(end) && CheckVisibility(start, end))
		{
			if(!trace_hull(end, HULL_LARGE, -1))
			{
				return true;
			}
		}
	}
	return false;
}

CheckVisibility(Float:start[3], Float:end[3])
{
	new tr;
	engfunc(EngFunc_TraceLine, start, end, IGNORE_GLASS, -1, tr);
	return (get_tr2(tr, TR_pHit) < 0);
}

SetFloor(Float:start[3])
{
	new tr, Float:end[3];
	end[0] = start[0];
	end[1] = start[1];
	end[2] = -99999.9;
	engfunc(EngFunc_TraceLine, start, end, DONT_IGNORE_MONSTERS, -1, tr);
	get_tr2(tr, TR_vecEndPos, start);
}

CheckPoints(Float:origin[3])
{
	new Float:data[3], tr, point;
	data[0] = origin[0];
	data[1] = origin[1];
	data[2] = 99999.9;
	engfunc(EngFunc_TraceLine, origin, data, DONT_IGNORE_MONSTERS, -1, tr);
	get_tr2(tr, TR_vecEndPos, data);
	point = engfunc(EngFunc_PointContents, data);
	if(point == CONTENTS_SKY && get_distance_f(origin, data) < 250.0)
	{
		return false;
	}
	data[2] = -99999.9;
	engfunc(EngFunc_TraceLine, origin, data, DONT_IGNORE_MONSTERS, -1, tr);
	get_tr2(tr, TR_vecEndPos, data);
	point = engfunc(EngFunc_PointContents, data);
	if(point < CONTENTS_SOLID)
		return false;
	
	return true;
}

CheckDistance(Float:origin[3])
{
	new Float:dist, Float:data[3];
	new count = ArraySize(g_vecSsSpawns);
	for(new i = 0; i < count; i++)
	{
		ArrayGetArray(g_vecSsSpawns, i, data);
		dist = get_distance_f(origin, data);
		if(dist < SS_MIN_DISTANCE)
			return false;
	}

	count = ArraySize(g_vecSsOrigins);
	for(new i = 0; i < count; i++)
	{
		ArrayGetArray(g_vecSsOrigins, i, data);
		dist = get_distance_f(origin, data);
		if(dist < SS_MIN_DISTANCE)
			return false;
	}

	return true;
}

/*====================================
========Sfarsit Super Spawns========*/


/* --| ColorChat |-- */

ColorChat(  id, Color:iType, const msg[  ], { Float, Sql, Result, _}:...  )
{
	
	// Daca nu se afla nici un jucator pe server oprim TOT. Altfel dam de erori..
	if( !get_playersnum( ) ) return;
	
	new szMessage[ 256 ];

	switch( iType )
	{
		 // Culoarea care o are jucatorul setata in cvar-ul scr_concolor.
		case NORMAL:	szMessage[ 0 ] = 0x01;
		
		// Culoare Verde.
		case GREEN:	szMessage[ 0 ] = 0x04;
		
		// Alb, Rosu, Albastru.
		default: 	szMessage[ 0 ] = 0x03;
	}

	vformat(  szMessage[ 1 ], 251, msg, 4  );

	// Ne asiguram ca mesajul nu este mai lung de 192 de caractere.Altfel pica server-ul.
	szMessage[ 192 ] = '^0';
	

	new iTeam, iColorChange, iPlayerIndex, MSG_Type;
	
	if( id )
	{
		MSG_Type  =  MSG_ONE_UNRELIABLE;
		iPlayerIndex  =  id;
	}
	else
	{
		iPlayerIndex  =  CC_FindPlayer(  );
		MSG_Type = MSG_ALL;
	}
	
	iTeam  =  get_user_team( iPlayerIndex );
	iColorChange  =  CC_ColorSelection(  iPlayerIndex,  MSG_Type, iType);

	CC_ShowColorMessage(  iPlayerIndex, MSG_Type, szMessage  );
		
	if(  iColorChange  )	CC_Team_Info(  iPlayerIndex, MSG_Type,  TeamName[ iTeam ]  );

}

CC_ShowColorMessage(  id, const iType, const szMessage[  ]  )
{
	
	static bool:bSayTextUsed;
	static iMsgSayText;
	
	if(  !bSayTextUsed  )
	{
		iMsgSayText  =  get_user_msgid( "SayText" );
		bSayTextUsed  =  true;
	}
	
	message_begin( iType, iMsgSayText, _, id  );
	write_byte(  id  );		
	write_string(  szMessage  );
	message_end(  );
}

CC_Team_Info( id, const iType, const szTeam[  ] )
{
	static bool:bTeamInfoUsed;
	static iMsgTeamInfo;
	if(  !bTeamInfoUsed  )
	{
		iMsgTeamInfo  =  get_user_msgid( "TeamInfo" );
		bTeamInfoUsed  =  true;
	}
	
	message_begin( iType, iMsgTeamInfo, _, id  );
	write_byte(  id  );
	write_string(  szTeam  );
	message_end(  );

	return 1;
}

CC_ColorSelection(  id, const iType, Color:iColorType)
{
	switch(  iColorType  )
	{
		
		case RED:	return CC_Team_Info(  id, iType, TeamName[ 1 ]  );
		case BLUE:	return CC_Team_Info(  id, iType, TeamName[ 2 ]  );
		case GREY:	return CC_Team_Info(  id, iType, TeamName[ 0 ]  );

	}

	return 0;
}

CC_FindPlayer(  )
{
	new iMaxPlayers  =  get_maxplayers(  );
	
	for( new i = 1; i <= iMaxPlayers; i++ )
		if(  is_user_connected( i )  )
			return i;
	
	return -1;
}

/* --| ColorChat |-- */[/code]


,dar as vrea sa mi-l modifice cineva astfel incat sa fie pentru modul DeathRun si sa setez eu pe harta unde vreau cadourile .. stie cineva?
RoyalServer
User avatar
Nubo
Fost moderator
Fost moderator
Posts: 2734
Joined: 11 Jul 2012, 18:45
Detinator Steam: Da
CS Status: [əˈnɒn.ɪ.məs]
Reputatie: Fost scripter eXtreamCS
Fost eXtream Mod
Has thanked: 8 times
Been thanked: 27 times

21 May 2013, 13:16

Iti pare sa fie scris aici "Cereri"??
Cand nu merge acest forum sunt online aici:
  • * Skype: nubo_cs
    * Y!M ID: nubo_cs
EDwardddd.
Membru, skill +2
Membru, skill +2
Posts: 806
Joined: 18 Jun 2010, 10:30
Detinator Steam: Da
SteamID: edwarddwd
Reputatie: Membru Club eXtreamCS (trei luni)
Fost Moderator ajutator
Nume anterioare: Elk, eDward /R/
Has thanked: 16 times
Been thanked: 49 times

21 May 2013, 13:27

Aolo , nu am fost atent , imi cer scuze :|

Poate sa mute un moderator topicu` ?
Mersi..
User avatar
CryWolf
Administrator
Administrator
Posts: 6505
Joined: 07 Aug 2008, 16:33
Detinator Steam: Da
Reputatie: Administrator
Fost Scripter
Manager CS2.eXtream.Ro
Fost Detinator ZM.eXtream.Ro
Fost manager CS.eXtream.Ro
Fost manager CSGO.eXtream.Ro
Fost manager global
Location: Botosani
Discord: crywolf1989
Has thanked: 202 times
Been thanked: 850 times
Contact:

21 May 2013, 13:32

O sa mai repet o data care e treaba cu categoria pluginuri/cereri si programare pluginuri unde am mutat eu pluginul.

PLUGINURI/CERERI - Se poateaza o cerere de plugin inexistent
PROGRAMARE/PLUGINURI - Se poateaza o cerere de modificare a unui plugin deja existent.

Mutat!
NU IMI MAI DA-TI PM CU CERERE AJUTOR/SAMD, FOLOSITI FORUMUL, CITESC MAJORITATEA TOPICURILOR.
www.dark-arena.com , SERVERE CS / CS2 / L4D AU REVENIT ONLINE.
www.diasporaiptv.ro - SERVICII PREMIUM IPTV

Image

Image
EDwardddd.
Membru, skill +2
Membru, skill +2
Posts: 806
Joined: 18 Jun 2010, 10:30
Detinator Steam: Da
SteamID: edwarddwd
Reputatie: Membru Club eXtreamCS (trei luni)
Fost Moderator ajutator
Nume anterioare: Elk, eDward /R/
Has thanked: 16 times
Been thanked: 49 times

21 May 2013, 13:45

Multumesc CryWolf

Inca astept modificare plugin-ului , cine ma poate ajuta :D
EDwardddd.
Membru, skill +2
Membru, skill +2
Posts: 806
Joined: 18 Jun 2010, 10:30
Detinator Steam: Da
SteamID: edwarddwd
Reputatie: Membru Club eXtreamCS (trei luni)
Fost Moderator ajutator
Nume anterioare: Elk, eDward /R/
Has thanked: 16 times
Been thanked: 49 times

24 May 2013, 17:36

UP!

Nu ma poate ajuta nimeni ? :(
User avatar
sDs|Aragon*
Membru, skill +2
Membru, skill +2
Posts: 576
Joined: 29 Dec 2011, 21:38
Detinator Steam: Da
SteamID: Mihai_Parkour10
Reputatie: Fost scripter eXtreamCS
Has thanked: 4 times
Been thanked: 132 times

29 May 2013, 09:33

Seteaza amx_bonusbox_after_die pe 0
Creeaza un folder cu numele BonusBox in config.
Baga acest plugin, dupa care scrii /bonusbox si iti salvezi originile unde vrei sa iti apara cadouri in fiecare runda.
| Afiseaza codul
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <fakemeta>
#include <fakemeta_util>

#define PLUGIN "Bonus Box"
#define VERSION "3.0"
#define AUTHOR "Aragon*"

#define BONUSBOX_MAX 40

new const BonusBox_RoundStart_ClassName[] = "RS_BonusBox"
new const BonusBox_Death_ClassName[] = "Death_BonusBox"

new const SpawnBoxSound[] = "BonusBoxSpawn.wav"
new const TakeBoxSound[] = "BonusBoxGet.wav"

new Menu, File[78], TotalBox = 0, Float:BoxData[BONUSBOX_MAX + 1][3];
new bonusbox_rs, bonusbox_die
new Model[3][] = {
	"models/bonusbox.mdl",
	"models/bonusbox_t.mdl",
	"models/bonusbox_ct.mdl"
}

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	register_concmd("bonusbox","CMD_BonusBoxMenu", ADMIN_CVAR) 	
	register_concmd("say bonusbox","CMD_BonusBoxMenu", ADMIN_CVAR) 	
	register_concmd("say /bonusbox","CMD_BonusBoxMenu", ADMIN_CVAR) 	
	register_concmd("say_team bonusbox","CMD_BonusBoxMenu", ADMIN_CVAR) 	
	register_concmd("say_team /bonusbox","CMD_BonusBoxMenu", ADMIN_CVAR) 	
	register_forward(FM_Touch, "BonusBox_Touch")
	register_think(BonusBox_RoundStart_ClassName,"BonusBox_Think") 
	register_think(BonusBox_Death_ClassName,"BonusBox_Think2") 
	register_event("DeathMsg", "EVENT_Death", "a")
	register_logevent("LOGEVENT_RoundStart",2,"1=Round_Start")
	
	bonusbox_rs = register_cvar("amx_bonusbox_round_start", "1")
	bonusbox_die = register_cvar("amx_bonusbox_after_die", "1")
	
	new CfgDir[32], MapName[32];
	get_configsdir(CfgDir, charsmax(CfgDir));
	get_mapname(MapName,31) 
	formatex(File, charsmax(File), "%s/BonusBox/%s.cfg", CfgDir, MapName);
	
	LoadOrigins() 
}

public plugin_precache() {
	for (new i = 0; i < sizeof Model; i++)
		precache_model(Model)
	precache_sound(SpawnBoxSound) 
	precache_sound(TakeBoxSound) 
}

public CMD_BonusBoxMenu(id) { 
	Menu = menu_create("\rBonusBox Menu", "BonusBoxMenuCmd");
	
	menu_additem(Menu, "\yAdd Box", "1", 0);
	menu_additem(Menu, "\yDelete All Box", "2", 0);
	menu_additem(Menu, "\yReload Box Origins", "3", 0);
	
	menu_setprop(Menu, MPROP_EXIT, MEXIT_ALL);
	menu_display(id, Menu, 0);
	return PLUGIN_CONTINUE;
}

public BonusBoxMenuCmd(id, menu, item) {
	if (item == MENU_EXIT) {
		menu_destroy(menu);
		return PLUGIN_HANDLED;
	}
	new data[6], iName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
	new key = str_to_num(data);
	switch(key) {
		case 1: SaveOrigin(id)
			
		case 2: DeleteBoxes()
			
		case 3: LoadOrigins()
			
		default: return PLUGIN_HANDLED;
	}
	menu_destroy(menu);
	return PLUGIN_HANDLED;
}

public LOGEVENT_RoundStart()  {
	remove_entity_name(BonusBox_RoundStart_ClassName) 
	remove_entity_name(BonusBox_Death_ClassName) 
	if(get_pcvar_num(bonusbox_rs)) {
		LoadOrigins() 
		new Spawned = TotalBox
		for(new i = 1; i <= Spawned; i++) {
			new Box = create_entity("info_target") 
			set_pev(Box, pev_classname, BonusBox_RoundStart_ClassName)
			engfunc(EngFunc_SetModel, Box, Model[0]) 
			engfunc(EngFunc_SetSize, Box, Float:{-10.0,-10.0,0.0},Float:{10.0,10.0,20.0})
			
			set_pev(Box, pev_gravity, 1.0)
			set_pev(Box, pev_origin, BoxData[TotalBox])
			set_pev(Box, pev_solid, SOLID_BBOX)
			set_pev(Box, pev_movetype, MOVETYPE_NONE)
			set_pev(Box, pev_nextthink, halflife_time() + 0.01)
			emit_sound(Box, CHAN_AUTO,SpawnBoxSound,VOL_NORM,ATTN_NORM,0,PITCH_NORM) 
			TotalBox--
		}
	}
} 

public EVENT_Death() {
	new victim = read_data(2);
	if(is_user_connected(victim) && cs_get_user_team(victim) != CS_TEAM_SPECTATOR && get_pcvar_num(bonusbox_die)) {
		new Float:Origin[3];
		pev(victim, pev_origin, Origin);
		
		new Box = create_entity("info_target") 
		set_pev(Box, pev_classname, BonusBox_Death_ClassName)
		switch(cs_get_user_team(victim)) {
			case CS_TEAM_T: { 
				engfunc(EngFunc_SetModel, Box, Model[2])
				set_pev(Box, pev_team, 2)
			}
			
			case CS_TEAM_CT: {
				engfunc(EngFunc_SetModel, Box, Model[1])	
				set_pev(Box, pev_team, 1)
			}
		}
		engfunc(EngFunc_SetSize, Box, Float:{-10.0, -10.0, -25.0},Float:{10.0, 10.0, 25.0})
		set_pev(Box, pev_gravity, 1.0)
		set_pev(Box, pev_origin, Origin)
		set_pev(Box, pev_solid, SOLID_BBOX)
		set_pev(Box, pev_animtime, get_gametime())
		set_pev(Box, pev_framerate,1.0)
		set_pev(Box, pev_movetype, MOVETYPE_NONE)
		set_pev(Box, pev_nextthink, get_gametime() + 0.01)
	}
}

public BonusBox_Touch(toucher, touched) {
	if (!is_user_alive(toucher) || !is_user_connected(toucher) || !pev_valid(touched))
		return FMRES_IGNORED
	
	new classname[32]	
	pev(touched, pev_classname, classname, 31)
	if (equal(classname, BonusBox_RoundStart_ClassName)) {
		BonusBox_GiveBonus(toucher, 0)
		emit_sound(touched,CHAN_AUTO,TakeBoxSound,VOL_NORM,ATTN_NORM,0,PITCH_NORM) 
		remove_entity(touched);
	}
	if (equal(classname, BonusBox_Death_ClassName) && get_user_team(toucher) == pev(touched, pev_team)) {	
		BonusBox_GiveBonus(toucher, 1)
		emit_sound(touched,CHAN_AUTO,TakeBoxSound,VOL_NORM,ATTN_NORM,0,PITCH_NORM) 
		set_pev(touched, pev_effects, EF_NODRAW)
		set_pev(touched, pev_solid, SOLID_NOT)
		remove_entity(touched);
	}
	return FMRES_IGNORED
	
}

public BonusBox_Think(entity) { 
	Light(entity, 4, 255, 100, 015)	
	set_pev(entity, pev_nextthink, get_gametime() + 0.01)
} 

public BonusBox_Think2(entity) { 
	switch(pev(entity, pev_team)) {
		case 1: { 
			Light(entity, 3, 200, 0, 0)
			
		}	
		case 2: { 
			Light(entity, 3, 0, 0, 200)
		}
	}
	set_pev(entity, pev_nextthink, get_gametime() + 0.01)
} 

public BonusBox_GiveBonus(id, type) {
	if(type) {
		switch (random_num(1,5)) {
			case 1: {
				if(!cs_get_user_nvg(id)) {
					cs_set_user_nvg(id, 1)
					ColorChat(id, "!t[Bonus Box]!g Ai primit un!t NightVision.")
				}
				else BonusBox_GiveBonus(id, 0)
			}	
			case 2: {
				new Health = random_num(50, 150)
				fm_set_user_health(id, get_user_health(id) + Health)
				ColorChat(id, "!t[Bonus Box]!g Ai primit!t %d HP.", Health)
			}
			case 3: {
				new Armor = random_num(50, 150)
				cs_set_user_armor(id, get_user_armor(id) + Armor, CS_ARMOR_VESTHELM)
				ColorChat(id, "!t[Bonus Box]!g Ai primit!t %d AP.", Armor)
			}
			case 4: {
				new Money = random_num(3000, 6000)
				cs_set_user_money(id, cs_get_user_money(id) + Money)
				ColorChat(id, "!t[Bonus Box]!g Ai primit!t %d$", Money)
			}
			case 5: {
				if(!user_has_weapon(id, CSW_HEGRENADE)) {
					fm_give_item(id, "weapon_hegrenade")
				}
				else {
					cs_set_user_bpammo(id, CSW_HEGRENADE, cs_get_user_bpammo(id, CSW_HEGRENADE) + 1);
				}
				
				if(!user_has_weapon(id, CSW_FLASHBANG)) {
					fm_give_item(id, "weapon_flashbang")
				}
				else {
					cs_set_user_bpammo(id, CSW_FLASHBANG, cs_get_user_bpammo(id, CSW_FLASHBANG) + 1);
				}
				
				if(!user_has_weapon(id, CSW_SMOKEGRENADE)) {
					fm_give_item(id, "weapon_smokegrenade")
				}
				else {
					cs_set_user_bpammo(id, CSW_SMOKEGRENADE, cs_get_user_bpammo(id, CSW_SMOKEGRENADE) + 1);
				}	
				ColorChat(id, "!t[Bonus Box]!g Ai primit un!t Pachet de Grenazi")
			}
		}
		
	}
	else {
		switch (random_num(1,5)) {
			case 1: {
				if(!cs_get_user_nvg(id)) {
					cs_set_user_nvg(id, 1)
					ColorChat(id, "!t[Bonus Box]!g Ai primit un!t NightVision.")
				}
				else BonusBox_GiveBonus(id, 0)
			}
			
			
			case 2: {
				new Health = random_num(100, 150)
				fm_set_user_health(id, get_user_health(id) + Health)
				ColorChat(id, "!t[Bonus Box]!g Ai primit!t %d HP.", Health)
			}
			case 3: {
				new Armor = random_num(100, 150)
				cs_set_user_armor(id, get_user_armor(id) + Armor, CS_ARMOR_VESTHELM)
				ColorChat(id, "!t[Bonus Box]!g Ai primit!t %d AP.", Armor)
			}
			case 4: {
				new Money = random_num(5000, 6000)
				cs_set_user_money(id, cs_get_user_money(id) + Money)
				ColorChat(id, "!t[Bonus Box]!g Ai primit!t %d$", Money)
			}
			case 5: {
				if(!user_has_weapon(id, CSW_HEGRENADE)) {
					fm_give_item(id, "weapon_hegrenade")
				}
				else {
					cs_set_user_bpammo(id, CSW_HEGRENADE, cs_get_user_bpammo(id, CSW_HEGRENADE) + 1);
				}
				
				if(!user_has_weapon(id, CSW_FLASHBANG)) {
					fm_give_item(id, "weapon_flashbang")
				}
				else {
					cs_set_user_bpammo(id, CSW_FLASHBANG, cs_get_user_bpammo(id, CSW_FLASHBANG) + 1);
				}
				
				if(!user_has_weapon(id, CSW_SMOKEGRENADE)) {
					fm_give_item(id, "weapon_smokegrenade")
				}
				else {
					cs_set_user_bpammo(id, CSW_SMOKEGRENADE, cs_get_user_bpammo(id, CSW_SMOKEGRENADE) + 1);
				}	
				ColorChat(id, "!t[Bonus Box]!g Ai primit un!t Pachet de Grenazi")
			}
		}
	}
}

public Light(entity, radius, red, green, blue) {	
	if(is_valid_ent(entity)) {
		static Float:origin[3]
		pev(entity, pev_origin, origin)
		
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY, _, entity);
		write_byte(TE_DLIGHT) // TE id
		engfunc(EngFunc_WriteCoord, origin[0])
		engfunc(EngFunc_WriteCoord, origin[1])
		engfunc(EngFunc_WriteCoord, origin[2])
		write_byte(radius) 
		write_byte(red)
		write_byte(green)
		write_byte(blue)
		write_byte(1)
		write_byte(0)
		message_end();
	}
}

public SaveOrigin(id) { 
	new Float:Origin[3];
	pev(id, pev_origin, Origin);
	
	
	static save, buffer[128]
	save = fopen(File,"at") 
	
	formatex(buffer, charsmax(buffer), "%f %f %f^n", Origin[0], Origin[1], Origin[2])
	client_print(id,print_center,"BonusBox successfully added.",Origin[0],Origin[1],Origin[2]) 
	fputs(save, buffer)
	
	TotalBox++
	
	BoxData[TotalBox][0] = Origin[0]
	BoxData[TotalBox][1] = Origin[1]
	BoxData[TotalBox][2] = Origin[2]
	
	
	fclose(save)		
	LoadOrigins() 
} 

public DeleteBoxes() {
	remove_entity_name(BonusBox_RoundStart_ClassName) 
	for(new i = 0; i > TotalBox; i++) {
		BoxData[TotalBox][0] = 0.0
		BoxData[TotalBox][1] = 0.0
		BoxData[TotalBox][2] = 0.0
		
		TotalBox --
	}
	LoadOrigins() 
	delete_file(File)
}

public LoadOrigins() { 
	TotalBox = 0 
	
	new buffer[128], x[12],y[12],z[12] 
	if(file_exists(File)) { 
		new save = fopen(File,"rt") 
		
		if(!save) return 
		
		while(!feof(save)) { 
			fgets(save,buffer,127) 
			
			if(buffer[0] == ';' || !buffer[0]) continue 
			
			parse(buffer, x,11, y,11, z,11) 
			
			BoxData[TotalBox][0] = str_to_float(x) 
			BoxData[TotalBox][1] = str_to_float(y) 
			BoxData[TotalBox][2] = str_to_float(z) 
			
			TotalBox++ 
		} 
		
		fclose(save) 
	}     
} 

stock ColorChat(const id, const input[], any:...) {
	new count = 1, players[32];
	static msg[191];
	vformat(msg, 190, input, 3);
	
	replace_all(msg, 190, "!g", "^4");
	replace_all(msg, 190, "!y", "^1");
	replace_all(msg, 190, "!t", "^3");
	
	if(id) players[0] = id;
	else get_players(players, count, "ch"); {
		for(new i = 0; i < count; i++) {
			if(is_user_connected(players)) {
				message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players);
				write_byte(players);
				write_string(msg);
				message_end();
			}
		}
	} 
}


Edit: Link Resurse: http://www.girlshare.ro/32546232.4
EDwardddd.
Membru, skill +2
Membru, skill +2
Posts: 806
Joined: 18 Jun 2010, 10:30
Detinator Steam: Da
SteamID: edwarddwd
Reputatie: Membru Club eXtreamCS (trei luni)
Fost Moderator ajutator
Nume anterioare: Elk, eDward /R/
Has thanked: 16 times
Been thanked: 49 times

31 May 2013, 01:35

sDs|Aragon* wrote:Seteaza amx_bonusbox_after_die pe 0
Creeaza un folder cu numele BonusBox in config.
Baga acest plugin, dupa care scrii /bonusbox si iti salvezi originile unde vrei sa iti apara cadouri in fiecare runda.
| Afiseaza codul
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <fakemeta>
#include <fakemeta_util>

#define PLUGIN "Bonus Box"
#define VERSION "3.0"
#define AUTHOR "Aragon*"

#define BONUSBOX_MAX 40

new const BonusBox_RoundStart_ClassName[] = "RS_BonusBox"
new const BonusBox_Death_ClassName[] = "Death_BonusBox"

new const SpawnBoxSound[] = "BonusBoxSpawn.wav"
new const TakeBoxSound[] = "BonusBoxGet.wav"

new Menu, File[78], TotalBox = 0, Float:BoxData[BONUSBOX_MAX + 1][3];
new bonusbox_rs, bonusbox_die
new Model[3][] = {
	"models/bonusbox.mdl",
	"models/bonusbox_t.mdl",
	"models/bonusbox_ct.mdl"
}

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	register_concmd("bonusbox","CMD_BonusBoxMenu", ADMIN_CVAR) 	
	register_concmd("say bonusbox","CMD_BonusBoxMenu", ADMIN_CVAR) 	
	register_concmd("say /bonusbox","CMD_BonusBoxMenu", ADMIN_CVAR) 	
	register_concmd("say_team bonusbox","CMD_BonusBoxMenu", ADMIN_CVAR) 	
	register_concmd("say_team /bonusbox","CMD_BonusBoxMenu", ADMIN_CVAR) 	
	register_forward(FM_Touch, "BonusBox_Touch")
	register_think(BonusBox_RoundStart_ClassName,"BonusBox_Think") 
	register_think(BonusBox_Death_ClassName,"BonusBox_Think2") 
	register_event("DeathMsg", "EVENT_Death", "a")
	register_logevent("LOGEVENT_RoundStart",2,"1=Round_Start")
	
	bonusbox_rs = register_cvar("amx_bonusbox_round_start", "1")
	bonusbox_die = register_cvar("amx_bonusbox_after_die", "1")
	
	new CfgDir[32], MapName[32];
	get_configsdir(CfgDir, charsmax(CfgDir));
	get_mapname(MapName,31) 
	formatex(File, charsmax(File), "%s/BonusBox/%s.cfg", CfgDir, MapName);
	
	LoadOrigins() 
}

public plugin_precache() {
	for (new i = 0; i < sizeof Model; i++)
		precache_model(Model)
	precache_sound(SpawnBoxSound) 
	precache_sound(TakeBoxSound) 
}

public CMD_BonusBoxMenu(id) { 
	Menu = menu_create("\rBonusBox Menu", "BonusBoxMenuCmd");
	
	menu_additem(Menu, "\yAdd Box", "1", 0);
	menu_additem(Menu, "\yDelete All Box", "2", 0);
	menu_additem(Menu, "\yReload Box Origins", "3", 0);
	
	menu_setprop(Menu, MPROP_EXIT, MEXIT_ALL);
	menu_display(id, Menu, 0);
	return PLUGIN_CONTINUE;
}

public BonusBoxMenuCmd(id, menu, item) {
	if (item == MENU_EXIT) {
		menu_destroy(menu);
		return PLUGIN_HANDLED;
	}
	new data[6], iName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
	new key = str_to_num(data);
	switch(key) {
		case 1: SaveOrigin(id)
			
		case 2: DeleteBoxes()
			
		case 3: LoadOrigins()
			
		default: return PLUGIN_HANDLED;
	}
	menu_destroy(menu);
	return PLUGIN_HANDLED;
}

public LOGEVENT_RoundStart()  {
	remove_entity_name(BonusBox_RoundStart_ClassName) 
	remove_entity_name(BonusBox_Death_ClassName) 
	if(get_pcvar_num(bonusbox_rs)) {
		LoadOrigins() 
		new Spawned = TotalBox
		for(new i = 1; i <= Spawned; i++) {
			new Box = create_entity("info_target") 
			set_pev(Box, pev_classname, BonusBox_RoundStart_ClassName)
			engfunc(EngFunc_SetModel, Box, Model[0]) 
			engfunc(EngFunc_SetSize, Box, Float:{-10.0,-10.0,0.0},Float:{10.0,10.0,20.0})
			
			set_pev(Box, pev_gravity, 1.0)
			set_pev(Box, pev_origin, BoxData[TotalBox])
			set_pev(Box, pev_solid, SOLID_BBOX)
			set_pev(Box, pev_movetype, MOVETYPE_NONE)
			set_pev(Box, pev_nextthink, halflife_time() + 0.01)
			emit_sound(Box, CHAN_AUTO,SpawnBoxSound,VOL_NORM,ATTN_NORM,0,PITCH_NORM) 
			TotalBox--
		}
	}
} 

public EVENT_Death() {
	new victim = read_data(2);
	if(is_user_connected(victim) && cs_get_user_team(victim) != CS_TEAM_SPECTATOR && get_pcvar_num(bonusbox_die)) {
		new Float:Origin[3];
		pev(victim, pev_origin, Origin);
		
		new Box = create_entity("info_target") 
		set_pev(Box, pev_classname, BonusBox_Death_ClassName)
		switch(cs_get_user_team(victim)) {
			case CS_TEAM_T: { 
				engfunc(EngFunc_SetModel, Box, Model[2])
				set_pev(Box, pev_team, 2)
			}
			
			case CS_TEAM_CT: {
				engfunc(EngFunc_SetModel, Box, Model[1])	
				set_pev(Box, pev_team, 1)
			}
		}
		engfunc(EngFunc_SetSize, Box, Float:{-10.0, -10.0, -25.0},Float:{10.0, 10.0, 25.0})
		set_pev(Box, pev_gravity, 1.0)
		set_pev(Box, pev_origin, Origin)
		set_pev(Box, pev_solid, SOLID_BBOX)
		set_pev(Box, pev_animtime, get_gametime())
		set_pev(Box, pev_framerate,1.0)
		set_pev(Box, pev_movetype, MOVETYPE_NONE)
		set_pev(Box, pev_nextthink, get_gametime() + 0.01)
	}
}

public BonusBox_Touch(toucher, touched) {
	if (!is_user_alive(toucher) || !is_user_connected(toucher) || !pev_valid(touched))
		return FMRES_IGNORED
	
	new classname[32]	
	pev(touched, pev_classname, classname, 31)
	if (equal(classname, BonusBox_RoundStart_ClassName)) {
		BonusBox_GiveBonus(toucher, 0)
		emit_sound(touched,CHAN_AUTO,TakeBoxSound,VOL_NORM,ATTN_NORM,0,PITCH_NORM) 
		remove_entity(touched);
	}
	if (equal(classname, BonusBox_Death_ClassName) && get_user_team(toucher) == pev(touched, pev_team)) {	
		BonusBox_GiveBonus(toucher, 1)
		emit_sound(touched,CHAN_AUTO,TakeBoxSound,VOL_NORM,ATTN_NORM,0,PITCH_NORM) 
		set_pev(touched, pev_effects, EF_NODRAW)
		set_pev(touched, pev_solid, SOLID_NOT)
		remove_entity(touched);
	}
	return FMRES_IGNORED
	
}

public BonusBox_Think(entity) { 
	Light(entity, 4, 255, 100, 015)	
	set_pev(entity, pev_nextthink, get_gametime() + 0.01)
} 

public BonusBox_Think2(entity) { 
	switch(pev(entity, pev_team)) {
		case 1: { 
			Light(entity, 3, 200, 0, 0)
			
		}	
		case 2: { 
			Light(entity, 3, 0, 0, 200)
		}
	}
	set_pev(entity, pev_nextthink, get_gametime() + 0.01)
} 

public BonusBox_GiveBonus(id, type) {
	if(type) {
		switch (random_num(1,5)) {
			case 1: {
				if(!cs_get_user_nvg(id)) {
					cs_set_user_nvg(id, 1)
					ColorChat(id, "!t[Bonus Box]!g Ai primit un!t NightVision.")
				}
				else BonusBox_GiveBonus(id, 0)
			}	
			case 2: {
				new Health = random_num(50, 150)
				fm_set_user_health(id, get_user_health(id) + Health)
				ColorChat(id, "!t[Bonus Box]!g Ai primit!t %d HP.", Health)
			}
			case 3: {
				new Armor = random_num(50, 150)
				cs_set_user_armor(id, get_user_armor(id) + Armor, CS_ARMOR_VESTHELM)
				ColorChat(id, "!t[Bonus Box]!g Ai primit!t %d AP.", Armor)
			}
			case 4: {
				new Money = random_num(3000, 6000)
				cs_set_user_money(id, cs_get_user_money(id) + Money)
				ColorChat(id, "!t[Bonus Box]!g Ai primit!t %d$", Money)
			}
			case 5: {
				if(!user_has_weapon(id, CSW_HEGRENADE)) {
					fm_give_item(id, "weapon_hegrenade")
				}
				else {
					cs_set_user_bpammo(id, CSW_HEGRENADE, cs_get_user_bpammo(id, CSW_HEGRENADE) + 1);
				}
				
				if(!user_has_weapon(id, CSW_FLASHBANG)) {
					fm_give_item(id, "weapon_flashbang")
				}
				else {
					cs_set_user_bpammo(id, CSW_FLASHBANG, cs_get_user_bpammo(id, CSW_FLASHBANG) + 1);
				}
				
				if(!user_has_weapon(id, CSW_SMOKEGRENADE)) {
					fm_give_item(id, "weapon_smokegrenade")
				}
				else {
					cs_set_user_bpammo(id, CSW_SMOKEGRENADE, cs_get_user_bpammo(id, CSW_SMOKEGRENADE) + 1);
				}	
				ColorChat(id, "!t[Bonus Box]!g Ai primit un!t Pachet de Grenazi")
			}
		}
		
	}
	else {
		switch (random_num(1,5)) {
			case 1: {
				if(!cs_get_user_nvg(id)) {
					cs_set_user_nvg(id, 1)
					ColorChat(id, "!t[Bonus Box]!g Ai primit un!t NightVision.")
				}
				else BonusBox_GiveBonus(id, 0)
			}
			
			
			case 2: {
				new Health = random_num(100, 150)
				fm_set_user_health(id, get_user_health(id) + Health)
				ColorChat(id, "!t[Bonus Box]!g Ai primit!t %d HP.", Health)
			}
			case 3: {
				new Armor = random_num(100, 150)
				cs_set_user_armor(id, get_user_armor(id) + Armor, CS_ARMOR_VESTHELM)
				ColorChat(id, "!t[Bonus Box]!g Ai primit!t %d AP.", Armor)
			}
			case 4: {
				new Money = random_num(5000, 6000)
				cs_set_user_money(id, cs_get_user_money(id) + Money)
				ColorChat(id, "!t[Bonus Box]!g Ai primit!t %d$", Money)
			}
			case 5: {
				if(!user_has_weapon(id, CSW_HEGRENADE)) {
					fm_give_item(id, "weapon_hegrenade")
				}
				else {
					cs_set_user_bpammo(id, CSW_HEGRENADE, cs_get_user_bpammo(id, CSW_HEGRENADE) + 1);
				}
				
				if(!user_has_weapon(id, CSW_FLASHBANG)) {
					fm_give_item(id, "weapon_flashbang")
				}
				else {
					cs_set_user_bpammo(id, CSW_FLASHBANG, cs_get_user_bpammo(id, CSW_FLASHBANG) + 1);
				}
				
				if(!user_has_weapon(id, CSW_SMOKEGRENADE)) {
					fm_give_item(id, "weapon_smokegrenade")
				}
				else {
					cs_set_user_bpammo(id, CSW_SMOKEGRENADE, cs_get_user_bpammo(id, CSW_SMOKEGRENADE) + 1);
				}	
				ColorChat(id, "!t[Bonus Box]!g Ai primit un!t Pachet de Grenazi")
			}
		}
	}
}

public Light(entity, radius, red, green, blue) {	
	if(is_valid_ent(entity)) {
		static Float:origin[3]
		pev(entity, pev_origin, origin)
		
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY, _, entity);
		write_byte(TE_DLIGHT) // TE id
		engfunc(EngFunc_WriteCoord, origin[0])
		engfunc(EngFunc_WriteCoord, origin[1])
		engfunc(EngFunc_WriteCoord, origin[2])
		write_byte(radius) 
		write_byte(red)
		write_byte(green)
		write_byte(blue)
		write_byte(1)
		write_byte(0)
		message_end();
	}
}

public SaveOrigin(id) { 
	new Float:Origin[3];
	pev(id, pev_origin, Origin);
	
	
	static save, buffer[128]
	save = fopen(File,"at") 
	
	formatex(buffer, charsmax(buffer), "%f %f %f^n", Origin[0], Origin[1], Origin[2])
	client_print(id,print_center,"BonusBox successfully added.",Origin[0],Origin[1],Origin[2]) 
	fputs(save, buffer)
	
	TotalBox++
	
	BoxData[TotalBox][0] = Origin[0]
	BoxData[TotalBox][1] = Origin[1]
	BoxData[TotalBox][2] = Origin[2]
	
	
	fclose(save)		
	LoadOrigins() 
} 

public DeleteBoxes() {
	remove_entity_name(BonusBox_RoundStart_ClassName) 
	for(new i = 0; i > TotalBox; i++) {
		BoxData[TotalBox][0] = 0.0
		BoxData[TotalBox][1] = 0.0
		BoxData[TotalBox][2] = 0.0
		
		TotalBox --
	}
	LoadOrigins() 
	delete_file(File)
}

public LoadOrigins() { 
	TotalBox = 0 
	
	new buffer[128], x[12],y[12],z[12] 
	if(file_exists(File)) { 
		new save = fopen(File,"rt") 
		
		if(!save) return 
		
		while(!feof(save)) { 
			fgets(save,buffer,127) 
			
			if(buffer[0] == ';' || !buffer[0]) continue 
			
			parse(buffer, x,11, y,11, z,11) 
			
			BoxData[TotalBox][0] = str_to_float(x) 
			BoxData[TotalBox][1] = str_to_float(y) 
			BoxData[TotalBox][2] = str_to_float(z) 
			
			TotalBox++ 
		} 
		
		fclose(save) 
	}     
} 

stock ColorChat(const id, const input[], any:...) {
	new count = 1, players[32];
	static msg[191];
	vformat(msg, 190, input, 3);
	
	replace_all(msg, 190, "!g", "^4");
	replace_all(msg, 190, "!y", "^1");
	replace_all(msg, 190, "!t", "^3");
	
	if(id) players[0] = id;
	else get_players(players, count, "ch"); {
		for(new i = 0; i < count; i++) {
			if(is_user_connected(players)) {
				message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players);
				write_byte(players);
				write_string(msg);
				message_end();
			}
		}
	} 
}


Edit: Link Resurse: http://www.girlshare.ro/32546232.4


Plugin-ul nu merge , apare "BonusBox Succesfully Added" dar nu adauga nici o cutie niciaeri .. :|

Am facut exact cum ai zis cu cvar-ul , folderul si pur si simplu nu merge.. poti rezolva te rog ?
User avatar
sDs|Aragon*
Membru, skill +2
Membru, skill +2
Posts: 576
Joined: 29 Dec 2011, 21:38
Detinator Steam: Da
SteamID: Mihai_Parkour10
Reputatie: Fost scripter eXtreamCS
Has thanked: 4 times
Been thanked: 132 times

31 May 2013, 01:52

eDward /R/ wrote:
sDs|Aragon* wrote:Seteaza amx_bonusbox_after_die pe 0
Creeaza un folder cu numele BonusBox in config.
Baga acest plugin, dupa care scrii /bonusbox si iti salvezi originile unde vrei sa iti apara cadouri in fiecare runda.
| Afiseaza codul
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <fakemeta>
#include <fakemeta_util>

#define PLUGIN "Bonus Box"
#define VERSION "3.0"
#define AUTHOR "Aragon*"

#define BONUSBOX_MAX 40

new const BonusBox_RoundStart_ClassName[] = "RS_BonusBox"
new const BonusBox_Death_ClassName[] = "Death_BonusBox"

new const SpawnBoxSound[] = "BonusBoxSpawn.wav"
new const TakeBoxSound[] = "BonusBoxGet.wav"

new Menu, File[78], TotalBox = 0, Float:BoxData[BONUSBOX_MAX + 1][3];
new bonusbox_rs, bonusbox_die
new Model[3][] = {
	"models/bonusbox.mdl",
	"models/bonusbox_t.mdl",
	"models/bonusbox_ct.mdl"
}

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	register_concmd("bonusbox","CMD_BonusBoxMenu", ADMIN_CVAR) 	
	register_concmd("say bonusbox","CMD_BonusBoxMenu", ADMIN_CVAR) 	
	register_concmd("say /bonusbox","CMD_BonusBoxMenu", ADMIN_CVAR) 	
	register_concmd("say_team bonusbox","CMD_BonusBoxMenu", ADMIN_CVAR) 	
	register_concmd("say_team /bonusbox","CMD_BonusBoxMenu", ADMIN_CVAR) 	
	register_forward(FM_Touch, "BonusBox_Touch")
	register_think(BonusBox_RoundStart_ClassName,"BonusBox_Think") 
	register_think(BonusBox_Death_ClassName,"BonusBox_Think2") 
	register_event("DeathMsg", "EVENT_Death", "a")
	register_logevent("LOGEVENT_RoundStart",2,"1=Round_Start")
	
	bonusbox_rs = register_cvar("amx_bonusbox_round_start", "1")
	bonusbox_die = register_cvar("amx_bonusbox_after_die", "1")
	
	new CfgDir[32], MapName[32];
	get_configsdir(CfgDir, charsmax(CfgDir));
	get_mapname(MapName,31) 
	formatex(File, charsmax(File), "%s/BonusBox/%s.cfg", CfgDir, MapName);
	
	LoadOrigins() 
}

public plugin_precache() {
	for (new i = 0; i < sizeof Model; i++)
		precache_model(Model)
	precache_sound(SpawnBoxSound) 
	precache_sound(TakeBoxSound) 
}

public CMD_BonusBoxMenu(id) { 
	Menu = menu_create("\rBonusBox Menu", "BonusBoxMenuCmd");
	
	menu_additem(Menu, "\yAdd Box", "1", 0);
	menu_additem(Menu, "\yDelete All Box", "2", 0);
	menu_additem(Menu, "\yReload Box Origins", "3", 0);
	
	menu_setprop(Menu, MPROP_EXIT, MEXIT_ALL);
	menu_display(id, Menu, 0);
	return PLUGIN_CONTINUE;
}

public BonusBoxMenuCmd(id, menu, item) {
	if (item == MENU_EXIT) {
		menu_destroy(menu);
		return PLUGIN_HANDLED;
	}
	new data[6], iName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
	new key = str_to_num(data);
	switch(key) {
		case 1: SaveOrigin(id)
			
		case 2: DeleteBoxes()
			
		case 3: LoadOrigins()
			
		default: return PLUGIN_HANDLED;
	}
	menu_destroy(menu);
	return PLUGIN_HANDLED;
}

public LOGEVENT_RoundStart()  {
	remove_entity_name(BonusBox_RoundStart_ClassName) 
	remove_entity_name(BonusBox_Death_ClassName) 
	if(get_pcvar_num(bonusbox_rs)) {
		LoadOrigins() 
		new Spawned = TotalBox
		for(new i = 1; i <= Spawned; i++) {
			new Box = create_entity("info_target") 
			set_pev(Box, pev_classname, BonusBox_RoundStart_ClassName)
			engfunc(EngFunc_SetModel, Box, Model[0]) 
			engfunc(EngFunc_SetSize, Box, Float:{-10.0,-10.0,0.0},Float:{10.0,10.0,20.0})
			
			set_pev(Box, pev_gravity, 1.0)
			set_pev(Box, pev_origin, BoxData[TotalBox])
			set_pev(Box, pev_solid, SOLID_BBOX)
			set_pev(Box, pev_movetype, MOVETYPE_NONE)
			set_pev(Box, pev_nextthink, halflife_time() + 0.01)
			emit_sound(Box, CHAN_AUTO,SpawnBoxSound,VOL_NORM,ATTN_NORM,0,PITCH_NORM) 
			TotalBox--
		}
	}
} 

public EVENT_Death() {
	new victim = read_data(2);
	if(is_user_connected(victim) && cs_get_user_team(victim) != CS_TEAM_SPECTATOR && get_pcvar_num(bonusbox_die)) {
		new Float:Origin[3];
		pev(victim, pev_origin, Origin);
		
		new Box = create_entity("info_target") 
		set_pev(Box, pev_classname, BonusBox_Death_ClassName)
		switch(cs_get_user_team(victim)) {
			case CS_TEAM_T: { 
				engfunc(EngFunc_SetModel, Box, Model[2])
				set_pev(Box, pev_team, 2)
			}
			
			case CS_TEAM_CT: {
				engfunc(EngFunc_SetModel, Box, Model[1])	
				set_pev(Box, pev_team, 1)
			}
		}
		engfunc(EngFunc_SetSize, Box, Float:{-10.0, -10.0, -25.0},Float:{10.0, 10.0, 25.0})
		set_pev(Box, pev_gravity, 1.0)
		set_pev(Box, pev_origin, Origin)
		set_pev(Box, pev_solid, SOLID_BBOX)
		set_pev(Box, pev_animtime, get_gametime())
		set_pev(Box, pev_framerate,1.0)
		set_pev(Box, pev_movetype, MOVETYPE_NONE)
		set_pev(Box, pev_nextthink, get_gametime() + 0.01)
	}
}

public BonusBox_Touch(toucher, touched) {
	if (!is_user_alive(toucher) || !is_user_connected(toucher) || !pev_valid(touched))
		return FMRES_IGNORED
	
	new classname[32]	
	pev(touched, pev_classname, classname, 31)
	if (equal(classname, BonusBox_RoundStart_ClassName)) {
		BonusBox_GiveBonus(toucher, 0)
		emit_sound(touched,CHAN_AUTO,TakeBoxSound,VOL_NORM,ATTN_NORM,0,PITCH_NORM) 
		remove_entity(touched);
	}
	if (equal(classname, BonusBox_Death_ClassName) && get_user_team(toucher) == pev(touched, pev_team)) {	
		BonusBox_GiveBonus(toucher, 1)
		emit_sound(touched,CHAN_AUTO,TakeBoxSound,VOL_NORM,ATTN_NORM,0,PITCH_NORM) 
		set_pev(touched, pev_effects, EF_NODRAW)
		set_pev(touched, pev_solid, SOLID_NOT)
		remove_entity(touched);
	}
	return FMRES_IGNORED
	
}

public BonusBox_Think(entity) { 
	Light(entity, 4, 255, 100, 015)	
	set_pev(entity, pev_nextthink, get_gametime() + 0.01)
} 

public BonusBox_Think2(entity) { 
	switch(pev(entity, pev_team)) {
		case 1: { 
			Light(entity, 3, 200, 0, 0)
			
		}	
		case 2: { 
			Light(entity, 3, 0, 0, 200)
		}
	}
	set_pev(entity, pev_nextthink, get_gametime() + 0.01)
} 

public BonusBox_GiveBonus(id, type) {
	if(type) {
		switch (random_num(1,5)) {
			case 1: {
				if(!cs_get_user_nvg(id)) {
					cs_set_user_nvg(id, 1)
					ColorChat(id, "!t[Bonus Box]!g Ai primit un!t NightVision.")
				}
				else BonusBox_GiveBonus(id, 0)
			}	
			case 2: {
				new Health = random_num(50, 150)
				fm_set_user_health(id, get_user_health(id) + Health)
				ColorChat(id, "!t[Bonus Box]!g Ai primit!t %d HP.", Health)
			}
			case 3: {
				new Armor = random_num(50, 150)
				cs_set_user_armor(id, get_user_armor(id) + Armor, CS_ARMOR_VESTHELM)
				ColorChat(id, "!t[Bonus Box]!g Ai primit!t %d AP.", Armor)
			}
			case 4: {
				new Money = random_num(3000, 6000)
				cs_set_user_money(id, cs_get_user_money(id) + Money)
				ColorChat(id, "!t[Bonus Box]!g Ai primit!t %d$", Money)
			}
			case 5: {
				if(!user_has_weapon(id, CSW_HEGRENADE)) {
					fm_give_item(id, "weapon_hegrenade")
				}
				else {
					cs_set_user_bpammo(id, CSW_HEGRENADE, cs_get_user_bpammo(id, CSW_HEGRENADE) + 1);
				}
				
				if(!user_has_weapon(id, CSW_FLASHBANG)) {
					fm_give_item(id, "weapon_flashbang")
				}
				else {
					cs_set_user_bpammo(id, CSW_FLASHBANG, cs_get_user_bpammo(id, CSW_FLASHBANG) + 1);
				}
				
				if(!user_has_weapon(id, CSW_SMOKEGRENADE)) {
					fm_give_item(id, "weapon_smokegrenade")
				}
				else {
					cs_set_user_bpammo(id, CSW_SMOKEGRENADE, cs_get_user_bpammo(id, CSW_SMOKEGRENADE) + 1);
				}	
				ColorChat(id, "!t[Bonus Box]!g Ai primit un!t Pachet de Grenazi")
			}
		}
		
	}
	else {
		switch (random_num(1,5)) {
			case 1: {
				if(!cs_get_user_nvg(id)) {
					cs_set_user_nvg(id, 1)
					ColorChat(id, "!t[Bonus Box]!g Ai primit un!t NightVision.")
				}
				else BonusBox_GiveBonus(id, 0)
			}
			
			
			case 2: {
				new Health = random_num(100, 150)
				fm_set_user_health(id, get_user_health(id) + Health)
				ColorChat(id, "!t[Bonus Box]!g Ai primit!t %d HP.", Health)
			}
			case 3: {
				new Armor = random_num(100, 150)
				cs_set_user_armor(id, get_user_armor(id) + Armor, CS_ARMOR_VESTHELM)
				ColorChat(id, "!t[Bonus Box]!g Ai primit!t %d AP.", Armor)
			}
			case 4: {
				new Money = random_num(5000, 6000)
				cs_set_user_money(id, cs_get_user_money(id) + Money)
				ColorChat(id, "!t[Bonus Box]!g Ai primit!t %d$", Money)
			}
			case 5: {
				if(!user_has_weapon(id, CSW_HEGRENADE)) {
					fm_give_item(id, "weapon_hegrenade")
				}
				else {
					cs_set_user_bpammo(id, CSW_HEGRENADE, cs_get_user_bpammo(id, CSW_HEGRENADE) + 1);
				}
				
				if(!user_has_weapon(id, CSW_FLASHBANG)) {
					fm_give_item(id, "weapon_flashbang")
				}
				else {
					cs_set_user_bpammo(id, CSW_FLASHBANG, cs_get_user_bpammo(id, CSW_FLASHBANG) + 1);
				}
				
				if(!user_has_weapon(id, CSW_SMOKEGRENADE)) {
					fm_give_item(id, "weapon_smokegrenade")
				}
				else {
					cs_set_user_bpammo(id, CSW_SMOKEGRENADE, cs_get_user_bpammo(id, CSW_SMOKEGRENADE) + 1);
				}	
				ColorChat(id, "!t[Bonus Box]!g Ai primit un!t Pachet de Grenazi")
			}
		}
	}
}

public Light(entity, radius, red, green, blue) {	
	if(is_valid_ent(entity)) {
		static Float:origin[3]
		pev(entity, pev_origin, origin)
		
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY, _, entity);
		write_byte(TE_DLIGHT) // TE id
		engfunc(EngFunc_WriteCoord, origin[0])
		engfunc(EngFunc_WriteCoord, origin[1])
		engfunc(EngFunc_WriteCoord, origin[2])
		write_byte(radius) 
		write_byte(red)
		write_byte(green)
		write_byte(blue)
		write_byte(1)
		write_byte(0)
		message_end();
	}
}

public SaveOrigin(id) { 
	new Float:Origin[3];
	pev(id, pev_origin, Origin);
	
	
	static save, buffer[128]
	save = fopen(File,"at") 
	
	formatex(buffer, charsmax(buffer), "%f %f %f^n", Origin[0], Origin[1], Origin[2])
	client_print(id,print_center,"BonusBox successfully added.",Origin[0],Origin[1],Origin[2]) 
	fputs(save, buffer)
	
	TotalBox++
	
	BoxData[TotalBox][0] = Origin[0]
	BoxData[TotalBox][1] = Origin[1]
	BoxData[TotalBox][2] = Origin[2]
	
	
	fclose(save)		
	LoadOrigins() 
} 

public DeleteBoxes() {
	remove_entity_name(BonusBox_RoundStart_ClassName) 
	for(new i = 0; i > TotalBox; i++) {
		BoxData[TotalBox][0] = 0.0
		BoxData[TotalBox][1] = 0.0
		BoxData[TotalBox][2] = 0.0
		
		TotalBox --
	}
	LoadOrigins() 
	delete_file(File)
}

public LoadOrigins() { 
	TotalBox = 0 
	
	new buffer[128], x[12],y[12],z[12] 
	if(file_exists(File)) { 
		new save = fopen(File,"rt") 
		
		if(!save) return 
		
		while(!feof(save)) { 
			fgets(save,buffer,127) 
			
			if(buffer[0] == ';' || !buffer[0]) continue 
			
			parse(buffer, x,11, y,11, z,11) 
			
			BoxData[TotalBox][0] = str_to_float(x) 
			BoxData[TotalBox][1] = str_to_float(y) 
			BoxData[TotalBox][2] = str_to_float(z) 
			
			TotalBox++ 
		} 
		
		fclose(save) 
	}     
} 

stock ColorChat(const id, const input[], any:...) {
	new count = 1, players[32];
	static msg[191];
	vformat(msg, 190, input, 3);
	
	replace_all(msg, 190, "!g", "^4");
	replace_all(msg, 190, "!y", "^1");
	replace_all(msg, 190, "!t", "^3");
	
	if(id) players[0] = id;
	else get_players(players, count, "ch"); {
		for(new i = 0; i < count; i++) {
			if(is_user_connected(players)) {
				message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players);
				write_byte(players);
				write_string(msg);
				message_end();
			}
		}
	} 
}


Edit: Link Resurse: http://www.girlshare.ro/32546232.4


Plugin-ul nu merge , apare "BonusBox Succesfully Added" dar nu adauga nici o cutie niciaeri .. :|

Am facut exact cum ai zis cu cvar-ul , folderul si pur si simplu nu merge.. poti rezolva te rog ?

Este testat, nu are cum sa nu functioneze.
EDwardddd.
Membru, skill +2
Membru, skill +2
Posts: 806
Joined: 18 Jun 2010, 10:30
Detinator Steam: Da
SteamID: edwarddwd
Reputatie: Membru Club eXtreamCS (trei luni)
Fost Moderator ajutator
Nume anterioare: Elk, eDward /R/
Has thanked: 16 times
Been thanked: 49 times

02 Jun 2013, 15:17

sDs|Aragon* wrote:
eDward /R/ wrote:
sDs|Aragon* wrote:Seteaza amx_bonusbox_after_die pe 0
Creeaza un folder cu numele BonusBox in config.
Baga acest plugin, dupa care scrii /bonusbox si iti salvezi originile unde vrei sa iti apara cadouri in fiecare runda.
| Afiseaza codul
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <fakemeta>
#include <fakemeta_util>

#define PLUGIN "Bonus Box"
#define VERSION "3.0"
#define AUTHOR "Aragon*"

#define BONUSBOX_MAX 40

new const BonusBox_RoundStart_ClassName[] = "RS_BonusBox"
new const BonusBox_Death_ClassName[] = "Death_BonusBox"

new const SpawnBoxSound[] = "BonusBoxSpawn.wav"
new const TakeBoxSound[] = "BonusBoxGet.wav"

new Menu, File[78], TotalBox = 0, Float:BoxData[BONUSBOX_MAX + 1][3];
new bonusbox_rs, bonusbox_die
new Model[3][] = {
	"models/bonusbox.mdl",
	"models/bonusbox_t.mdl",
	"models/bonusbox_ct.mdl"
}

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	register_concmd("bonusbox","CMD_BonusBoxMenu", ADMIN_CVAR) 	
	register_concmd("say bonusbox","CMD_BonusBoxMenu", ADMIN_CVAR) 	
	register_concmd("say /bonusbox","CMD_BonusBoxMenu", ADMIN_CVAR) 	
	register_concmd("say_team bonusbox","CMD_BonusBoxMenu", ADMIN_CVAR) 	
	register_concmd("say_team /bonusbox","CMD_BonusBoxMenu", ADMIN_CVAR) 	
	register_forward(FM_Touch, "BonusBox_Touch")
	register_think(BonusBox_RoundStart_ClassName,"BonusBox_Think") 
	register_think(BonusBox_Death_ClassName,"BonusBox_Think2") 
	register_event("DeathMsg", "EVENT_Death", "a")
	register_logevent("LOGEVENT_RoundStart",2,"1=Round_Start")
	
	bonusbox_rs = register_cvar("amx_bonusbox_round_start", "1")
	bonusbox_die = register_cvar("amx_bonusbox_after_die", "1")
	
	new CfgDir[32], MapName[32];
	get_configsdir(CfgDir, charsmax(CfgDir));
	get_mapname(MapName,31) 
	formatex(File, charsmax(File), "%s/BonusBox/%s.cfg", CfgDir, MapName);
	
	LoadOrigins() 
}

public plugin_precache() {
	for (new i = 0; i < sizeof Model; i++)
		precache_model(Model)
	precache_sound(SpawnBoxSound) 
	precache_sound(TakeBoxSound) 
}

public CMD_BonusBoxMenu(id) { 
	Menu = menu_create("\rBonusBox Menu", "BonusBoxMenuCmd");
	
	menu_additem(Menu, "\yAdd Box", "1", 0);
	menu_additem(Menu, "\yDelete All Box", "2", 0);
	menu_additem(Menu, "\yReload Box Origins", "3", 0);
	
	menu_setprop(Menu, MPROP_EXIT, MEXIT_ALL);
	menu_display(id, Menu, 0);
	return PLUGIN_CONTINUE;
}

public BonusBoxMenuCmd(id, menu, item) {
	if (item == MENU_EXIT) {
		menu_destroy(menu);
		return PLUGIN_HANDLED;
	}
	new data[6], iName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
	new key = str_to_num(data);
	switch(key) {
		case 1: SaveOrigin(id)
			
		case 2: DeleteBoxes()
			
		case 3: LoadOrigins()
			
		default: return PLUGIN_HANDLED;
	}
	menu_destroy(menu);
	return PLUGIN_HANDLED;
}

public LOGEVENT_RoundStart()  {
	remove_entity_name(BonusBox_RoundStart_ClassName) 
	remove_entity_name(BonusBox_Death_ClassName) 
	if(get_pcvar_num(bonusbox_rs)) {
		LoadOrigins() 
		new Spawned = TotalBox
		for(new i = 1; i <= Spawned; i++) {
			new Box = create_entity("info_target") 
			set_pev(Box, pev_classname, BonusBox_RoundStart_ClassName)
			engfunc(EngFunc_SetModel, Box, Model[0]) 
			engfunc(EngFunc_SetSize, Box, Float:{-10.0,-10.0,0.0},Float:{10.0,10.0,20.0})
			
			set_pev(Box, pev_gravity, 1.0)
			set_pev(Box, pev_origin, BoxData[TotalBox])
			set_pev(Box, pev_solid, SOLID_BBOX)
			set_pev(Box, pev_movetype, MOVETYPE_NONE)
			set_pev(Box, pev_nextthink, halflife_time() + 0.01)
			emit_sound(Box, CHAN_AUTO,SpawnBoxSound,VOL_NORM,ATTN_NORM,0,PITCH_NORM) 
			TotalBox--
		}
	}
} 

public EVENT_Death() {
	new victim = read_data(2);
	if(is_user_connected(victim) && cs_get_user_team(victim) != CS_TEAM_SPECTATOR && get_pcvar_num(bonusbox_die)) {
		new Float:Origin[3];
		pev(victim, pev_origin, Origin);
		
		new Box = create_entity("info_target") 
		set_pev(Box, pev_classname, BonusBox_Death_ClassName)
		switch(cs_get_user_team(victim)) {
			case CS_TEAM_T: { 
				engfunc(EngFunc_SetModel, Box, Model[2])
				set_pev(Box, pev_team, 2)
			}
			
			case CS_TEAM_CT: {
				engfunc(EngFunc_SetModel, Box, Model[1])	
				set_pev(Box, pev_team, 1)
			}
		}
		engfunc(EngFunc_SetSize, Box, Float:{-10.0, -10.0, -25.0},Float:{10.0, 10.0, 25.0})
		set_pev(Box, pev_gravity, 1.0)
		set_pev(Box, pev_origin, Origin)
		set_pev(Box, pev_solid, SOLID_BBOX)
		set_pev(Box, pev_animtime, get_gametime())
		set_pev(Box, pev_framerate,1.0)
		set_pev(Box, pev_movetype, MOVETYPE_NONE)
		set_pev(Box, pev_nextthink, get_gametime() + 0.01)
	}
}

public BonusBox_Touch(toucher, touched) {
	if (!is_user_alive(toucher) || !is_user_connected(toucher) || !pev_valid(touched))
		return FMRES_IGNORED
	
	new classname[32]	
	pev(touched, pev_classname, classname, 31)
	if (equal(classname, BonusBox_RoundStart_ClassName)) {
		BonusBox_GiveBonus(toucher, 0)
		emit_sound(touched,CHAN_AUTO,TakeBoxSound,VOL_NORM,ATTN_NORM,0,PITCH_NORM) 
		remove_entity(touched);
	}
	if (equal(classname, BonusBox_Death_ClassName) && get_user_team(toucher) == pev(touched, pev_team)) {	
		BonusBox_GiveBonus(toucher, 1)
		emit_sound(touched,CHAN_AUTO,TakeBoxSound,VOL_NORM,ATTN_NORM,0,PITCH_NORM) 
		set_pev(touched, pev_effects, EF_NODRAW)
		set_pev(touched, pev_solid, SOLID_NOT)
		remove_entity(touched);
	}
	return FMRES_IGNORED
	
}

public BonusBox_Think(entity) { 
	Light(entity, 4, 255, 100, 015)	
	set_pev(entity, pev_nextthink, get_gametime() + 0.01)
} 

public BonusBox_Think2(entity) { 
	switch(pev(entity, pev_team)) {
		case 1: { 
			Light(entity, 3, 200, 0, 0)
			
		}	
		case 2: { 
			Light(entity, 3, 0, 0, 200)
		}
	}
	set_pev(entity, pev_nextthink, get_gametime() + 0.01)
} 

public BonusBox_GiveBonus(id, type) {
	if(type) {
		switch (random_num(1,5)) {
			case 1: {
				if(!cs_get_user_nvg(id)) {
					cs_set_user_nvg(id, 1)
					ColorChat(id, "!t[Bonus Box]!g Ai primit un!t NightVision.")
				}
				else BonusBox_GiveBonus(id, 0)
			}	
			case 2: {
				new Health = random_num(50, 150)
				fm_set_user_health(id, get_user_health(id) + Health)
				ColorChat(id, "!t[Bonus Box]!g Ai primit!t %d HP.", Health)
			}
			case 3: {
				new Armor = random_num(50, 150)
				cs_set_user_armor(id, get_user_armor(id) + Armor, CS_ARMOR_VESTHELM)
				ColorChat(id, "!t[Bonus Box]!g Ai primit!t %d AP.", Armor)
			}
			case 4: {
				new Money = random_num(3000, 6000)
				cs_set_user_money(id, cs_get_user_money(id) + Money)
				ColorChat(id, "!t[Bonus Box]!g Ai primit!t %d$", Money)
			}
			case 5: {
				if(!user_has_weapon(id, CSW_HEGRENADE)) {
					fm_give_item(id, "weapon_hegrenade")
				}
				else {
					cs_set_user_bpammo(id, CSW_HEGRENADE, cs_get_user_bpammo(id, CSW_HEGRENADE) + 1);
				}
				
				if(!user_has_weapon(id, CSW_FLASHBANG)) {
					fm_give_item(id, "weapon_flashbang")
				}
				else {
					cs_set_user_bpammo(id, CSW_FLASHBANG, cs_get_user_bpammo(id, CSW_FLASHBANG) + 1);
				}
				
				if(!user_has_weapon(id, CSW_SMOKEGRENADE)) {
					fm_give_item(id, "weapon_smokegrenade")
				}
				else {
					cs_set_user_bpammo(id, CSW_SMOKEGRENADE, cs_get_user_bpammo(id, CSW_SMOKEGRENADE) + 1);
				}	
				ColorChat(id, "!t[Bonus Box]!g Ai primit un!t Pachet de Grenazi")
			}
		}
		
	}
	else {
		switch (random_num(1,5)) {
			case 1: {
				if(!cs_get_user_nvg(id)) {
					cs_set_user_nvg(id, 1)
					ColorChat(id, "!t[Bonus Box]!g Ai primit un!t NightVision.")
				}
				else BonusBox_GiveBonus(id, 0)
			}
			
			
			case 2: {
				new Health = random_num(100, 150)
				fm_set_user_health(id, get_user_health(id) + Health)
				ColorChat(id, "!t[Bonus Box]!g Ai primit!t %d HP.", Health)
			}
			case 3: {
				new Armor = random_num(100, 150)
				cs_set_user_armor(id, get_user_armor(id) + Armor, CS_ARMOR_VESTHELM)
				ColorChat(id, "!t[Bonus Box]!g Ai primit!t %d AP.", Armor)
			}
			case 4: {
				new Money = random_num(5000, 6000)
				cs_set_user_money(id, cs_get_user_money(id) + Money)
				ColorChat(id, "!t[Bonus Box]!g Ai primit!t %d$", Money)
			}
			case 5: {
				if(!user_has_weapon(id, CSW_HEGRENADE)) {
					fm_give_item(id, "weapon_hegrenade")
				}
				else {
					cs_set_user_bpammo(id, CSW_HEGRENADE, cs_get_user_bpammo(id, CSW_HEGRENADE) + 1);
				}
				
				if(!user_has_weapon(id, CSW_FLASHBANG)) {
					fm_give_item(id, "weapon_flashbang")
				}
				else {
					cs_set_user_bpammo(id, CSW_FLASHBANG, cs_get_user_bpammo(id, CSW_FLASHBANG) + 1);
				}
				
				if(!user_has_weapon(id, CSW_SMOKEGRENADE)) {
					fm_give_item(id, "weapon_smokegrenade")
				}
				else {
					cs_set_user_bpammo(id, CSW_SMOKEGRENADE, cs_get_user_bpammo(id, CSW_SMOKEGRENADE) + 1);
				}	
				ColorChat(id, "!t[Bonus Box]!g Ai primit un!t Pachet de Grenazi")
			}
		}
	}
}

public Light(entity, radius, red, green, blue) {	
	if(is_valid_ent(entity)) {
		static Float:origin[3]
		pev(entity, pev_origin, origin)
		
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY, _, entity);
		write_byte(TE_DLIGHT) // TE id
		engfunc(EngFunc_WriteCoord, origin[0])
		engfunc(EngFunc_WriteCoord, origin[1])
		engfunc(EngFunc_WriteCoord, origin[2])
		write_byte(radius) 
		write_byte(red)
		write_byte(green)
		write_byte(blue)
		write_byte(1)
		write_byte(0)
		message_end();
	}
}

public SaveOrigin(id) { 
	new Float:Origin[3];
	pev(id, pev_origin, Origin);
	
	
	static save, buffer[128]
	save = fopen(File,"at") 
	
	formatex(buffer, charsmax(buffer), "%f %f %f^n", Origin[0], Origin[1], Origin[2])
	client_print(id,print_center,"BonusBox successfully added.",Origin[0],Origin[1],Origin[2]) 
	fputs(save, buffer)
	
	TotalBox++
	
	BoxData[TotalBox][0] = Origin[0]
	BoxData[TotalBox][1] = Origin[1]
	BoxData[TotalBox][2] = Origin[2]
	
	
	fclose(save)		
	LoadOrigins() 
} 

public DeleteBoxes() {
	remove_entity_name(BonusBox_RoundStart_ClassName) 
	for(new i = 0; i > TotalBox; i++) {
		BoxData[TotalBox][0] = 0.0
		BoxData[TotalBox][1] = 0.0
		BoxData[TotalBox][2] = 0.0
		
		TotalBox --
	}
	LoadOrigins() 
	delete_file(File)
}

public LoadOrigins() { 
	TotalBox = 0 
	
	new buffer[128], x[12],y[12],z[12] 
	if(file_exists(File)) { 
		new save = fopen(File,"rt") 
		
		if(!save) return 
		
		while(!feof(save)) { 
			fgets(save,buffer,127) 
			
			if(buffer[0] == ';' || !buffer[0]) continue 
			
			parse(buffer, x,11, y,11, z,11) 
			
			BoxData[TotalBox][0] = str_to_float(x) 
			BoxData[TotalBox][1] = str_to_float(y) 
			BoxData[TotalBox][2] = str_to_float(z) 
			
			TotalBox++ 
		} 
		
		fclose(save) 
	}     
} 

stock ColorChat(const id, const input[], any:...) {
	new count = 1, players[32];
	static msg[191];
	vformat(msg, 190, input, 3);
	
	replace_all(msg, 190, "!g", "^4");
	replace_all(msg, 190, "!y", "^1");
	replace_all(msg, 190, "!t", "^3");
	
	if(id) players[0] = id;
	else get_players(players, count, "ch"); {
		for(new i = 0; i < count; i++) {
			if(is_user_connected(players)) {
				message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players);
				write_byte(players);
				write_string(msg);
				message_end();
			}
		}
	} 
}


Edit: Link Resurse: http://www.girlshare.ro/32546232.4


Plugin-ul nu merge , apare "BonusBox Succesfully Added" dar nu adauga nici o cutie niciaeri .. :|

Am facut exact cum ai zis cu cvar-ul , folderul si pur si simplu nu merge.. poti rezolva te rog ?

Este testat, nu are cum sa nu functioneze.


Am incercat si pe harti clasice (dust2) si pe harta de dr ( deathrun_arctic ) si nu merge sub nici o forma :|

Creeaza fisierele .cfg in folderul BonusBox , baga codurile alea de pozitie dar cutiile nu apar :| ..
Post Reply

Return to “Modificari pluginuri”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 12 guests