Raised This Month: $ Target: $400
 0% 

Question about Natives


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Whitez
Member
Join Date: Apr 2016
Location: London, UK
Old 05-29-2016 , 14:16   Re: Question about Natives
Reply With Quote #5

Is this right?

Condition is just an optional parameter, which i want to send only in case of a special event, so i can use exceptions for special events in other plugins with the forwards created

PHP Code:
Custom Forwards
enum _
:TOTAL_FORWARDS
{
    
FW_USER_INFECT_PRE 0,
    
FW_USER_INFECT,
    
FW_USER_INFECT_POST
}

new 
g_ForwardResult
new g_Forwards[TOTAL_FORWARDS]

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
g_Forwards[FW_USER_INFECT_PRE] = CreateMultiForward("zp_fw_core_infect_pre"ET_CONTINUEFP_CELLFP_CELLFP_CELL)
    
g_Forwards[FW_USER_INFECT] = CreateMultiForward("zp_fw_core_infect"ET_IGNOREFP_CELLFP_CELL)
    
g_Forwards[FW_USER_INFECT_POST] = CreateMultiForward("zp_fw_core_infect_post"ET_IGNOREFP_CELLFP_CELLFP_CELL)
}

InfectPlayer(idattacker 0condition 0)
{
    
ExecuteForward(g_Forwards[FW_USER_INFECT_PRE], g_ForwardResultidattackercondition)
    
    
// One or more plugins blocked infection
    
if (g_ForwardResult >= PLUGIN_HANDLED)
        return;
    
    
ExecuteForward(g_Forwards[FW_USER_INFECT], g_ForwardResultidattackercondition)
    
    
flag_set(g_IsZombieid)
    
    if (
GetZombieCount() == 1)
        
flag_set(g_IsFirstZombieid)
    else
        
flag_unset(g_IsFirstZombieid)
    
    
ExecuteForward(g_Forwards[FW_USER_INFECT_POST], g_ForwardResultidattackercondition)
    
    
CheckLastZombieHuman()
}

public 
native_core_infect(plugin_idnum_paramsnum_condition)
{
    new 
id get_param(1)
    
    if (!
is_user_alive(id))
    {
        
log_error(AMX_ERR_NATIVE"[ZP] Invalid Player (%d)"id)
        return 
false;
    }
    
    if (
flag_get(g_IsZombieid))
    {
        
log_error(AMX_ERR_NATIVE"[ZP] Player already infected (%d)"id)
        return 
false;
    }
    
    new 
attacker get_param(2)
    
    if (
attacker && !is_user_connected(attacker))
    {
        
log_error(AMX_ERR_NATIVE"[ZP] Invalid Player (%d)"attacker)
        return 
false;
    }
    
    new 
condition get_param(3)
    
    
InfectPlayer(idattackercondition)
    return 
true;

PHP Code:

// In case of a special situation
zp_core_infect(idattacker3
PHP Code:

public fw_zp_core_infect_post(victimattackercondition)
{
            if(
condition 3)
              {
                      
code here
              
}


Last edited by Whitez; 05-29-2016 at 14:57.
Whitez is offline
 



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 18:36.


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