Combine 2 Plugins (Solved/abandoned)

Coding Help/Re-API Supported
Post Reply
User avatar
ArminC
Senior Member
Senior Member
Romania
Posts: 137
Joined: 6 years ago
Location: Bucharest
Contact:

Combine 2 Plugins (Solved/abandoned)

#1

Post by ArminC » 6 years ago

So I have a CZ Tutorial Box (for cs1.6) that you set message x to appear at y seconds (there is a list.ini), and a Dead/Spec box that use the same function that show the HP,NAME,AP etc. of the player you spec..
I think if I put the two plugins they will conflict because for example if you are dead and spectate, you have that hp box and after that if that y seconds passed there will appear another box with my set message x in front of that spec box :\

So my request:

1. Combine them [for example if you are dead-spectating box with hp to appear on left and messages on right (better variant) | or the messages box at y seconds to be off if you are dead/spectating (only if you can't manage to do the first method)]
2. Set a cvar (separate, for every one) to disable message at x seconds or/and spec hp..
3. Optimize/bug-fix if you found something wrong
4. Whatever you want :)

Plugins
1) CZ Box, Message at x interval: https://pastebin.com/ZWQ2aBNQ (Raheem liked this) or https://pastebin.com/STCGt8V5 -- same function but different author, coding.. (choose whatever plugin you like to combine with the spec plugin)
2) Spec plugin

Code: Select all

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <cstrike>

#define PLUGIN "Tutor Player Info"
#define VERSION "1.0"
#define AUTHOR "Ardonicek"
 

///////////////////
// TUTOR STOCKS //
//////////////////
#if defined _tutor_included
#endinput
#endif
#define _tutor_included

#if !defined _amxmodx_included
#include <amxmodx>
#endif

#define TASK_TUTOR 467666646

enum TutorColor 
{ 
	TUTOR_RED = 1, 
	TUTOR_BLUE, 
	TUTOR_YELLOW, 
	TUTOR_GREEN
}

new const g_TutorPrecache[][] = { "gfx/career/icon_!.tga", "gfx/career/icon_!-bigger.tga", "gfx/career/icon_i.tga", "gfx/career/icon_i-bigger.tga", "gfx/career/icon_skulls.tga", "gfx/career/round_corner_ne.tga", "gfx/career/round_corner_nw.tga", "gfx/career/round_corner_se.tga", "gfx/career/round_corner_sw.tga", "resource/TutorScheme.res", "resource/UI/TutorTextWindow.res" }

new g_MsgTutor
new g_MsgTutClose
new tutor_g_iMaxPlayers;

stock tutorInit(){
	g_MsgTutor = get_user_msgid("TutorText");
	g_MsgTutClose = get_user_msgid("TutorClose");
	
	tutor_g_iMaxPlayers = get_maxplayers();
}

stock tutorPrecache(){
	for(new i = 0; i < sizeof g_TutorPrecache; i++) 
	{	
		precache_generic(g_TutorPrecache[i]);
	}
}

stock tutorMake(id,TutorColor:Color,Float:fTime = 0.0,const szText[],any:...){
	new szMessage[512];
	vformat(szMessage, charsmax(szMessage), szText, 5);
	
	if(!id){
		message_begin(MSG_ALL,g_MsgTutor);
		write_string(szMessage);
		write_byte(0);
		write_short(0);
		write_short(0);
		write_short(1<<_:Color);
		message_end();
	}
	else if(is_user_connected(id))
	{
		message_begin(MSG_ONE_UNRELIABLE,g_MsgTutor,_,id);
		write_string(szMessage);
		write_byte(0);
		write_short(0);
		write_short(0);
		write_short(1<<_:Color);
		message_end();
	}
	
	if(fTime != 0.0){
		if(!id){
			for(new i = 1; i <= tutor_g_iMaxPlayers; i++)
			remove_task(i+TASK_TUTOR);
			
			
			set_task(fTime,"tutorClose",TASK_TUTOR)
		}
		else
		{
			remove_task(id+TASK_TUTOR)
			set_task(fTime,"tutorClose",id+TASK_TUTOR)
		}
	}
}

public tutorClose(iTask){
	new id = iTask - TASK_TUTOR;
	
	if(!id){
		message_begin(MSG_ALL,g_MsgTutClose)
		message_end()
	}
	else if(is_user_connected(id))
	{
		message_begin(MSG_ONE_UNRELIABLE,g_MsgTutClose,_,id)
		message_end()
	}
}


// Spectator target
const PEV_SPEC_TARGET = pev_iuser2;

/////////////////
// PLUGIN CODE //
/////////////////

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	tutorInit();
}

public plugin_precache(){
	tutorPrecache()
}

public client_putinserver(id) 
{ 
    set_task(2.0, "showinfo", id, _, _, "b")
} 

public showinfo(id){
	if(!is_user_alive(id))
	{
		new idSpec;
		new iPlayerName[32];
		new Ping, Loss; 
		idSpec = pev(id, PEV_SPEC_TARGET);
		get_user_ping(idSpec, Ping, Loss);
		get_user_name(idSpec, iPlayerName, 31);
		tutorMake(id, TUTOR_YELLOW, 2.0,"Target Name: %s^nTarget Health: %i^nTarget Armor: %i^nTarget Ping: %d ", iPlayerName, get_user_health(idSpec), get_user_armor(idSpec), Ping);
	}
}
Thanks!

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 14 guests