Raised This Month: $ Target: $400
 0% 

What do i have to do to call another plugin?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
nicolazo103
Veteran Member
Join Date: Jan 2009
Location: I have no fu*** idea
Old 01-01-2010 , 19:43   What do i have to do to call another plugin?
Reply With Quote #1

Hello everyone
Iīm trying to use callfunc, but i have no idea how to use it.
I made this

PHP Code:
new EXTRAHPLUGINS [][] =
{
    
"zp_extra_minigun.amxx",
    
"zp_extra_bazooka.amxx",
    
"zp_zmode_q.amxx",
    
"zp_m4_extra.amxx",
    
"zp_extra_lasermine.amxx"

and then, in the menu handler

PHP Code:
new choice[900], name[32], accesscallback
    
    menu_item_getinfo
(menuitemaccesschoicecharsmax(choice), namecharsmax(name), callback)
    
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    
money cs_get_user_money(id)
    
    new 
ichoose str_to_num(choice)
    
//..........
    
if(callfunc_begin("zp_extra_item_selected"EXTRAZPLUGINS[ichoose]) == 1)
    {
        
callfunc_push_int(id)
        
callfunc_end()
    } 
I tested it and it doesnīt work (this part)

zp_extra_item_selected exists in listed plugins. I donīt know what is wrong (well, i think it could be because of callfunc_push_str)

Thanks for watching
Attached Files
File Type: sma Get Plugin or Get Source (zp_addon_buymenusis.sma - 441 views - 12.6 KB)
__________________
Why do they send babies to fight me? -Heavy


Last edited by nicolazo103; 01-01-2010 at 19:46.
nicolazo103 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-01-2010 , 20:03   Re: What do i have to do to call another plugin?
Reply With Quote #2

Is zp_extra_item_selected() a public function ?
__________________
Arkshine is offline
nicolazo103
Veteran Member
Join Date: Jan 2009
Location: I have no fu*** idea
Old 01-01-2010 , 23:12   Re: What do i have to do to call another plugin?
Reply With Quote #3

Yes

Example
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <zombieplague>

/*================================================================================
 [Plugin Customization]
=================================================================================*/

new const g_item_name[] = { "Unlimited Clip (single round)" }
const 
g_item_cost 10

/*============================================================================*/

// CS Offsets
#if cellbits == 32
const OFFSET_CLIPAMMO 51
#else
const OFFSET_CLIPAMMO 65
#endif
const OFFSET_LINUX_WEAPONS 4

// Max Clip for weapons
new const MAXCLIP[] = { -113, -11017, -1303013020253035251220,
            
10301008303020273030, -150 }

new 
g_itemid_infammog_has_unlimited_clip[33]

public 
plugin_init()
{
    
register_plugin("[ZP] Extra: Unlimited Clip""1.0""MeRcyLeZZ")
    
    
g_itemid_infammo zp_register_extra_item(g_item_nameg_item_costZP_TEAM_HUMAN)    
    
    
register_event("HLTV""event_round_start""a""1=0""2=0")
    
register_message(get_user_msgid("CurWeapon"), "message_cur_weapon")
}

// Player buys our upgrade, set the unlimited ammo flag
public zp_extra_item_selected(playeritemid)
{
    if (
itemid == g_itemid_infammo)
        
g_has_unlimited_clip[player] = true
}

// Reset flags for all players on newround
public event_round_start()
{
    for (new 
idid <= 32id++) g_has_unlimited_clip[id] = false;
}

// Unlimited clip code
public message_cur_weapon(msg_idmsg_destmsg_entity)
{
    
// Player doesn't have the unlimited clip upgrade
    
if (!g_has_unlimited_clip[msg_entity])
        return;
    
    
// Player not alive or not an active weapon
    
if (!is_user_alive(msg_entity) || get_msg_arg_int(1) != 1)
        return;
    
    static 
weaponclip
    weapon 
get_msg_arg_int(2// get weapon ID
    
clip get_msg_arg_int(3// get weapon clip
    
    // Unlimited Clip Ammo
    
if (MAXCLIP[weapon] > 2// skip grenades
    
{
        
set_msg_arg_int(3get_msg_argtype(3), MAXCLIP[weapon]) // HUD should show full clip all the time
        
        
if (clip 2// refill when clip is nearly empty
        
{
            
// Get the weapon entity
            
static wname[32], weapon_ent
            get_weaponname
(weaponwnamesizeof wname 1)
            
weapon_ent fm_find_ent_by_owner(-1wnamemsg_entity)
            
            
// Set max clip on weapon
            
fm_set_weapon_ammo(weapon_entMAXCLIP[weapon])
        }
    }
}

// Find entity by its owner (from fakemeta_util)
stock fm_find_ent_by_owner(entity, const classname[], owner)
{
    while ((
entity engfunc(EngFunc_FindEntityByStringentity"classname"classname)) && pev(entitypev_owner) != owner) {}
    
    return 
entity;
}

// Set Weapon Clip Ammo
stock fm_set_weapon_ammo(entityamount)
{
    
set_pdata_int(entityOFFSET_CLIPAMMOamountOFFSET_LINUX_WEAPONS);

__________________
Why do they send babies to fight me? -Heavy

nicolazo103 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-02-2010 , 07:39   Re: What do i have to do to call another plugin?
Reply With Quote #4

Never tried to use such native and your code looks good, except that your function has 2 params and you push only the player id.
__________________
Arkshine is offline
nicolazo103
Veteran Member
Join Date: Jan 2009
Location: I have no fu*** idea
Old 01-02-2010 , 18:31   Re: What do i have to do to call another plugin?
Reply With Quote #5

But i dont know what i should push
__________________
Why do they send babies to fight me? -Heavy

nicolazo103 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-02-2010 , 19:01   Re: What do i have to do to call another plugin?
Reply With Quote #6

It's the item index returned by zp_register_extra_item().
__________________
Arkshine is offline
nicolazo103
Veteran Member
Join Date: Jan 2009
Location: I have no fu*** idea
Old 01-02-2010 , 19:23   Re: What do i have to do to call another plugin?
Reply With Quote #7

g_itemid_infammo? or itemid in that case?
__________________
Why do they send babies to fight me? -Heavy

nicolazo103 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-02-2010 , 19:36   Re: What do i have to do to call another plugin?
Reply With Quote #8

If I understand you want to "force" to select the item, right ? In this case, you have to execute a function in ZombiePlague not in the plugin item because this one is just a callback when an user selects an item.
__________________
Arkshine is offline
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 04:16.


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