[Rezolvat]Modificare plugin Xmas gift !!!

Categoria cu cereri de pluginuri si nu numai.

Moderators: Moderatori ajutatori, Moderatori, Echipa eXtreamCS.com

Forum rules
Accesează link-ul pentru a putea vedea regulile forumului

Daca doriti sa vi se modifice un plugin, va rugam postati aici .
Post Reply
Nelutu16
Membru, skill 0
Membru, skill 0
Posts: 40
Joined: 20 Oct 2012, 11:14
Detinator Steam: Nu
Has thanked: 7 times
Contact:

06 Sep 2013, 05:03

Am o problema , nu ma descurc sa modific acest plugin si apelez la ajutorul vostru.

As vrea sa contina doar bonusurile + 3000 bani ,+ 50 hp ,+ 50 armura si cam atat restu sa scoateti .

Multumesc frumos , si sper sa fiu ajutat . Ofer un mare multumesc !
| Afiseaza codul
*
======================================
========== XMAS GIFTS 2.2 ============
======================================

Autor: KronoS
Versiune: 2.2
Site: http://www.eXtreamCS.com

Credite:
FakeNick - pentru pluginul Pick up present de unde a pornit tot
AlinHD - pentru pluginul de cadouri facut de el dar care nu l-a publicat
joropito - pentru Super Spawns
si alte persoane pentru informatii despre entitati

C-var-uri:
presents_respawn_time 60.0 (Dupa cat timp dupa ridicarea unui cadou apare altul pe harta)
presents_on_map 11 (Cate cadouri sa apara pe harta)
ATENTIE: Se calculeaza numarul c-var-ului - 1!!!
Daca puneti 11 or sa apara doar 10 cadouri!

Changelog:
_______________________________
V 2.0
-super spawns
-cvar: presents_on_map
_______________________________
V 2.1
-bug reparat: cadourile apareau in aer
-variabila globala
-FUN -> Fakemeta
-Hamsandwich
-optimizare mesaje HUD
_______________________________
V 2.2
-bug reparat: cadourile dispareau de pe harta
-FM_Think indepartat
_______________________________
*/

#include <amxmodx>
#include <amxmisc>

/* Module necesare */
#include <fakemeta>
#include <hamsandwich>
#include <engine>

/* INC-uri */
#include <cellarray>
#include <xs>

/* Model la cadouri */
new const model_present[][] = { "models/present/w_present.mdl","models/present/w_present2.mdl" }

/* Extras din Fakemeta Util */
#define fm_find_ent_by_class(%1,%2) engfunc(EngFunc_FindEntityByString, %1, "classname", %2)
#define fm_create_entity(%1) engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, %1))

/* Extras din Super Spawns */
#define SS_VERSION	"1.0"
#define SS_MIN_DISTANCE	500.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 }

/* Offset-uri */
#if cellbits == 32
const OFFSET_CSMONEY = 115
#else
const OFFSET_CSMONEY = 140
#endif
const OFFSET_LINUX  = 5
		
new pcvar_respawn_time, pcvar_presents_on_map
new g_money
new g_bonus[33]

public plugin_init()
{
	register_plugin("XMAS GIFTS", "2.2", "KronoS")
		
	/*====================================
	==============Eventuri==============*/

	register_event("HLTV", "spawn_gifts", "a", "1=0", "2=0")
	RegisterHam(Ham_Spawn, "player", "round_start", 1)
	RegisterHam(Ham_Killed, "player", "client_death", 1)
    	RegisterHam(Ham_Item_PreFrame, "player", "FwdPreFramePost", 1)
	register_forward(FM_Touch,"forward_touch")
		
	/*====================================
	==============Cvar-uri==============*/

	pcvar_respawn_time = register_cvar("presents_respawn_time","60.0")
	pcvar_presents_on_map = register_cvar("presents_on_map", "11")

	SsInit(800.0)
	SsScan()
	
	g_money = get_user_msgid("Money")
}

public plugin_precache()
{
	new i
	for(i = 0; i < sizeof model_present; i++)
		engfunc(EngFunc_PrecacheModel,model_present)
}

public spawn_gifts()
{
	func_spawn()
}

public round_start(id)
{
	if(g_bonus[id] > 0)
	{
		switch(g_bonus[id])
		{
			case 1:
			{
				fm_set_user_health(id, get_user_health(id) + 50)
			}
			case 2:
			{
				fm_set_user_gravity(id, 0.4)
			}
		}
	}
}

public func_spawn()
{
        new Float:origin[3]
	new i

	for(i=0; i< get_pcvar_num(pcvar_presents_on_map); i++)
	{
        if(SsGetOrigin(origin))
        {
                new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
                if(pev_valid(ent))
                {
                        engfunc(EngFunc_SetModel,ent,model_present[random_num(0,sizeof model_present - 1)])
                        engfunc(EngFunc_SetOrigin, ent, origin)
			static Float:fMaxs[3] = { 2.0, 2.0, 4.0 }
			static Float:fMins[3] = { -2.0, -2.0, -4.0 }
			set_pev(ent,pev_solid,SOLID_BBOX)
			engfunc(EngFunc_SetSize,ent,fMins,fMaxs)
			engfunc(EngFunc_DropToFloor, ent)

			switch(random_num(0,1))
			{
				case 0:
				{
					set_pev(ent,pev_classname,"small_present")
				}
				case 1:
				{
					set_pev(ent,pev_classname,"large_present")
				}
			}
                }
        }
	}
}

public client_death(id)
{
	if(g_bonus[id] > 0)
	{
		g_bonus[id] = 0
	}
}

public FwdPreFramePost(iClient)
{
	if(is_user_connected(iClient))
	{
		if(g_bonus[iClient] == 3)
		{
    			fm_set_user_maxspeed(iClient, 350.0)
		}
		if(g_bonus[iClient] == 4)
		{
    			fm_set_user_maxspeed(iClient, 200.0)
		}
	}
}  

public forward_touch(ent,id)
{
	if(!pev_valid(ent))
		return FMRES_IGNORED
	
	static class[20]
	
	pev(ent,pev_classname,class,sizeof class - 1)
	
	if((!equali(class,"small_present") && !equali(class,"large_present")))
		return FMRES_IGNORED

	if((equali(class,"large_present") && (g_bonus[id] > 0)))
		return FMRES_IGNORED
	
	if(!is_user_alive(id))
		return FMRES_IGNORED
	
	set_pev(ent,pev_solid,SOLID_NOT)
	set_pev(ent,pev_effects,EF_NODRAW)
	set_task(get_pcvar_float(pcvar_respawn_time), "func_spawn", ent)
	
	if(equali(class,"small_present"))
	{
	switch(random_num(0,4))
	{
		case 0: 
		{
			fm_set_user_money(id, fm_get_user_money(id) + 500)
			set_hudmessage(255, 165, 0, 0.02, 0.73, 0, 6.0, 12.0)
			show_hudmessage(id, "[XMAS Gift] Mosul ti-a oferit 500$")
		}
		case 1:
		{
			fm_set_user_money(id, 16000)
			set_hudmessage(255, 165, 0, 0.02, 0.73, 0, 6.0, 12.0)
			show_hudmessage(id, "[XMAS Gift] Mosul ti-a oferit 16000$")
		}
		case 2:
		{
			fm_set_user_money(id, 0)
			set_hudmessage(255, 165, 0, 0.02, 0.73, 0, 6.0, 12.0)
			show_hudmessage(id, "[XMAS Gift] Mosul ti-a furat toti banii")
		}
		case 3:
		{
			fm_set_user_money(id, fm_get_user_money(id) - 500)
			set_hudmessage(255, 165, 0, 0.02, 0.73, 0, 6.0, 12.0)
			show_hudmessage(id, "[XMAS Gift] Mosul ti-a furat 500$")
		}
		case 4:
		{
			fm_give_item(id, "weapon_awp")
			set_hudmessage(255, 165, 0, 0.02, 0.73, 0, 6.0, 12.0)
			show_hudmessage(id, "[XMAS Gift] Mosul ti-a oferit un AWP")
		}
	}
	}
	if(equali(class,"large_present"))
	{
	switch(random_num(0,3))
	{
		case 0: 
		{
			fm_set_user_health(id, get_user_health(id) + 50)
			g_bonus[id] = 1
			large_present_hud(id)
		}
		case 1:
		{
			fm_set_user_gravity(id, 0.4)
			g_bonus[id] = 2
			large_present_hud(id)
		}
		case 2:
		{
			fm_set_user_maxspeed(id, 350.0)
			g_bonus[id] = 3
			large_present_hud(id)
		}
		case 3:
		{
			fm_set_user_maxspeed(id, 200.0)
			g_bonus[id] = 4
			large_present_hud(id)
		}
	}
	}
	
	return FMRES_IGNORED
}

public large_present_hud(id)
{
	if(is_user_alive(id))
	{
		if(g_bonus[id] > 0)
		{
			switch(g_bonus[id])
			{
				case 1:
				{
					set_hudmessage(0, 255, 0, 0.02, 0.73, 0, 6.0, 12.0)
					show_hudmessage(id, "[XMAS Gift] Viata+")
				}
				case 2:
				{
					set_hudmessage(0, 255, 0, 0.02, 0.73, 0, 6.0, 12.0)
					show_hudmessage(id, "[XMAS Gift] Gravitatie-")
				}
				case 3:
				{
					set_hudmessage(0, 255, 0, 0.02, 0.73, 0, 6.0, 12.0)
					show_hudmessage(id, "[XMAS Gift] Viteza+")
				}
				case 4:
				{
					set_hudmessage(200, 0, 0, 0.02, 0.73, 0, 6.0, 12.0)
					show_hudmessage(id, "[XMAS Gift] Viteza-")
				}
			}
			set_task(12.0, "large_present_hud", id)
		}
	}
}

public client_disconnect(id)
{
	g_bonus[id] = 0
}

/*====================================
========Inceput Fakemeta Util=======*/

stock fm_set_user_money(id,money,flash=1)
{
	set_pdata_int(id,OFFSET_CSMONEY,money,OFFSET_LINUX)

	message_begin(MSG_ONE,g_money,{0,0,0},id)
	write_long(money)
	write_byte(flash)
	message_end()
}

stock fm_get_user_money(id)
{
	return get_pdata_int(id,OFFSET_CSMONEY,OFFSET_LINUX)
}

stock fm_set_user_health(id, health)
{
	(health > 0) ? set_pev(id, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, id)

	return 1
}

stock fm_give_item(index, const item[]) {
	if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
		return 0

	new ent = fm_create_entity(item)
	if (!pev_valid(ent))
		return 0

	new Float:origin[3]
	pev(index, pev_origin, origin)
	set_pev(ent, pev_origin, origin)
	set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
	dllfunc(DLLFunc_Spawn, ent)

	new save = pev(ent, pev_solid)
	dllfunc(DLLFunc_Touch, ent, index)
	if (pev(ent, pev_solid) != save)
		return ent

	engfunc(EngFunc_RemoveEntity, ent)

	return -1
}

stock fm_set_user_gravity(index, Float:gravity = 1.0) {
	set_pev(index, pev_gravity, gravity)

	return 1
}

stock fm_set_user_maxspeed(index, Float:speed = -1.0) {
	engfunc(EngFunc_SetClientMaxspeed, index, speed);
	set_pev(index, pev_maxspeed, speed);

	return 1;
}

/*====================================
========Sfarsit Fakemeta Util=======*/

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

public SsInit(Float:mindist)
{
	new cmd[32]
	format(cmd, 15, "_ss_dump%c%c%c%c", random_num('A', 'Z'), random_num('A', 'Z'), random_num('A', 'Z'), random_num('A', 'Z'))
	register_cvar("sv_superspawns", SS_VERSION, (FCVAR_SERVER|FCVAR_SPONLY))
	register_concmd(cmd, "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========*/
Last edited by Nelutu16 on 08 Sep 2013, 02:48, edited 2 times in total.
RoyalServer
User avatar
cyby
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 1777
Joined: 16 Jul 2011, 21:46
Detinator Steam: Da
Detinator server CS: Da
Reputatie: Scripter eXtreamCS
Fost Moderator ajutator
Has thanked: 146 times
Been thanked: 396 times

06 Sep 2013, 06:16

| Afiseaza codul
/*
======================================
========== XMAS GIFTS 2.2 ============
======================================

Autor: KronoS
Versiune: 2.2
Site: www.eXtreamCS.com

Credite:
FakeNick - pentru pluginul Pick up present de unde a pornit tot
AlinHD - pentru pluginul de cadouri facut de el dar care nu l-a publicat
joropito - pentru Super Spawns
si alte persoane pentru informatii despre entitati

C-var-uri:
presents_respawn_time 60.0 (Dupa cat timp dupa ridicarea unui cadou apare altul pe harta)
presents_on_map 11 (Cate cadouri sa apara pe harta)
ATENTIE: Se calculeaza numarul c-var-ului - 1!!!
Daca puneti 11 or sa apara doar 10 cadouri!

Changelog:
_______________________________
V 2.0
-super spawns
-cvar: presents_on_map
_______________________________
V 2.1
-bug reparat: cadourile apareau in aer
-variabila globala
-FUN -> Fakemeta
-Hamsandwich
-optimizare mesaje HUD
_______________________________
V 2.2
-bug reparat: cadourile dispareau de pe harta
-FM_Think indepartat
_______________________________
*/

#include <amxmodx>
#include <amxmisc>

/* Module necesare */
#include <fakemeta>
#include <hamsandwich>
#include <engine>

/* INC-uri */
#include <cellarray>
#include <xs>

/* Model la cadouri */
new const model_present[][] = { "models/present/w_present.mdl","models/present/w_present2.mdl" }

/* Extras din Fakemeta Util */
#define fm_find_ent_by_class(%1,%2) engfunc(EngFunc_FindEntityByString, %1, "classname", %2)
#define fm_create_entity(%1) engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, %1))

/* Extras din Super Spawns */
#define SS_VERSION   "1.0"
#define SS_MIN_DISTANCE   500.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 }

/* Offset-uri */
#if cellbits == 32
const OFFSET_CSMONEY = 115
#else
const OFFSET_CSMONEY = 140
#endif
const OFFSET_LINUX  = 5
      
new pcvar_respawn_time, pcvar_presents_on_map
new g_money

public plugin_init()
{
	register_plugin("XMAS GIFTS", "2.2", "KronoS")
	  
	/*====================================
	==============Eventuri==============*/

	register_event("HLTV", "spawn_gifts", "a", "1=0", "2=0")

	register_forward(FM_Touch,"forward_touch")
	  
	/*====================================
	==============Cvar-uri==============*/

	pcvar_respawn_time = register_cvar("presents_respawn_time","60.0")
	pcvar_presents_on_map = register_cvar("presents_on_map", "11")

	SsInit(800.0)
	SsScan()

	g_money = get_user_msgid("Money")
}

public plugin_precache()
{
	new i
	for(i = 0; i < sizeof model_present; i++)
		engfunc(EngFunc_PrecacheModel,model_present)
}

public spawn_gifts()
{
	func_spawn()
}

public func_spawn()
{
	new Float:origin[3]
	new i

	for(i=0; i< get_pcvar_num(pcvar_presents_on_map); i++)
	{
		if(SsGetOrigin(origin))
		{
			new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
			if(pev_valid(ent))
			{
				engfunc(EngFunc_SetModel,ent,model_present[random_num(0,sizeof model_present - 1)])
				engfunc(EngFunc_SetOrigin, ent, origin)
				static Float:fMaxs[3] = { 2.0, 2.0, 4.0 }
				static Float:fMins[3] = { -2.0, -2.0, -4.0 }
				set_pev(ent,pev_solid,SOLID_BBOX)
				engfunc(EngFunc_SetSize,ent,fMins,fMaxs)
				engfunc(EngFunc_DropToFloor, ent)

				set_pev(ent,pev_classname,"small_present")
			}
		}
	}
}

public forward_touch(ent,id)
{
	if(!pev_valid(ent))
		return FMRES_IGNORED
   
	static class[20]
   
	pev(ent,pev_classname,class,sizeof class - 1)
   
	if(!equali(class,"small_present"))
		return FMRES_IGNORED
   
	if(!is_user_alive(id))
		return FMRES_IGNORED
   
	set_pev(ent,pev_solid,SOLID_NOT)
	set_pev(ent,pev_effects,EF_NODRAW)
	set_task(get_pcvar_float(pcvar_respawn_time), "func_spawn", ent)
   
	switch(random_num(0,2))
	{
		case 0:
		{
			fm_set_user_money(id, fm_get_user_money(id) + 3000)
			set_hudmessage(255, 165, 0, 0.02, 0.73, 0, 6.0, 12.0)
			show_hudmessage(id, "[XMAS Gift] Mosul ti-a oferit 3000$")
		}
		case 1:
		{
			fm_set_user_health(id, get_user_health(id) + 50)
			set_hudmessage(255, 165, 0, 0.02, 0.73, 0, 6.0, 12.0)
			show_hudmessage(id, "[XMAS Gift] Mosul ti-a oferit +50 HP.")
		}
		case 2:
		{
			set_pev(id, pev_armorvalue, pev(id, pev_armorvalue) + 50)
			set_hudmessage(255, 165, 0, 0.02, 0.73, 0, 6.0, 12.0)
			show_hudmessage(id, "[XMAS Gift] Mosul ti-a oferit +50 AP.")
		}
	}
	return FMRES_IGNORED
}

/*====================================
========Inceput Fakemeta Util=======*/

stock fm_set_user_money(id,money,flash=1)
{
	set_pdata_int(id,OFFSET_CSMONEY,money,OFFSET_LINUX)

	message_begin(MSG_ONE,g_money,{0,0,0},id)
	write_long(money)
	write_byte(flash)
	message_end()
}

stock fm_get_user_money(id)
{
	return get_pdata_int(id,OFFSET_CSMONEY,OFFSET_LINUX)
}

stock fm_set_user_health(id, health)
{
	(health > 0) ? set_pev(id, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, id)

	return 1
}

/*====================================
========Sfarsit Fakemeta Util=======*/

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

public SsInit(Float:mindist)
{
	new cmd[32]
	format(cmd, 15, "_ss_dump%c%c%c%c", random_num('A', 'Z'), random_num('A', 'Z'), random_num('A', 'Z'), random_num('A', 'Z'))
	register_cvar("sv_superspawns", SS_VERSION, (FCVAR_SERVER|FCVAR_SPONLY))
	register_concmd(cmd, "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========*/
93.114.82.17:27015 - Monster Invasion CO-OP Mod
Nelutu16
Membru, skill 0
Membru, skill 0
Posts: 40
Joined: 20 Oct 2012, 11:14
Detinator Steam: Nu
Has thanked: 7 times
Contact:

06 Sep 2013, 13:39

Mersi frumos cyby un om de nota 10 :)

Am o problema cu el , nu respawneaza cadourile , adica apar la inceputul hartii si dupa ce le iau pe toate nu mai apar deloc cere o fi problema?
User avatar
KrAiD.
Fost moderator
Fost moderator
Posts: 866
Joined: 15 Jun 2013, 12:14
Detinator Steam: Da
CS Status: Cat de cat activ :D
Detinator server CS: Nu
Reputatie: Fost Moderator ajutator
0.7 / 3
Has thanked: 14 times
Been thanked: 131 times
Contact:

06 Sep 2013, 13:45

ai pus cvar-urile astea?
C-var-uri:
presents_respawn_time 60.0 (Dupa cat timp dupa ridicarea unui cadou apare altul pe harta)
presents_on_map 11 (Cate cadouri sa apara pe harta)
User avatar
KronoS eXtream
Fost administrator
Fost administrator
Posts: 4378
Joined: 02 Apr 2009, 19:18
Detinator Steam: Da
Reputatie: Fost administrator
Fost detinator Zombie-Land.eXtream.Ro
Contribuitor
Fost Scripter eXtreamCS
Dezvoltator al listei de seriozitate eXtreamCS
Location: Bucharest
Has thanked: 551 times
Been thanked: 820 times
Contact:

06 Sep 2013, 13:47

Folosesti o versiunea mai veche ce are niste buguri majore.Uite aici cea mai noua versiune: http://www.extreamcs.com/forum/pluginur ... 91153.html
Nu efectuez tranzactii pe mess, skype etc. Aveti grija la indivizii care se dau drept mine!
Nu mai ofer suport asa ca nu imi mai trimiteti mesaje in legatura cu asta!


Zombie Plague Shade 1.2-debug1 [with Item Limiter] (12 September 2015) - Bombardier Branch
Nelutu16
Membru, skill 0
Membru, skill 0
Posts: 40
Joined: 20 Oct 2012, 11:14
Detinator Steam: Nu
Has thanked: 7 times
Contact:

06 Sep 2013, 14:11

Probabil ca asta e problema , am luat ultima versiune dar am nevoie iar de ajutor pentru modificarea lui... , daca se poate sa o modifice cineva cum am cerut mai sus , multumesc.
| Afiseaza codul
/*

Plugin: Xmas Gifts 2.3.2
Autor: KronoS # GG
Site: www.eXtreamCS.com

Credite:
 @FakeNick - pentru pluginul Pick up present de unde a pornit tot
 @joropito - pentru Super Spawns
 @Askhanar - pentru fixarea Super Spawns

Cvar-uri:
 - presents_respawn_time 60.0 (Dupa cat timp dupa ridicarea unui cadou apare altul pe harta)
 - presents_on_map 11 (Cate cadouri sa apara pe harta)
 ATENTIE: Se calculeaza numarul cvar-ului - 1!!!
 Daca puneti 11 or sa apara doar 10 cadouri!

Changelog:

* v2.3.2 - 28.12.2012
 - cadourile primeau respawn chiar daca timpul era setat pe 0.0

* v2.3.1 - 28.12.2012
 - cadourile nu primeau respawn

* v2.3 - 28.12.2012
 - cod infrumusetat
 - cadourile nu mai apareau dupa prima runda (fixat de Askhanar)

* v2.2 - 25.11.2010
 - bug reparat: cadourile dispareau de pe harta
 - FM_Think indeparta

* v2.1 - 17.11.2010
 - super spawns
 - cvar: presents_on_map
 - bug reparat: cadourile apareau in aer
 - variabila globala
 - FUN -> Fakemeta
 - Hamsandwich
 - optimizare mesaje HUD

* v1.0 - 14.11.2010
 - plugin publicat

*/

#include < amxmodx >
#include < amxmisc >
#include < fakemeta >
#include < hamsandwich >
#include < engine >
#include < cellarray >
#include < xs >

/* Extras din Fakemeta Util */
#define fm_find_ent_by_class( %1, %2 ) engfunc( EngFunc_FindEntityByString, %1, "classname", %2 )
#define fm_create_entity(%1) engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString, %1 ) )

/* Extras din Super Spawns */
#define SS_MIN_DISTANCE 500.0
#define SS_MAX_LOOPS 100000

#pragma semicolon 1;

/* Modele cadouri */
new const model_present[ ][ ] = { "models/present/w_present.mdl","models/present/w_present2.mdl" };

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 };

/* Offset-uri */
#if cellbits == 32
const OFFSET_CSMONEY = 115;
#else
const OFFSET_CSMONEY = 140;
#endif
const OFFSET_LINUX  = 5;
		
new pcvar_respawn_time, pcvar_presents_on_map;
new g_money;
new g_bonus[ 33 ];

public plugin_init( )
{
	register_plugin( "XMAS GIFTS", "2.3.2", "KronoS" );
		
	// Eventuri
	register_event( "HLTV", "spawn_gifts", "a", "1=0", "2=0" );
	RegisterHam( Ham_Spawn, "player", "round_start", 1 );
	RegisterHam( Ham_Killed, "player", "client_death", 1 );
    	RegisterHam( Ham_Item_PreFrame, "player", "FwdPreFramePost", 1 );
	register_forward( FM_Touch, "forward_touch" );
		
	// Cvar-uri
	pcvar_respawn_time = register_cvar( "presents_respawn_time", "60.0" );
	pcvar_presents_on_map = register_cvar( "presents_on_map", "11" );

	SsInit( 800.0 );
	SsScan( );
	XGIFTS_Spawn( );
	
	g_money = get_user_msgid( "Money" );
}

public plugin_precache( )
{
	for ( new i = 0; i < sizeof model_present ; i++ )
		engfunc( EngFunc_PrecacheModel, model_present[ i ] );
}

public spawn_gifts( )
	XGIFTS_Spawn( );

public round_start( id )
{
	if ( g_bonus[id] > 0 )
	{
		switch ( g_bonus[ id ] )
		{
			case 1: fm_set_user_health( id, get_user_health( id ) + 50 );
			case 2: fm_set_user_gravity( id, 0.4 );
		}
	}
}

public XGIFTS_Spawn( )
{
	new Float:fOrigin[ 3 ];

	for ( new i = 0; i < get_pcvar_num( pcvar_presents_on_map ) ; i++ )
	{
        	if ( SsGetOrigin( fOrigin ) )
			XGIFTS_Create( fOrigin );
	}
}

public XGIFTS_Create( const Float:fOrigin[ 3 ] )
{
	new ent = engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString, "info_target" ) );

	if ( pev_valid( ent ) )
	{
		engfunc( EngFunc_SetModel, ent, model_present[ random_num( 0, sizeof model_present - 1 ) ] );
		engfunc( EngFunc_SetOrigin, ent, fOrigin );
		static Float:fMaxs[ 3 ] = { 2.0, 2.0, 4.0 };
		static Float:fMins[ 3 ] = { -2.0, -2.0, -4.0 };
		set_pev( ent, pev_solid, SOLID_BBOX );
		engfunc( EngFunc_SetSize, ent, fMins, fMaxs );
		engfunc( EngFunc_DropToFloor, ent );

		switch ( random_num( 0, 1 ) )
		{
			case 0: set_pev( ent, pev_classname, "small_present" );
			case 1: set_pev( ent, pev_classname, "large_present" );
		}
	}
}

public XGIFTS_Respawn( iOrigin[ ] )
{
	new Float:fOrigin[ 3 ], auxOrigin[ 3 ];

	auxOrigin[ 0 ] = iOrigin[ 0 ];
	auxOrigin[ 1 ] = iOrigin[ 1 ];
	auxOrigin[ 2 ] = iOrigin[ 2 ];

	IVecFVec( auxOrigin, fOrigin );
	XGIFTS_Create( fOrigin );
}

public client_death( id )
{
	if ( g_bonus[ id ] > 0 )
		g_bonus[ id ] = 0;
}

public FwdPreFramePost( iClient )
{
	if ( is_user_connected( iClient ) )
	{
		if ( g_bonus[ iClient ] == 3 )
    			fm_set_user_maxspeed( iClient, 350.0 );
		else if ( g_bonus[ iClient ] == 4 )
    			fm_set_user_maxspeed( iClient, 200.0 );
	}
}  

public forward_touch( ent, id )
{
	if ( !pev_valid( ent ) )
		return FMRES_IGNORED;
	
	static class[ 20 ];
	
	pev( ent, pev_classname, class, sizeof class - 1 );
	
	if ( ( !equali( class, "small_present" ) && !equali( class, "large_present" ) ) )
		return FMRES_IGNORED;
	
	if ( !is_user_alive( id ) )
		return FMRES_IGNORED;
	
	set_pev( ent, pev_solid, SOLID_NOT );
	set_pev( ent, pev_effects, EF_NODRAW );

	if ( get_pcvar_float( pcvar_respawn_time ) > 0.0 )
	{
		new Float:flOrigin[ 3 ], iOrigin[ 3 ];
			
		entity_get_vector( ent, EV_VEC_origin, flOrigin );
			
		FVecIVec( flOrigin, iOrigin );

		set_task( get_pcvar_float( pcvar_respawn_time ), "XGIFTS_Respawn", _, iOrigin, 3  );
	}
	
	if ( equali( class, "small_present" ) )
	{
		switch ( random_num( 0, 4 ) )
		{
			case 0: 
			{
				fm_set_user_money( id, fm_get_user_money( id ) + 500 );
				set_hudmessage( 255, 165, 0, 0.02, 0.73, 0, 6.0, 12.0 );
				show_hudmessage( id, "[XMAS Gift] Mosul ti-a oferit 500$" );
			}
			case 1:
			{
				fm_set_user_money( id, 16000 );
				set_hudmessage( 255, 165, 0, 0.02, 0.73, 0, 6.0, 12.0 );
				show_hudmessage( id, "[XMAS Gift] Mosul ti-a oferit 16000$" );
			}
			case 2:
			{
				fm_set_user_money( id, 0 );
				set_hudmessage( 255, 165, 0, 0.02, 0.73, 0, 6.0, 12.0 );
				show_hudmessage( id, "[XMAS Gift] Mosul ti-a furat toti banii" );
			}
			case 3:
			{
				fm_set_user_money( id, fm_get_user_money( id ) - 500 );
				set_hudmessage( 255, 165, 0, 0.02, 0.73, 0, 6.0, 12.0 );
				show_hudmessage( id, "[XMAS Gift] Mosul ti-a furat 500$" );
			}
			case 4:
			{
				fm_give_item( id, "weapon_awp" );
				set_hudmessage( 255, 165, 0, 0.02, 0.73, 0, 6.0, 12.0 );
				show_hudmessage( id, "[XMAS Gift] Mosul ti-a oferit un AWP" );
			}
		}
	}
	else if ( equali( class,"large_present" ) && !g_bonus[ id ] )
	{
		switch (random_num(0,3))
		{
			case 0: 
			{
				fm_set_user_health( id, get_user_health( id ) + 50);
				g_bonus[ id ] = 1;
				large_present_hud( id );
			}
			case 1:
			{
				fm_set_user_gravity( id, 0.4 );
				g_bonus[ id ] = 2;
				large_present_hud( id );
			}
			case 2:
			{
				fm_set_user_maxspeed( id, 350.0 );
				g_bonus[ id ] = 3;
				large_present_hud( id );
			}
			case 3:
			{
				fm_set_user_maxspeed( id, 200.0 );
				g_bonus[ id ] = 4;
				large_present_hud( id );
			}
		}
	}
	
	return FMRES_IGNORED;
}

public large_present_hud( id )
{
	if ( is_user_alive( id ) )
	{
		if ( g_bonus[ id ] > 0 )
		{
			switch( g_bonus[ id ] )
			{
				case 1:
				{
					set_hudmessage( 0, 255, 0, 0.02, 0.73, 0, 6.0, 12.0);
					show_hudmessage( id, "[XMAS Gift] Viata+" );
				}
				case 2:
				{
					set_hudmessage( 0, 255, 0, 0.02, 0.73, 0, 6.0, 12.0 );
					show_hudmessage( id, "[XMAS Gift] Gravitatie-" );
				}
				case 3:
				{
					set_hudmessage( 0, 255, 0, 0.02, 0.73, 0, 6.0, 12.0 );
					show_hudmessage( id, "[XMAS Gift] Viteza+" );
				}
				case 4:
				{
					set_hudmessage( 200, 0, 0, 0.02, 0.73, 0, 6.0, 12.0 );
					show_hudmessage( id, "[XMAS Gift] Viteza-" );
				}
			}

			set_task( 12.0, "large_present_hud", id );
		}
	}
}

public client_disconnect( id )
	g_bonus[ id ] = 0;

// Fakemeta Util
stock fm_set_user_money( id, money, flash = 1 )
{
	set_pdata_int( id, OFFSET_CSMONEY, money, OFFSET_LINUX );

	message_begin( MSG_ONE, g_money, { 0, 0, 0 }, id );
	write_long( money );
	write_byte( flash );
	message_end( );
}

stock fm_get_user_money( id )
	return get_pdata_int( id, OFFSET_CSMONEY, OFFSET_LINUX );

stock fm_set_user_health( id, health )
{
	( health > 0 ) ? set_pev( id, pev_health, float( health ) ) : dllfunc( DLLFunc_ClientKill, id );

	return 1;
}

stock fm_give_item( index, const item[ ] )
{
	if ( !equal( item, "weapon_", 7 ) && !equal( item, "ammo_", 5 ) && !equal( item, "item_", 5 ) && !equal( item, "tf_weapon_", 10 ) )
		return 0;

	new ent = fm_create_entity( item) ;

	if ( !pev_valid( ent ) )
		return 0;

	new Float:origin[ 3 ];
	pev( index, pev_origin, origin );
	set_pev( ent, pev_origin, origin );
	set_pev( ent, pev_spawnflags, pev( ent, pev_spawnflags ) | SF_NORESPAWN );
	dllfunc( DLLFunc_Spawn, ent );

	new save = pev( ent, pev_solid );
	dllfunc( DLLFunc_Touch, ent, index );
	if ( pev( ent, pev_solid ) != save )
		return ent;

	engfunc( EngFunc_RemoveEntity, ent );

	return -1;
}

stock fm_set_user_gravity( index, Float:gravity = 1.0 )
{
	set_pev( index, pev_gravity, gravity );

	return 1;
}

stock fm_set_user_maxspeed( index, Float:speed = -1.0 )
{
	engfunc( EngFunc_SetClientMaxspeed, index, speed );
	set_pev( index, pev_maxspeed, speed );

	return 1;
}


// Super spawns
public SsInit( Float:mindist )
{
	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 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[ i ] += random_float( 0.0 - g_flOffsets[ i ], g_flOffsets[ i ] );

	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;
}
User avatar
cyby
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 1777
Joined: 16 Jul 2011, 21:46
Detinator Steam: Da
Detinator server CS: Da
Reputatie: Scripter eXtreamCS
Fost Moderator ajutator
Has thanked: 146 times
Been thanked: 396 times

06 Sep 2013, 14:52

| Afiseaza codul
/*

Plugin: Xmas Gifts 2.3.2
Autor: KronoS # GG
Site: http://www.eXtreamCS.com

Credite:
 @FakeNick - pentru pluginul Pick up present de unde a pornit tot
 @joropito - pentru Super Spawns
 @Askhanar - pentru fixarea Super Spawns

Cvar-uri:
 - presents_respawn_time 60.0 (Dupa cat timp dupa ridicarea unui cadou apare altul pe harta)
 - presents_on_map 11 (Cate cadouri sa apara pe harta)
 ATENTIE: Se calculeaza numarul cvar-ului - 1!!!
 Daca puneti 11 or sa apara doar 10 cadouri!

Changelog:

* v2.3.2 - 28.12.2012
 - cadourile primeau respawn chiar daca timpul era setat pe 0.0

* v2.3.1 - 28.12.2012
 - cadourile nu primeau respawn

* v2.3 - 28.12.2012
 - cod infrumusetat
 - cadourile nu mai apareau dupa prima runda (fixat de Askhanar)

* v2.2 - 25.11.2010
 - bug reparat: cadourile dispareau de pe harta
 - FM_Think indeparta

* v2.1 - 17.11.2010
 - super spawns
 - cvar: presents_on_map
 - bug reparat: cadourile apareau in aer
 - variabila globala
 - FUN -> Fakemeta
 - Hamsandwich
 - optimizare mesaje HUD

* v1.0 - 14.11.2010
 - plugin publicat

*/

#include < amxmodx >
#include < amxmisc >
#include < fakemeta >
#include < hamsandwich >
#include < engine >
#include < cellarray >
#include < xs >

/* Extras din Fakemeta Util */
#define fm_find_ent_by_class( %1, %2 ) engfunc( EngFunc_FindEntityByString, %1, "classname", %2 )
#define fm_create_entity(%1) engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString, %1 ) )

/* Extras din Super Spawns */
#define SS_MIN_DISTANCE 500.0
#define SS_MAX_LOOPS 100000

#pragma semicolon 1;

/* Modele cadouri */
new const model_present[ ][ ] = { "models/present/w_present.mdl","models/present/w_present2.mdl" };

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 };

/* Offset-uri */
#if cellbits == 32
const OFFSET_CSMONEY = 115;
#else
const OFFSET_CSMONEY = 140;
#endif
const OFFSET_LINUX  = 5;
		
new pcvar_respawn_time, pcvar_presents_on_map;
new g_money;

public plugin_init( )
{
	register_plugin( "XMAS GIFTS", "2.3.2", "KronoS" );
		
	// Eventuri
	register_event( "HLTV", "spawn_gifts", "a", "1=0", "2=0" );
	register_forward( FM_Touch, "forward_touch" );
		
	// Cvar-uri
	pcvar_respawn_time = register_cvar( "presents_respawn_time", "60.0" );
	pcvar_presents_on_map = register_cvar( "presents_on_map", "11" );

	SsInit( 800.0 );
	SsScan( );
	XGIFTS_Spawn( );
	
	g_money = get_user_msgid( "Money" );
}

public plugin_precache( )
{
	for ( new i = 0; i < sizeof model_present ; i++ )
		engfunc( EngFunc_PrecacheModel, model_present[ i ] );
}

public spawn_gifts( )
	XGIFTS_Spawn( );

public XGIFTS_Spawn( )
{
	new Float:fOrigin[ 3 ];

	for ( new i = 0; i < get_pcvar_num( pcvar_presents_on_map ) ; i++ )
	{
        	if ( SsGetOrigin( fOrigin ) )
			XGIFTS_Create( fOrigin );
	}
}

public XGIFTS_Create( const Float:fOrigin[ 3 ] )
{
	new ent = engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString, "info_target" ) );

	if ( pev_valid( ent ) )
	{
		engfunc( EngFunc_SetModel, ent, model_present[ random_num( 0, sizeof model_present - 1 ) ] );
		engfunc( EngFunc_SetOrigin, ent, fOrigin );
		static Float:fMaxs[ 3 ] = { 2.0, 2.0, 4.0 };
		static Float:fMins[ 3 ] = { -2.0, -2.0, -4.0 };
		set_pev( ent, pev_solid, SOLID_BBOX );
		engfunc( EngFunc_SetSize, ent, fMins, fMaxs );
		engfunc( EngFunc_DropToFloor, ent );
		set_pev( ent, pev_classname, "small_present" );
	}
}

public XGIFTS_Respawn( iOrigin[ ] )
{
	new Float:fOrigin[ 3 ], auxOrigin[ 3 ];

	auxOrigin[ 0 ] = iOrigin[ 0 ];
	auxOrigin[ 1 ] = iOrigin[ 1 ];
	auxOrigin[ 2 ] = iOrigin[ 2 ];

	IVecFVec( auxOrigin, fOrigin );
	XGIFTS_Create( fOrigin );
}

public forward_touch( ent, id )
{
	if ( !pev_valid( ent ) )
		return FMRES_IGNORED;
	
	static class[ 20 ];
	
	pev( ent, pev_classname, class, sizeof class - 1 );
	
	if ( !equali( class, "small_present" ))
		return FMRES_IGNORED;
	
	if ( !is_user_alive( id ) )
		return FMRES_IGNORED;
	
	set_pev( ent, pev_solid, SOLID_NOT );
	set_pev( ent, pev_effects, EF_NODRAW );

	if ( get_pcvar_float( pcvar_respawn_time ) > 0.0 )
	{
		new Float:flOrigin[ 3 ], iOrigin[ 3 ];
			
		entity_get_vector( ent, EV_VEC_origin, flOrigin );
			
		FVecIVec( flOrigin, iOrigin );

		set_task( get_pcvar_float( pcvar_respawn_time ), "XGIFTS_Respawn", _, iOrigin, 3  );
	}
	
	if ( equali( class, "small_present" ) )
	{
		set_hudmessage(255, 165, 0, 0.02, 0.73, 0, 6.0, 12.0);
		switch( random_num(0, 2))
		{
			case 0:
			{
				fm_set_user_money(id, fm_get_user_money(id) + 3000);
				show_hudmessage(id, "[XMAS Gift] Mosul ti-a oferit 3000$");
			}
			case 1:
			{
				fm_set_user_health(id, get_user_health(id) + 50);
				show_hudmessage(id, "[XMAS Gift] Mosul ti-a oferit +50 HP.");
			}
			case 2:
			{
				set_pev(id, pev_armorvalue, pev(id, pev_armorvalue) + 50);
				show_hudmessage(id, "[XMAS Gift] Mosul ti-a oferit +50 AP.");
			}
		}
	}
	
	return FMRES_IGNORED;
}

// Fakemeta Util
stock fm_set_user_money( id, money, flash = 1 )
{
	set_pdata_int( id, OFFSET_CSMONEY, money, OFFSET_LINUX );

	message_begin( MSG_ONE, g_money, { 0, 0, 0 }, id );
	write_long( money );
	write_byte( flash );
	message_end( );
}

stock fm_get_user_money( id )
	return get_pdata_int( id, OFFSET_CSMONEY, OFFSET_LINUX );

stock fm_set_user_health( id, health )
{
	( health > 0 ) ? set_pev( id, pev_health, float( health ) ) : dllfunc( DLLFunc_ClientKill, id );

	return 1;
}

// Super spawns
public SsInit( Float:mindist )
{
	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 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[ i ] += random_float( 0.0 - g_flOffsets[ i ], g_flOffsets[ i ] );

	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;
}
Vezi asa.
93.114.82.17:27015 - Monster Invasion CO-OP Mod
Nelutu16
Membru, skill 0
Membru, skill 0
Posts: 40
Joined: 20 Oct 2012, 11:14
Detinator Steam: Nu
Has thanked: 7 times
Contact:

06 Sep 2013, 16:09

Nu merge , pur si simplu nu mai apar cadourile.
User avatar
KrAiD.
Fost moderator
Fost moderator
Posts: 866
Joined: 15 Jun 2013, 12:14
Detinator Steam: Da
CS Status: Cat de cat activ :D
Detinator server CS: Nu
Reputatie: Fost Moderator ajutator
0.7 / 3
Has thanked: 14 times
Been thanked: 131 times
Contact:

06 Sep 2013, 16:36

de ce nu incerci asta ? :-? l-am folosit si merge foarte bine
Cadouri!
Cvar-uri

fmu_gifts_hp 5 ( cata viata primesti )
fmu_gifts_ap 5 ( cata armura primesti )
fmu_gifts_money 500 ( cati bani primesti )

fmu_enable_giftsrespawn 1 ( daca vor primi respawn cadourile < fix in pozitia de unde au disparut > ).
fmu_gifts_respawntime 45 ( dupa cate secunde reapare cadoul exact in acelasi loc )
fmu_gifts_num 35 ( cat e cadouri sa fie pe harta , depinde daca sunt gasite atatea.. cat i nvaloarea din cvar ).
Nelutu16
Membru, skill 0
Membru, skill 0
Posts: 40
Joined: 20 Oct 2012, 11:14
Detinator Steam: Nu
Has thanked: 7 times
Contact:

06 Sep 2013, 16:41

O sa incerc diseara KrAiD , multumesc .
Nelutu16
Membru, skill 0
Membru, skill 0
Posts: 40
Joined: 20 Oct 2012, 11:14
Detinator Steam: Nu
Has thanked: 7 times
Contact:

08 Sep 2013, 02:46

KrAiD. wrote:de ce nu incerci asta ? :-? l-am folosit si merge foarte bine
Cadouri!
Cvar-uri

fmu_gifts_hp 5 ( cata viata primesti )
fmu_gifts_ap 5 ( cata armura primesti )
fmu_gifts_money 500 ( cati bani primesti )

fmu_enable_giftsrespawn 1 ( daca vor primi respawn cadourile < fix in pozitia de unde au disparut > ).
fmu_gifts_respawntime 45 ( dupa cate secunde reapare cadoul exact in acelasi loc )
fmu_gifts_num 35 ( cat e cadouri sa fie pe harta , depinde daca sunt gasite atatea.. cat i nvaloarea din cvar ).

Mersi , merge perfect. Se poate da T/C
Post Reply

Return to “Cereri”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 40 guests