Raised This Month: $51 Target: $400
 12% 

Fake Forwards


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AntiBots
Veteran Member
Join Date: May 2008
Location: Brazil
Old 03-15-2009 , 18:53   Fake Forwards
Reply With Quote #1

Your plugin has many forwards?
with this example you can create forward like register_forward of fakemeta module.
I know that other way is CreateMultiForward but this can be a another option.

PHP Code:
#include <amxmodx>

enum
{
    
Fake_Connect 0,
    
Fake_Disconnect,
    
Fake_ChangeName,
    
Fake_PutInServer
}

new Array:
g_fakeforwards_type
new Array:g_fakeforwards_num

public plugin_precache() 
{
    
register_plugin("Fake Forwards""1.0""ReymonARG")

    
g_fakeforwards_num ArrayCreate(11)
    
g_fakeforwards_type ArrayCreate(11)
    
}

// We need to register the call for the forwards
public plugin_natives()
{
    
// Librery
    
register_library("fake_forwards")
    
    
// Natives
    
register_native("register_fakeforward""_register_event")
    
register_native("unregister_fakeforward""_unregister_event")
}

public 
_register_event(pluginparams)
{
    
// Are correct the params? return
    
if( params != )
        return -
1
    
    
static typeg_callout[33], forwards_num
    type 
get_param(1)
    
get_string(2g_callout32)
    
    
// Here We create the Forward.
    
switch( type )
    {
        
// So some forwards have diferent out, so we need this to create diferent styles.
        
case Fake_Connectforwards_num CreateOneForward(pluging_calloutFP_CELL)
        case 
Fake_Disconnect forwards_num CreateOneForward(pluging_calloutFP_CELL)
        case 
Fake_ChangeName forwards_num CreateOneForward(pluging_calloutFP_CELLFP_STRING)
        case 
Fake_PutInServer forwards_num CreateOneForward(pluging_calloutFP_CELL)
        default: return -
1
    
}
    
    
// Can create the forward? Return.
    
if( forwards_num == -)
        return -
1
    
    
// Save the type of the forward and the num.
    
ArrayPushCell(g_fakeforwards_typetype)
    
ArrayPushCell(g_fakeforwards_numforwards_num)
    
    return 
forwards_num
}

// Well i think that this dont is good, But i will try to better this part.
public _unregister_event(pluginparams)
{
    
// Its param = 1 ? return.
    
if( params != )
        return -
1
    
    
static ifwd_id
    fwd_id 
get_param(1)
    
    
// Found the forward and delete.
    
for( 0ArraySizeg_fakeforwards_num ); i++)
    {
        if( 
ArrayGetCell(g_fakeforwards_numi) == fwd_id )
        {
            
// Delete forward
            
DestroyForward(fwd_id)
            
            
// And items.
            
ArrayDeleteItem(g_fakeforwards_typei)
            
ArrayDeleteItem(g_fakeforwards_numi)
            
            return 
1
        
}
    }
    
    return 
0
}

public 
client_connect(id)
{
    static 
inull_id
    
    
// Well this is the mechanism to exec the forwards.
    
for( 0ArraySizeg_fakeforwards_num ); i++)
    {
        
// If item type is Fake_Connect ?
        
if( ArrayGetCell(g_fakeforwards_typei) == Fake_Connect )
        {
            
// Exec the forward.
            
ExecuteForward(ArrayGetCell(g_fakeforwards_numi), null_idid)
        }
    }
}

public 
client_disconnect(id)
{
    static 
inull_id
    
for( 0ArraySizeg_fakeforwards_num ); i++)
    {
        if( 
ArrayGetCell(g_fakeforwards_typei) == Fake_Disconnect )
        {
            
ExecuteForward(ArrayGetCell(g_fakeforwards_numi), null_idid)
        }
    }
}

public 
client_infochanged(id)
{
    static 
oldname[32], newname[32], inull_id
    get_user_name
(idoldname31)
    
get_user_info(id"name"newname31)
    
    if( !
equal(oldnamenewname) )
    {
        for( 
0ArraySizeg_fakeforwards_num ); i++)
        {
            if( 
ArrayGetCell(g_fakeforwards_typei) == Fake_ChangeName )
            {
                
ExecuteForward(ArrayGetCell(g_fakeforwards_numi), null_ididnewname)
            }
        }
    }
}

public 
client_putinserver(id)
{
    static 
inull_id
    
for( 0ArraySizeg_fakeforwards_num ); i++)
    {
        if( 
ArrayGetCell(g_fakeforwards_typei) == Fake_PutInServer )
        {
            
ExecuteForward(ArrayGetCell(g_fakeforwards_numi), null_idid)
        }
    }

And Example for recibe the forwards.

PHP Code:
#include <amxmodx>

#pragma library fake_forwards

enum Fake_Forwards
{
    
Fake_Connect 0,
    
Fake_Disconnect,
    
Fake_ChangeName,
    
Fake_PutInServer
}

native register_fakeforward(Fake_Forwards:type, const out[])
native unregister_fakeforward(fwd_id)

public 
plugin_init() 
{
    
register_plugin("Forward Recive""1.0""ReymonARG")
    
    
register_fakeforward(Fake_Connect"fw_client_connect")
    
register_fakeforward(Fake_Disconnect"fw_client_disconnect")
    
register_fakeforward(Fake_ChangeName"fw_client_changename")
    
register_fakeforward(Fake_PutInServer"fw_client_putinserver")
}

public 
fw_client_connect(id)
{
    
server_print("Client %d Connecting"id)
}

public 
fw_client_disconnect(id)
{
    
server_print("Client %d Disconnect"id)
}

public 
fw_client_changename(id, const newname[])
{
    
server_print("Client %d Change name to %s"idnewname)
}

public 
fw_client_putinserver(id)
{
    
server_print("Client %d Connect"id)

Fell Free to correctme.
__________________
AntiBots is offline
Send a message via ICQ to AntiBots Send a message via MSN to AntiBots Send a message via Skype™ to AntiBots
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 03-16-2009 , 01:17   Re: Fake Forwards
Reply With Quote #2

Seems kind of pointless, instead of just having your original plugin do it, you're going to have your plugin and this additional one to achieve it.

Sure it would be alright for a server with plugins that all/some use these "fake forwards" but it still does not seem that logical.

Also you should be using CreateMultiForward because otherwise it really is pointless as the "fake forward" would only be sent back to the original plugin and not multiple.

Perhaps you could give an example in where it would really be helpful.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
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 06:28.


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