Raised This Month: $ Target: $400
 0% 

Help with TravTrie.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 02-04-2016 , 02:52   Help with TravTrie.
Reply With Quote #1

I'm realy confusing at using celltravtrie library, i have some questions:

- In my code i use TrieKeyExists native to check if exist an Key exist on the g_tBlock var, but i create g_tBlock using TravTrie, is giving me an warning with Tag Mismach, but working compile and working scan if key exist. I should let how is it or exist anoter native who replace that for TravTrie library?

- How to use Iterator to save key in trie when map changed? That's realy confuse for me.

* I realy wanna learn how to use TravTrie, seems realy useful and i wanna use on future, thanks

Here's the code:

Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <celltravtrie>

new const PLUGIN[]	= "Pick Up Manager",
	 VERSION[]	= "0.2",
	  AUTHOR[]	= "Craxor";

new TravTrie:g_tBlock;
new giTypeCvar;

public plugin_init( )
{
	register_plugin
	(
		.plugin_name = PLUGIN, 
		.version     = VERSION, 
		.author      = AUTHOR
	)

	g_tBlock = TravTrieCreate( );

	register_forward( FM_Touch, "WeaponTouchFwd" );

	register_concmd( "amx_pum_addkey" ,"addkey", ADMIN_BAN, " < Weapon key-name to block > ");
	register_concmd( "amx_pum_remkey" ,"remkey", ADMIN_BAN, " < Weapon key-name to block > ");

	giTypeCvar = register_cvar("pum_type", "1" );
}

public addkey( id, level, cid )
{
	if( !cmd_access( id, level, cid, 2 ) )
		return PLUGIN_HANDLED;

	new Arg1[16];
	read_argv( 1, Arg1, charsmax( Arg1 ) );

	new adder[64];
	formatex( adder, charsmax( adder ), "models/w_%s.mdl", Arg1 );

	TravTrieSetCell( g_tBlock, adder, 1 );
	return PLUGIN_HANDLED;
}

public remkey( id, level, cid )
{
	if( !cmd_access( id, level, cid, 2 ) )
		return PLUGIN_HANDLED;

	new Arg1[16];
	read_argv( 1, Arg1, charsmax( Arg1 ) );

	new adder[64];
	formatex( adder, charsmax( adder ), "models/w_%s.mdl", Arg1 );

	TravTrieDeleteKey( g_tBlock, adder );
	return PLUGIN_HANDLED;
}
 
public WeaponTouchFwd( Entity, Id )
{
	if ( !pev_valid( Entity ) || !pev_valid( Id ) || !is_user_alive( Id ) )
		return FMRES_IGNORED;

        new Model[32];
        pev(Entity, pev_model, Model, charsmax( Model ) );

	new iCvarValue = get_pcvar_num( giTypeCvar );

	if( TrieKeyExists( g_tBlock, Model ) )
	{
		switch( iCvarValue )
		{
			case 1: engfunc( EngFunc_RemoveEntity, Entity );
			case 2: return FMRES_SUPERCEDE;
			default: return FMRES_IGNORED;
		}
	}
	return FMRES_IGNORED;
}
__________________
Project: Among Us

Last edited by Craxor; 02-04-2016 at 02:53.
Craxor is offline
Send a message via ICQ to Craxor
 



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 09:30.


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