Raised This Month: $ Target: $400
 0% 

Help about Reading from file strings.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 02-01-2016 , 02:11   Re: Help about Reading from file strings.
Reply With Quote #10

Working fine with trie.

But appear other problem, when i try to change the map all key's from Trie is removed, how i can save/load keys from Trie?

(TrieSnapshotCreate is working only for 183)

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

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

new Trie:g_tBlock;
new giTypeCvar;

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

	g_tBlock = TrieCreate( );

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

	TrieSetCell( 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 );

	TrieDeleteKey( 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-01-2016 at 08:49.
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:21.


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