Raised This Month: $ Target: $400
 0% 

Menu and spawn stuff


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
vL.
Senior Member
Join Date: Aug 2009
Location: Estonia
Old 06-10-2010 , 20:36   Menu and spawn stuff
Reply With Quote #1

So I got this menu where are 4 weapons and 1 of them is default(you spawn with it if you haven't taken another one), so I need some help with the spawn thing, so it would save the settings. I've made a menu based on the tutorial what Emp' had made. I think the spawn thing has something to do with the function, so that the WeaponName would change if the user chooses the other weapon.

PHP Code:
public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
RegisterHam(Ham_Spawn"player""FwdHamSpawn_Post"1);
    
    
register_clcmd("say /weapons""Weapons");
}

public 
FwdHamSpawn_Post(id)
{
    
SpawnedWeapon WeaponName // Like the function SpawnedWeapon = true / false
}

public 
Weapons(id)
{
    new 
menu menu_create("\yWeapons""menu_handler");
    
    
menu_additem(menu"M4P1""1"0); // The Default weapon
    
menu_additem(menu"AK47""2"0);
    
menu_additem(menu"AWP""3"0);
    
menu_additem(menu"Scout""4"0);
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
menu_display(idmenu0);
}

public 
menu_handler(idmenuitem)
{
    
// Other stuff here, no point on writing the whole code here :)

vL. is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-10-2010 , 20:45   Re: Menu and spawn stuff
Reply With Quote #2

Use a global array to keep track of everybody's chosen weapon (new g_iWeaponChoice[33], index it like: g_iWeaponChoice[id]). But, when the plugin starts, set everybody's 'choice' to which ever is default.
__________________
fysiks is offline
vL.
Senior Member
Join Date: Aug 2009
Location: Estonia
Old 06-10-2010 , 20:56   Re: Menu and spawn stuff
Reply With Quote #3

Could you please make an example or the thing? Because I'm rather new to this stuff and don't really know how to use the g_iWeaponChoice thing.
vL. is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-10-2010 , 23:12   Re: Menu and spawn stuff
Reply With Quote #4

PHP Code:
new g_iWeaponChoice[33]

// plugin_init()
    
arrayset(g_iWeaponChoice133)


// Ham_Spawn
    // Can be done several ways
    
switch(g_iWeaponChoice[id])
    {
        case 
2:
        {
            
// Second weapon
        
}
        case 
3:
        {
            
// Third weapon
        
}
        default:
        {
            
// default weapon
        
}
    }

// menu handler
    // ...
    
g_iWeaponChoice[id] = key 
__________________
fysiks is offline
vL.
Senior Member
Join Date: Aug 2009
Location: Estonia
Old 06-11-2010 , 04:41   Re: Menu and spawn stuff
Reply With Quote #5

It doesn't work like I need it to work, like when I die I do not spawn with the weapon I choose the last round.
vL. is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-11-2010 , 17:06   Re: Menu and spawn stuff
Reply With Quote #6

Quote:
Originally Posted by vL. View Post
It doesn't work like I need it to work, like when I die I do not spawn with the weapon I choose the last round.
To acheive faster results you will need to learn to post your full code. (No guaruntees on me being able to help you out on the Counter-Strike specific stuff).
__________________
fysiks is offline
vL.
Senior Member
Join Date: Aug 2009
Location: Estonia
Old 06-11-2010 , 18:05   Re: Menu and spawn stuff
Reply With Quote #7

Ok here's the full code without the modifications you told me to make.

PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fun>
#include <hamsandwich>

public plugin_init()
{
    
register_plugin"Weapons""1.0""vL." )
    
    
RegisterHam(Ham_Spawn"player""Fwd_Ham_Spawn_Post"1);
    
    
register_clcmd("say /weapons""Weapons");
}

public 
Fwd_Ham_Spawn_Post(id)
{  
    if(
is_user_connected(id) && is_user_alive(id))
    {
        
give_item(id"weapon_m4a1");
        
cs_set_user_bpammo(idCSW_M4A190);
    }
 
    return 
PLUGIN_HANDLED;
}

public 
Weapons(id)
{    
    new 
menu menu_create("\yWeapons""menu_handler");
    
    
menu_additem(menu"M4A1""1"0); // The Default weapon
    
menu_additem(menu"AK47""2"0);
    
menu_additem(menu"AWP""3"0);
    
menu_additem(menu"Scout""4"0);
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
menu_display(idmenu0);
}

public 
menu_handler(idmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    new 
data[6], iName[64];
    new 
accesscallback;
    
    
menu_item_getinfo(menuitemaccessdata,5iName63callback);
    new 
key str_to_num(data);
    
    switch(
key)
    {
        case 
1:
        {
            
give_item(id"weapon_m4a1");
            
cs_set_user_bpammo(idCSW_M4A190);        
        }
        case 
2:
        {
            
give_item(id"weapon_ak47");
            
cs_set_user_bpammo(idCSW_AK4790);        
        }
        case 
3:
        {
            
give_item(id"weapon_awp");
            
cs_set_user_bpammo(idCSW_AWP30);        
        }
        case 
4:
        {
            
give_item(id"weapon_scout");
            
cs_set_user_bpammo(idCSW_SCOUT90);        
        }
    }
    
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;


Last edited by vL.; 06-11-2010 at 18:11.
vL. is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-11-2010 , 19:10   Re: Menu and spawn stuff
Reply With Quote #8

No, show the code that doesn't work. Show what you tried. I'm not going to do it all for you.
__________________
fysiks is offline
vL.
Senior Member
Join Date: Aug 2009
Location: Estonia
Old 06-11-2010 , 19:33   Re: Menu and spawn stuff
Reply With Quote #9

Okay, here it is.

PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fun>
#include <hamsandwich>

new g_iWeaponChoice[33

public 
plugin_init()
{
    
register_plugin"Weapons""1.0""vL." )
    
    
arrayset(g_iWeaponChoice133)
    
    
RegisterHam(Ham_Spawn"player""Fwd_Ham_Spawn_Post"1);
    
    
register_clcmd("say /weapons""Weapons");
}

public 
Fwd_Ham_Spawn_Post(id)
{  
    if(
is_user_connected(id) && is_user_alive(id))
    {
        switch(
g_iWeaponChoice[id])
        {
            case 
2:
            {
                
give_item(id"weapon_ak47");
                
cs_set_user_bpammo(idCSW_AK4790); 
            }
            case 
3:
            {
                
give_item(id"weapon_awp");
                
cs_set_user_bpammo(idCSW_AWP30); 
            }
            case 
4:
            {
                
give_item(id"weapon_scout");
                
cs_set_user_bpammo(idCSW_SCOUT90); 
            }
            default:{
                
give_item(id"weapon_m4a1");
                
cs_set_user_bpammo(idCSW_M4A190); 
            }
            
        }
    }
    
    return 
PLUGIN_HANDLED;
}

public 
Weapons(id)
{    
    new 
menu menu_create("\yWeapons""menu_handler");
    
    
menu_additem(menu"M4A1""1"0); // The Default weapon
    
menu_additem(menu"AK47""2"0);
    
menu_additem(menu"AWP""3"0);
    
menu_additem(menu"Scout""4"0);
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
menu_display(idmenu0);
}

public 
menu_handler(idmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    new 
data[6], iName[64];
    new 
accesscallback;
    
    
menu_item_getinfo(menuitemaccessdata,5iName63callback);
    new 
key str_to_num(data);
    
    
g_iWeaponChoice[id] = key  
    
    
switch(key)
    {
        case 
1:
        {
            
give_item(id"weapon_m4a1");
            
cs_set_user_bpammo(idCSW_M4A190);        
        }
        case 
2:
        {
            
give_item(id"weapon_ak47");
            
cs_set_user_bpammo(idCSW_AK4790);        
        }
        case 
3:
        {
            
give_item(id"weapon_awp");
            
cs_set_user_bpammo(idCSW_AWP30);        
        }
        case 
4:
        {
            
give_item(id"weapon_scout");
            
cs_set_user_bpammo(idCSW_SCOUT90);        
        }
        
    }    
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;


Last edited by vL.; 06-11-2010 at 19:36.
vL. is offline
vL.
Senior Member
Join Date: Aug 2009
Location: Estonia
Old 06-14-2010 , 01:38   Re: Menu and spawn stuff
Reply With Quote #10

Fysik any luck?

Last edited by vL.; 06-14-2010 at 02:04.
vL. is offline
Reply


Thread Tools
Display Modes

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 05:23.


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