Cerere modificare/optimizare plugin

Categoria unde puteti cere pentru tutoriale.

Moderators: Moderatori ajutatori, Moderatori, Echipa eXtreamCS.com

Post Reply
User avatar
@LeX
Membru, skill 0
Membru, skill 0
Posts: 18
Joined: 09 Feb 2015, 19:28
Detinator Steam: Da
SteamID: STEAM_0:1:452037874
Fond eXtream: 0
Location: Brasov
Has thanked: 1 time

10 Jan 2020, 17:21

Salu, am acest plugin:
vip_respawn.sma | Afiseaza codul
#include <amxmodx>
#include <cstrike>
#include <amxmisc>
#include <fun>
#include <hamsandwich>
#include <engine>

#define COUNTDOWN_TIME 10
#define HUD_CHANNEL 1

static const PLUGIN[] 	= "Vip Respawn"
static const AUTHOR[] 	= "x."
static const VERSION[]	= "x"

#define ADMIN_GOLD ADMIN_LEVEL_H
#define ADMIN_SILVER ADMIN_ADMIN

#define REMOVE_FLAG_G "t"
#define REMOVE_FLAG_S "y"

#define SCOREATTRIB_NONE    0
#define SCOREATTRIB_DEAD    ( 1 << 0 )
#define SCOREATTRIB_BOMB    ( 1 << 1 )
#define SCOREATTRIB_VIP     ( 1 << 2 )

new Countdown[33];

enum
{
    print_team_default = 0,
    print_team_grey = -1,
    print_team_red = -2,
    print_team_blue = -3,
};

new 	
	cvar_viata_g, 
	cvar_armura_g, 
	cvar_viata_s, 
	cvar_armura_s,
	cvar_vip_out,
	cvar_vip_in,
	cvar_vip_tag,
	cvar_vip_maxhp,
	cvar_vip_maxap,
	cvar_vip_ap_hs_kill,
	cvar_vip_hp_hs_kill,
	cvar_vip_hp_kill,
	cvar_vip_ap_kill,
	cvar_vip_show,
	cvar_vip_bulletdmg_mode,
	cvar_vip_speed,
	cvar_vip_resetvip_mode;


new const Float: g_flCoords[][] = 
{
	{ 0.50, 0.40 },
	{ 0.56, 0.44 },
	{ 0.60, 0.50 },
	{ 0.56, 0.56 },
	{ 0.50, 0.60 },
	{ 0.44, 0.56 },
	{ 0.40, 0.50 },
	{ 0.44, 0.44 }
};

new 	g_iPosition[33],
	g_iSize;
	
new const RMaps[][] = 
{
	"35hp",
	"35hp_2",
	"31hp",
	"1hp",
	"100hp"
	// etc
};

public plugin_init () 
{
	register_plugin(PLUGIN, VERSION, AUTHOR);
	register_cvar("Vip_Vaga", VERSION, FCVAR_SERVER | FCVAR_SPONLY);
	register_concmd("amx_test1", "test", ADMIN_GOLD)
	register_concmd("amx_test2", "test", ADMIN_SILVER)
	
	register_clcmd("say /vip", "vip_info");
	register_clcmd("say /resetvip", "resetvip")
	register_clcmd("say", "handle_say");
	register_clcmd("say_team", "handle_say");
	
	cvar_viata_s = register_cvar("vip_silver_hp", "120")
	cvar_armura_s = register_cvar("vip_silver_am", "120")
	
	cvar_viata_g = register_cvar("vip_gold_hp", "120")
	cvar_armura_g = register_cvar("vip_gold_am", "120")
	
	cvar_vip_out = register_cvar("vip_out", "1")
	cvar_vip_in = register_cvar("vip_in", "1")
	
	cvar_vip_tag = register_cvar("vip_tag", "Un Tag ceva")
	
	
	cvar_vip_maxhp = register_cvar("vip_maxhp", "120");
	cvar_vip_maxap = register_cvar("vip_maxap", "120");
	
	cvar_vip_hp_kill = register_cvar("vip_hp_kill", "15");	
	cvar_vip_ap_kill = register_cvar("vip_ap_kill", "15");
	
	cvar_vip_hp_hs_kill = register_cvar("vip_hp_hs_kill", "20")
	cvar_vip_ap_hs_kill = register_cvar("vip_hp_ap_kill", "20")
	
	cvar_vip_bulletdmg_mode = register_cvar("vip_bullet_mode", "3")
	
	cvar_vip_speed = register_cvar("vip_speed", "300");
	
	cvar_vip_show = register_cvar("vip_show", "1");
	
	cvar_vip_resetvip_mode = register_cvar("vip_restscore_mode", "1");

	g_iSize = sizeof(g_flCoords);
	
	register_message(get_user_msgid( "ScoreAttrib" ), "MessageScoreAttrib");	
	
	RegisterHam(Ham_Spawn, "player", "cmdSpawn", 1);
	register_event("ResetHUD", "resetModel", "b");
}

public test(id, level, cid)
{
	if (!cmd_access(id, level, cid, 2))
		return 1;
	console_print(id, "Test cu succes")
	return 1
}

public client_putinserver(id)
{
	if(!(get_user_flags(id) & ADMIN_GOLD) || !(get_user_flags(id) & ADMIN_SILVER) )
		return 1;
		
	if(get_pcvar_num(cvar_vip_in) == 1)
	{
		new tag[32], name[32];

		get_pcvar_string(cvar_vip_tag, tag, charsmax(tag)); 
		get_user_name(id, name, charsmax(name)); 

		if(get_user_flags(id) & ADMIN_GOLD )
		{
			client_print_color(0, 0, "^1(^3%s^1) VIP GOLD: ^4%s ^1s-a conectat.", tag, name); 
		}
		
		if(get_user_flags(id) & ADMIN_SILVER )
		{
			client_print_color(0, 0, "^1(^3%s^1) VIP SILVER: ^4%s ^1s-a conectat.", tag, name); 
		}
		
		return 1;
	}
	
	return 1;
}

public client_disconnected(id)
{
	
	if(!(get_user_flags(id) & ADMIN_GOLD) || !(get_user_flags(id) & ADMIN_SILVER))
		return 1;
		
	if(get_pcvar_num(cvar_vip_out) == 1)
	{
		new tag[32], name[32];

		get_pcvar_string(cvar_vip_tag, tag, charsmax(tag)); 
		get_user_name(id, name, charsmax(name)); 
		if(get_user_flags(id) & ADMIN_GOLD)
		{
			client_print_color(0, 0, "^1(^3%s^1) VIP GOLD: ^4%s ^1s-a deconectat.", tag, name); 
		}
		
		if(get_user_flags(id) & ADMIN_SILVER)
		{
			client_print_color(0, 0, "^1(^3%s^1) VIP SILVER: ^4%s ^1s-a deconectat.", tag, name); 
		}

		return 1;
	}
	return 1;


}
public plugin_precache() precache_model("models/player/vip_model/vip_model.mdl");

public vip_info(id) show_motd(id, "/addons/amxmodx/configs/vip_info.html");


public cmdSpawn (id) 
{
	if(!is_user_alive(id) || !(get_user_flags(id) & ADMIN_GOLD) || !(get_user_flags(id) & ADMIN_SILVER))
		return 1;
		
	new MapName[32]; 
	get_mapname(MapName, sizeof(MapName));
	for (new i = 0; i < sizeof (RMaps); i ++)
	{
		if(equali (MapName, RMaps))
		{
			remove_user_flags(id, read_flags(REMOVE_FLAG_S));
			remove_user_flags(id, read_flags(REMOVE_FLAG_G));
			return 1
		}
	}
		
	if(get_user_flags(id) & ADMIN_GOLD)	
	{
		set_user_armor(id, get_pcvar_num(cvar_armura_g));
		set_user_health(id, get_pcvar_num(cvar_viata_g));
	}
	
	if(get_user_flags(id) & ADMIN_SILVER)
	{
		set_user_armor(id, get_pcvar_num(cvar_armura_s));
		set_user_health(id, get_pcvar_num(cvar_viata_s));
	}
	
	return 0;
}

public resetModel(id, level, cid)
{
	if(!is_user_alive(id) || !(get_user_flags(id) & ADMIN_GOLD))
		return 1;	
		
	cs_set_user_model(id, "vip_model")
	client_cmd(id, "cl_minmodels 0");
	
	return 1;
}

public client_death(killer, victim, hitplace)
{
	if(!(get_user_flags(killer) & ADMIN_GOLD) || !(get_user_flags(killer) & ADMIN_SILVER))
		return 1;
		
	new VIP_MAXHP = get_pcvar_num(cvar_vip_maxhp);
	new VIP_HP = get_user_health(killer);
	new VIP_MAXAP = get_pcvar_num(cvar_vip_maxap);
	new VIP_AP = get_user_armor(killer);
	
	if((killer != victim) && !(hitplace == HIT_HEAD))
	{
		if(VIP_HP >= VIP_MAXHP)
		{
			set_user_health(killer, get_pcvar_num(cvar_vip_maxhp));
		}
		
		else
		{
			set_user_health(killer, get_user_health(killer) + get_pcvar_num(cvar_vip_hp_kill));
		}
	
		if(VIP_AP >= VIP_MAXAP)
		{
			set_user_armor(killer, get_pcvar_num(cvar_vip_maxap));
		}
		
		else
		{
			set_user_armor(killer, get_user_armor(killer) + get_pcvar_num(cvar_vip_ap_kill));
		}
	}
	if(hitplace == HIT_HEAD)
	{
		if(VIP_HP >= VIP_MAXHP)
		{
			set_user_health(killer, get_pcvar_num(cvar_vip_maxhp));
		}
		
		else
		{
			set_user_health(killer, get_user_health(killer) + get_pcvar_num(cvar_vip_hp_hs_kill));
		}
	
		if(VIP_AP >= VIP_MAXAP)
		{
			set_user_armor(killer, get_pcvar_num(cvar_vip_maxap));
		}
		
		else
		{
			set_user_armor(killer, get_user_armor(killer) + get_pcvar_num(cvar_vip_ap_hs_kill));
		}
	}
	return 1;
}

public handle_say(id)
{
	new said[192];
	read_args(said,192);
	remove_quotes(said)
	
	if(contain(said, "/vips") != -1)
		set_task(0.1,"print_adminlist",id);
		
	return 0;
}

public print_adminlist(user)
{
	if(get_pcvar_num(cvar_vip_show) == 1)
	{
		new tag[32];
		get_pcvar_string(cvar_vip_tag, tag, charsmax(tag));
	
		new adminnames[33][32];
		new message[256];
		new id, count, x, len;

		for(id = 1 ; id <= get_maxplayers() ; id++)
			if(is_user_connected(id))
				if((get_user_flags(id) & ADMIN_GOLD) || (get_user_flags(id) & ADMIN_SILVER) )
					get_user_name(id, adminnames[count++], charsmax(adminnames[ ]));
					
    
		len = format(message, 255, "^1(^3%s^1) VIP-ii online sunt:^4 " ,tag);
		if(count > 0)
		{
			for(x = 0 ; x < count ; x++)
			{
				if(get_user_flags(user) & ADMIN_GOLD)
				{
					len += format(message[len], 255-len, "(Gold) - %s%s ", adminnames[x], x < (count-1) ? ", ":"");
				}
				
				if(get_user_flags(user) & ADMIN_SILVER)
				{
					len += format(message[len], 255-len, "(Silver) - %s%s ", adminnames[x], x < (count-1) ? ", ":"");
				}
					
				if(len > 96)
				{
					print_message(user, message);
					len = format(message, 255, " ");
				}
			}
			
			print_message(user, message);
		}
		
		else
		{ 
			client_print_color(0, 0, "^1(^3%s^1) Nu sunt ^4VIP^1-i online.", tag);
		}			
	}
	return 0;  
}

print_message(id, msg[])
{
	message_begin(MSG_ONE, get_user_msgid("SayText"), {0,0,0}, id);
	write_byte(id);
	write_string(msg);
	message_end();
}

public client_damage(iAttacker, iVictim, iDamage)
{
	if(get_pcvar_num(cvar_vip_bulletdmg_mode) == 0)
		return 1;
	if(get_pcvar_num(cvar_vip_bulletdmg_mode) == 1)
		if(!(get_user_flags(iAttacker) & ADMIN_GOLD))
			return 1;
	if(get_pcvar_num(cvar_vip_bulletdmg_mode) == 2)
		if(!(get_user_flags(iAttacker) & ADMIN_SILVER))
			return 1;
	if(get_pcvar_num(cvar_vip_bulletdmg_mode) == 3)
		if(!(get_user_flags(iAttacker) & ADMIN_GOLD) || !(get_user_flags(iAttacker) & ADMIN_SILVER))
			return 1;

	if(++g_iPosition[iAttacker] == g_iSize)
		g_iPosition[iAttacker] = 0;
	
	set_dhudmessage(random_num(0, 255), random_num(0, 255), random_num(0, 255), Float: g_flCoords[g_iPosition[iAttacker]][0], Float: g_flCoords[g_iPosition[iAttacker]][1], 0, 0.1, 2.5, 0.02, 0.02);
	show_dhudmessage(iAttacker, "%i", iDamage);


	return 1;
}

public grenade_throw(id, ent, weap)
{
	if ( !(get_user_flags(id) & ADMIN_GOLD) )
		return 1
		
	if (weap != CSW_HEGRENADE)
		return 1;
		
	Countdown[id] = COUNTDOWN_TIME - 1;
    
	ShowHudMessage(id, COUNTDOWN_TIME);
	set_task(1.0, "OnResupply", id, _, _, "a", COUNTDOWN_TIME);
	
	return 1
}

public OnResupply(id)
{    
	if (!is_user_alive(id) || user_has_weapon(id, CSW_HEGRENADE))
	{
		remove_task(id);
		return;
	}
    
	if (Countdown[id])
		ShowHudMessage(id, Countdown[id]--);
	else
		give_item(id, "weapon_hegrenade");
}
        
ShowHudMessage(id, countdown)
{
    set_hudmessage(255, 255, 255, 0.10, 0.25, _, _, 1.1, 0.0, 0.0, HUD_CHANNEL);
    show_hudmessage(id, "Next HE Grenade in %d", countdown);
} 


public MessageScoreAttrib(iMsgID, iDest, iReceiver)
{
    new iPlayer = get_msg_arg_int(1);
    
    if(is_user_connected(iPlayer) && (get_user_flags(iPlayer) & ADMIN_GOLD) || (get_user_flags(iPlayer) & ADMIN_SILVER))
	{
		set_msg_arg_int(2, ARG_BYTE, is_user_alive(iPlayer) ? SCOREATTRIB_VIP : SCOREATTRIB_DEAD);
	}
}


public client_PreThink(id) 
{
	if(get_user_flags(id) & ADMIN_GOLD)	
		set_user_maxspeed(id, float(get_pcvar_num(cvar_vip_speed)));
		
}

public resetvip(id)
{
	new MapName[32]; 
	get_mapname(MapName, sizeof(MapName));
	for (new i = 0; i < sizeof (RMaps); i ++)
	{
		if(equali (MapName, RMaps))
		{
			client_print_color(id, -2, "^3Detectare: '^4Harta interzisa^3', Pe aceasta harta functia '^4VIP^3' este dezactivata")
			return 1
		}
	}

		
	if((get_pcvar_num(cvar_vip_resetvip_mode) == 0) || (get_pcvar_num(cvar_vip_resetvip_mode) >= 3) )
	{
		client_print_color(id, -2, "^3Optiunea '^4Reset Score^3' pentru '^4VIP^3' a fost dezactivata de catre ^4Fondatori ^3!")
		return 1;
	}
	
	if(get_pcvar_num(cvar_vip_resetvip_mode) == 1)
	{
		if( get_user_flags(id) & ADMIN_GOLD)
		{
			cs_set_user_deaths(id, 0)
			cs_set_user_deaths(id, 0)
		}
	}
	
	if(get_pcvar_num(cvar_vip_resetvip_mode) == 2)
	{
		if( (get_user_flags(id) & ADMIN_GOLD) || (get_user_flags(id) & ADMIN_SILVER) )
		{
			cs_set_user_deaths(id, 0)
			cs_set_user_deaths(id, 0)
		}
	}
	
	return 1
}


pana ieri functiona perfect
am adaugat speed, resetvip si grenada la fiecare 10 sec.
dupa ce am facut asta, nu mai primeai hp/ap per spawn
/vips nu mai mergea...
Am crezut ca este de la speed, grenada sau resetvip asa ca le-am scos, Apoi... tot la fel...aceeasi problema, indiferent de situatie
la "client_damage" imi apare in consola:
Navive error: get_pcvar_num
la toate niniile ce tin de acel sens
alta eroare nu imi aparea dar nu primeam nici hp nici ap


Daca ma puteti ajuta...
Mai spun o data, nu sunt scripter, nu vreau sa imi spuneti ca "e aiurea scriptat la x trebuia x" sau "e un plugin alandala" sau "lasa-te de scripting" , etc, imi puteti spune cum sa fac si un exemplu sa inteleg, chiar ar fi superb :)
Daca puteti sa rezolvati pluginul si numai daca doriti sa il optimizati daca este cazul v-as ramane indatorat :)


Ps. is cam la inceput de drum, nu prea stiu nimic dar incerc ca imi place si vreau sa invat mai mult dar in ritmul meu :)
eXtreamSHOP
User avatar
@LeX
Membru, skill 0
Membru, skill 0
Posts: 18
Joined: 09 Feb 2015, 19:28
Detinator Steam: Da
SteamID: STEAM_0:1:452037874
Fond eXtream: 0
Location: Brasov
Has thanked: 1 time

13 Jan 2020, 17:15

Nimeni ???
Post Reply

Return to “Cereri”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests