Raised This Month: $ Target: $400
 0% 

Extra functions for Engine + Core


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 04-04-2005 , 21:11   Extra functions for Engine + Core
Reply With Quote #1

Code:
static cell AMX_NATIVE_CALL system_cmd(AMX *amx, cell *params)
{
    int len;
    char *cmd = MF_GetAmxString(amx, params[1], 0, &len);
    system( cmd );

	return 1;
}

static cell AMX_NATIVE_CALL is_user_outside(AMX *amx, cell *params)
{
   cell *pOrigin = MF_GetAmxAddr(amx,params[1]);

   Vector vOrigin;

   vOrigin.x = pOrigin[0];
   vOrigin.y = pOrigin[1];
   vOrigin.z = pOrigin[2];

   while (UTIL_PointContents(vOrigin) == -1)
   {
	   vOrigin.z+=4;
   }

   if (UTIL_PointContents(vOrigin) == -6)
	   return 1;
   else
	   return -1;
}

static cell get_class_by_view(AMX *amx, cell *params)
{
	int index = params[1];

	if (index == 0)
		return -1;

	edict_t *pPlayer = INDEXENT(index);

	Vector start, end;

	MAKE_VECTORS(pPlayer->v.v_angle);

	TraceResult tr;

	start = pPlayer->v.origin + pPlayer->v.view_ofs;
	end = pPlayer->v.origin + pPlayer->v.view_ofs + gpGlobals->v_forward * 9999;

	TRACE_LINE(start, end, dont_ignore_monsters, pPlayer, &tr);

	if (tr.pHit)
	{
		int entid = ENTINDEX(tr.pHit);
		edict_t *pEntity = INDEXENT(entid);
		return ENTINDEX(pEntity);
	}
	else
	{
		return -1;
	}
	
	return -1;
}

static cell rotate_entity(AMX *amx, cell *params)
{
	int entindex = params[1];
	int xaxis = params[2];
	int yaxis = params[3];
	int zaxis = params[4];

	if (entindex == 0)
		return -1;

	edict_t *pEntity = INDEXENT(entindex);

	pEntity->v.angles.x = xaxis;
	pEntity->v.angles.y = yaxis;
	pEntity->v.angles.z = zaxis;

	return 1;
}


static cell create_monster(AMX *amx, cell *params)
{
	int *len;
	int custom = params[4];
	int xaxis = params[5];
	int yaxis = params[6];
	int zaxis = params[7];
	int health = params[8];
	int render_fx = params[9];
	int render_mode = params[10];
	int render_amt = params[11];
	int render_r = params[12];
	int render_g = params[13];
	int render_b = params[14];
	int gravity = params[15];
	int solid = params[16];
	int movetype = params[17];
	int spawnflags = params[18];

	Vector EntLoc;

	char* sEntname = MF_GetAmxString(amx, params[1], 0, len);
	char* sModelPath = MF_GetAmxString(amx, params[2], 1, len);

	cell *Entorigin = MF_GetAmxAddr(amx, params[3]);

	EntLoc.x = Entorigin[0];
	EntLoc.y = Entorigin[1];
	EntLoc.z = Entorigin[2];

	edict_t *pEntity = CREATE_NAMED_ENTITY(MAKE_STRING(sEntname));

	pEntity->v.classname = MAKE_STRING(sEntname);
	pEntity->v.health = health;
	pEntity->v.renderfx = render_fx;
	pEntity->v.rendermode = render_mode;
	pEntity->v.renderamt = render_amt;
	pEntity->v.rendercolor.x = render_r;
	pEntity->v.rendercolor.y = render_g;
	pEntity->v.rendercolor.z = render_b;
	pEntity->v.angles.x = xaxis;
	pEntity->v.angles.y = yaxis;
	pEntity->v.angles.z = zaxis;
	pEntity->v.gravity = gravity;
	pEntity->v.solid = solid;
	pEntity->v.spawnflags = spawnflags;
	pEntity->v.movetype = movetype;

	SET_ORIGIN(pEntity, (const Vector) EntLoc);
	
	if (custom == 0)
	{
		// Do Nothing
	}
	else
	{
		SET_MODEL(pEntity, sModelPath);
	}

	MDLL_Spawn(pEntity);

	return g_engfuncs.pfnIndexOfEdict(pEntity);
}

static cell get_texture(AMX *amx, cell *params)
{
	int ignoreindex = params[1];
	int len = params[3];

	char out[64];

	edict_t *pPlayer = INDEXENT(ignoreindex);

	Vector start, end, v_xhair_end;

	MAKE_VECTORS(pPlayer->v.v_angle);

	TraceResult tr;

	start = pPlayer->v.origin + pPlayer->v.view_ofs;
	end = pPlayer->v.origin + pPlayer->v.view_ofs + gpGlobals->v_forward * 9999;

	TRACE_LINE(start, end, ignore_monsters, pPlayer, &tr);

	if (tr.pHit)
	{
		edict_t *pWorldspawn = g_engfuncs.pfnPEntityOfEntIndex(0);

		pWorldspawn = tr.pHit;

		const char *Texture = TRACE_TEXTURE(pWorldspawn, start, end);	
	
	}
	
	return MF_SetAmxString(amx, params[2], out, len);
}
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
VarmVaffel
Member
Join Date: Feb 2005
Location: Norway
Old 04-05-2005 , 05:52  
Reply With Quote #2

Handy functions, looking great
VarmVaffel is offline
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 04-05-2005 , 12:49  
Reply With Quote #3

They are other peoples functions.
Basicall, these are all the good functions I could scrape from the AMX modules. Pretty pathetic that these are the only good functions that AMXX doesnt already include ^^;
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
VarmVaffel
Member
Join Date: Feb 2005
Location: Norway
Old 04-06-2005 , 06:12  
Reply With Quote #4

How about inculding some windows functions like ShellExecute or similiar, or maybe funcs for some standard unix cmd's?

Think that could be handy?
VarmVaffel is offline
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 04-06-2005 , 09:56  
Reply With Quote #5

Maybe, if I have time.

I'm working on things in this order:

Code:
enum Mels_life {
Amy = 1, <- Wife, supercedes everything
Sleep,
Vital Essentials,
TSXMOD <- Currently here,
BB,
S&I,
P13, <- HL2 Mod, release May 16
SVEN,
REGION,
VS,
School, <- F'in exams in a few weeks
Other Stuff,
}
As you can see, it takes a while to get down to Other Stuff, even with hyper threading and multi-tasking.

So yeah, it'll be a while. But the good news is, S&I MODULE RELEASE ON SATURDAY!! WOOHOO!!
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
VarmVaffel
Member
Join Date: Feb 2005
Location: Norway
Old 04-06-2005 , 10:50  
Reply With Quote #6

hehe, I see...
Guess I could take care of it then if anybody wants such a module.
I don't need such a module yet, so just ask if anybody reads this post and goes "Damn, thats just the kind of module I need!", then just pm me or something.

Btw, so youre making a hl2 mod? Got a webpage for that?
VarmVaffel is offline
BAILOPAN
Join Date: Jan 2004
Old 04-06-2005 , 11:59  
Reply With Quote #7

I'll add everything but system_cmd()... since it doesn't fork or execute in a thread, it would literally halt the server until the command finishes.

This would need to be in a separate module called "system" or something, which would give you access to things like fork(), exec(), or on windows, CreateProcess.

The other issue is that the console window would be the same as stdout, stdin, and stderr.. so it would be difficult to redirect/see output that is printed to the screen,
__________________
egg
BAILOPAN is offline
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 04-06-2005 , 13:24  
Reply With Quote #8

Might I suggest is_user_outside being added to the default amxx, along with the other is_user stuff?

Never really expected these to every get in ^^; Just needed a few of em.
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:32.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode