Raised This Month: $ Target: $400
 0% 

CurrentRound and sv_restart


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
leonardo_
Member
Join Date: Nov 2012
Location: Moscow, right now in Vic
Old 02-11-2013 , 19:03   CurrentRound and sv_restart
Reply With Quote #1

Hi guys!
I wrote my first plugin, and I have so many warnings in my code and I have no idea how to fix them...

Please help me to fix them:
PHP Code:
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c1997-2006 ITB CompuPhaseAMX Mod X Team

Warning
Loose indentation on line 141
Warning
Loose indentation on line 143
Warning
Loose indentation on line 144
Warning
Loose indentation on line 145
Warning
Loose indentation on line 149
Warning
Loose indentation on line 157
Warning
Loose indentation on line 161
Warning
Loose indentation on line 167
Warning
Loose indentation on line 168
Warning
Loose indentation on line 176
Warning
Loose indentation on line 180
Warning
Loose indentation on line 181
Warning
Loose indentation on line 182
Warning
Loose indentation on line 186
Warning
Loose indentation on line 194
Warning
Loose indentation on line 197
Warning
Loose indentation on line 202
Warning
Loose indentation on line 206
Warning
Loose indentation on line 210
Warning
Loose indentation on line 211
Warning
Loose indentation on line 212
Warning
Loose indentation on line 216
Warning
Loose indentation on line 224
Warning
Loose indentation on line 227
Warning
Loose indentation on line 232
Warning
Symbol is never used"CurrentRound" on line 245
Header size
:           1012 bytes
Code size
:             5800 bytes
Data size
:             4320 bytes
Stack
/heap size:      16384 bytesestimated maxusage=781 cells (3124 bytes)
Total requirements:   27516 bytes

26 Warnings
.
Done

The idea of that plugin is when player has 3rd round he gets a menu with weapons:
PHP Code:
menu_additem(menu"\wGet M4A1 + Deagle""1"ADMIN_LEVEL_G);
menu_additem(menu"\wGet AK47 + Deagle""2"ADMIN_LEVEL_G);
menu_additem(menu"\wGet AWP + Deagle""3"ADMIN_LEVEL_G); 
and I add strip function and C4 if player is a Terrorist.. But know I have another problem...

When for example I have 3rd round I can get my menu and everything goes perfect except when I doing restart from "amxmodx" menu it shows me menu from the first and I don't that. I still want to keep it from 3rd round, because If player is going to get AWP + Deagle in 1st round is going to be stupid...

How can I make it? Please don't give me full code, just give ideas how I can make it... Thank you! And please don't judge me, because this is my first plugin...

This is code of my plugin:

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <hamsandwich>
#include <fakemeta_util>
#include <cstrike>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "Alexander"
#define MAXPLAYERS 32 + 1


new bool:gbUsed[MAXPLAYERS];
//new CurrentRound;
new count
//new bool:HasC4[33]
new CurrentRound



public 
plugin_init() 
{
    
register_plugin("Weapon Menu""0.1""Alex");
    
register_clcmd"SpecialMenu","AwesomeMenu");
    
register_logevent"eventRoundEnd"2"1=Round_End" );
    
register_event"HLTV""new_round""a""1=0""2=0" );
    
RegisterHam(Ham_Spawn"player""Spawn_Post"true); // This is called when a player spawn.7
    
register_event("SomethingLikeThat""GiveFreeGrenades""a");
    
//register_logevent("LogEvent_RoundStart", 2, "1 = Round_Start" )
    
}

/*public LogEvent_RoundStart(){
    CurrentRound++
}*/

public new_round( )
{
    
count++


public 
Spawn_Postid )
{    
    if(
is_user_aliveid ) && count >= 2)
    {
        
AwesomeMenuid )
    }
}  

public 
eventRoundEnd()
{
    
arraysetgbUsedfalseMAXPLAYERS )
}

public 
client_disconnect(id)
{
    
gbUsed[id] = false;
}

public 
GiveFreeGrenadesid ){
    if(
count >= 0) {
        
give_item(id"weapon_hegrenade")
        
give_item(id"weapon_flashbang")
        
give_item(id"weapon_flashbang")
        
give_item(id"weapon_smokegrenade")
    }
}
public 
AwesomeMenu(id)
{
    if(!
gbUsed[id])
    {    
        
        
//first we need to make a variable that will hold the menu
        
new menu menu_create("\rChoose your gun:""menu_handler");
        
//Note - menu_create
        //The first parameter  is what the menu will be titled (what is at the very top)
        //The second parameter is the function that will deal/handle with the menu (which key was pressed, and what to do)
        
        //Now lets add some things to select from the menu
    
menu_additem(menu"\wGet M4A1 + Deagle""1"ADMIN_LEVEL_G);
    
menu_additem(menu"\wGet AK47 + Deagle""2"ADMIN_LEVEL_G);
    
menu_additem(menu"\wGet AWP + Deagle""3"ADMIN_LEVEL_G);
        
//menu_additem(menu, "\wI'm Selection #2", "2", 0);
        //menu_additem(menu, "\wI'm Secret Selection #3", "3", ADMIN_LEVEL_G);
        //Note - menu_additem
        //The first parameter is which menu we will be adding this item/selection to
        //The second parameter is what text will appear on the menu (Note that it is preceeded with a number of which item it is)
        //The third parameter is data that we want to send with this item
        //The fourth parameter is which admin flag we want to be able to access this item (Refer to the admin flags from the amxconst.inc)
        //The fifth parameter is the callback for enabling/disabling items, by default we will omit this and use no callback (default value of -1) Refer to the Menu Items with Callbacks section for more information.
        
        //Set a property on the menu
        
menu_setprop(menuMPROP_EXITMEXIT_ALL);
        
//Note - menu_setprop
        //The first parameter is the menu to modify
        //The second parameter is what to modify (found in amxconst.inc)
        //The third parameter is what to modify it to (in this case, we are adding a option to the menu that will exit the menu. setting it to MEXIT_NEVER will disable this option)
        
        //Lets display the menu
        
menu_display(idmenu0);
        
//Note - menu_display
        //The first parameter is which index to show it to (you cannot show this to everyone at once)
        //The second parameter is which menu to show them (in this case, the one we just made)
        //The third parameter is which page to start them on
    
}
}
//okay, we showed them the menu, now lets handle it (looking back at menu_create, we are going to use that function)
public menu_handler(idmenuitem)
{
    
//we don't want to deal with them if they exited a menu
    
if( item == MENU_EXIT )
    {
        
menu_destroy(menu);
        
//Note that you will want to destroy the menu after they do something
        
return PLUGIN_HANDLED;
    }
    
    
//now lets create some variables that will give us information about the menu and the item that was pressed/chosen
    
new data[6], szName[64];
    new 
accesscallback;
    
//heres the function that will give us that information (since it doesnt magicaly appear)
    
menu_item_getinfo(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);
    
    
//Note - that you can do this next step how you want, this is just the way I prefer
    
    //looking back to menu_additem, we sent data with every item we added, this is where it gets a little fishy for us (where you can do your own method)
    
new key str_to_num(data);
    
//note that all my datas were numbers (you can do it with whatever type of string you want)
    
    //now lets find which item was pressed
    
switch(key)
    {
        case 
1:
        {
        new 
bool:HasC4
        
if (user_has_weapon(idCSW_C4) && get_user_team(id) == 1
        
HasC4 true
    else 
        
HasC4 false
       
strip_user_weaponsid )
            
give_item(id"weapon_m4a1")
       
give_item(id,"ammo_556nato")
       
give_item(id,"ammo_556nato")
       
give_item(id,"ammo_556nato")
       
give_item(id,"ammo_556nato")
            
give_item(id"weapon_deagle")
            
give_item(id,"ammo_50ae")
            
give_item(id,"ammo_50ae")
            
give_item(id,"ammo_50ae")
            
give_item(id,"ammo_50ae")
            
give_item(id,"ammo_50ae")
            
give_item(id,"ammo_50ae")
            
give_item(id,"ammo_50ae")
       
give_item(id,"weapon_knife")
       
give_item(id"item_assaultsuit")
       
give_item(id"item_thighpack")
            
     if (
HasC4
    { 
        
give_item(id"weapon_c4"); 
        
cs_set_user_plantid ); 
    } 
    
        
client_print(idprint_center"You got free M4A1 + Deagle");
            
gbUsed[id] = true;
            
//note that if we dont want to continue through the function, we can't just end with a return. We want to kill the menu first
            
menu_destroy(menu);
            return 
PLUGIN_HANDLED;
        }
        case 
2:
        {
    new 
bool:HasC4;
        if (
user_has_weapon(idCSW_C4) && get_user_team(id) == 1
            
HasC4 true
        else 
            
HasC4 false
       
strip_user_weaponsid )
            
give_item(id,"weapon_ak47")
       
give_item(id,"ammo_762nato")
       
give_item(id,"ammo_762nato")
       
give_item(id,"ammo_762nato")
       
give_item(id,"ammo_762nato")
            
give_item(id,"weapon_deagle")
            
give_item(id,"ammo_50ae")
            
give_item(id,"ammo_50ae")
            
give_item(id,"ammo_50ae")
            
give_item(id,"ammo_50ae")
            
give_item(id,"ammo_50ae")
            
give_item(id,"ammo_50ae")
            
give_item(id,"ammo_50ae")
       
give_item(id,"weapon_knife")
       
give_item(id,"item_assaultsuit")
       
give_item(id,"item_thighpack")
     if (
HasC4
    { 
        
give_item(id"weapon_c4"); 
        
cs_set_user_plantid ); 
    } 
            
client_print(idprint_chat"OH YEAH! YOU GOT NICE AK + DEAGLE!");
        }
        case 
3//again i don't have experience with the admin limitations, so i don't know if you need to have a check before this (im assuming you don't though ^_^)
        
{new bool:HasC4;
        if (
user_has_weapon(idCSW_C4) && get_user_team(id) == 1)     
            
HasC4 true
        else 
            
HasC4 false
       
strip_user_weaponsid )
            
give_item(id"weapon_awp")
       
give_item(id,"ammo_338magnum")
       
give_item(id,"ammo_338magnum")
       
give_item(id,"ammo_338magnum")
       
give_item(id,"ammo_338magnum")
            
give_item(id"weapon_deagle")
            
give_item(id,"ammo_50ae")
            
give_item(id,"ammo_50ae")
            
give_item(id,"ammo_50ae")
            
give_item(id,"ammo_50ae")
            
give_item(id,"ammo_50ae")
            
give_item(id,"ammo_50ae")
            
give_item(id,"ammo_50ae")
       
give_item(id,"weapon_knife")
       
give_item(id"item_assaultsuit")
       
give_item(id"item_thighpack")
     if (
HasC4
    { 
        
give_item(id"weapon_c4"); 
        
cs_set_user_plantid ); 
    } 
            
client_print(idprint_chat"OH YEAH! YOU GOT NICE AWP + DEAGLE!");
        }
    }
    
    
//lets finish up this function with a menu_destroy, and a return
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;

Thank you so much!
__________________
www.Deagle-Shot.ru - Game Community
leonardo_ is offline
Send a message via ICQ to leonardo_ Send a message via Skype™ to leonardo_
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 02-11-2013 , 19:17   Re: CurrentRound and sv_restart
Reply With Quote #2

Indent properly and the Loose Indentation warnings will disappear. Or, you can ignore the warnings and your plugin will work just fine
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Torge
Veteran Member
Join Date: Oct 2011
Old 02-11-2013 , 19:34   Re: CurrentRound and sv_restart
Reply With Quote #3

Try this:

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <hamsandwich>
#include <fakemeta_util>
#include <cstrike>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "Alexander"
#define MAXPLAYERS 32 + 1


new bool:gbUsed[MAXPLAYERS];
//new CurrentRound;
new count
//new bool:HasC4[33]
new CurrentRound



public 
plugin_init() 
{
    
register_plugin("Weapon Menu""0.1""Alex");
    
register_clcmd"SpecialMenu","AwesomeMenu");
    
register_logevent"eventRoundEnd"2"1=Round_End" );
    
register_event"HLTV""new_round""a""1=0""2=0" );
    
RegisterHam(Ham_Spawn"player""Spawn_Post"true); // This is called when a player spawn.7
    
register_event("SomethingLikeThat""GiveFreeGrenades""a");
    
//register_logevent("LogEvent_RoundStart", 2, "1 = Round_Start" )
    
}

/*public LogEvent_RoundStart(){
CurrentRound++
}*/

public new_round( )
{
count++


public 
Spawn_Postid )
{    
if(
is_user_aliveid ) && count >= 2)
{
    
AwesomeMenuid )
}
}  

public 
eventRoundEnd()
{
arraysetgbUsedfalseMAXPLAYERS )
}

public 
client_disconnect(id)
{
gbUsed[id] = false;
}

public 
GiveFreeGrenadesid ){
if(
count >= 0) {
    
give_item(id"weapon_hegrenade")
    
give_item(id"weapon_flashbang")
    
give_item(id"weapon_flashbang")
    
give_item(id"weapon_smokegrenade")
}
}
public 
AwesomeMenu(id)
{
if(!
gbUsed[id])
{    
    
    
//first we need to make a variable that will hold the menu
    
new menu menu_create("\rChoose your gun:""menu_handler");
    
//Note - menu_create
    //The first parameter  is what the menu will be titled (what is at the very top)
    //The second parameter is the function that will deal/handle with the menu (which key was pressed, and what to do)
    
    //Now lets add some things to select from the menu
    
menu_additem(menu"\wGet M4A1 + Deagle""1"ADMIN_LEVEL_G);
    
menu_additem(menu"\wGet AK47 + Deagle""2"ADMIN_LEVEL_G);
    
menu_additem(menu"\wGet AWP + Deagle""3"ADMIN_LEVEL_G);
    
//menu_additem(menu, "\wI'm Selection #2", "2", 0);
    //menu_additem(menu, "\wI'm Secret Selection #3", "3", ADMIN_LEVEL_G);
    //Note - menu_additem
    //The first parameter is which menu we will be adding this item/selection to
    //The second parameter is what text will appear on the menu (Note that it is preceeded with a number of which item it is)
    //The third parameter is data that we want to send with this item
    //The fourth parameter is which admin flag we want to be able to access this item (Refer to the admin flags from the amxconst.inc)
    //The fifth parameter is the callback for enabling/disabling items, by default we will omit this and use no callback (default value of -1) Refer to the Menu Items with Callbacks section for more information.
    
    //Set a property on the menu
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
//Note - menu_setprop
    //The first parameter is the menu to modify
    //The second parameter is what to modify (found in amxconst.inc)
    //The third parameter is what to modify it to (in this case, we are adding a option to the menu that will exit the menu. setting it to MEXIT_NEVER will disable this option)
    
    //Lets display the menu
    
menu_display(idmenu0);
    
//Note - menu_display
    //The first parameter is which index to show it to (you cannot show this to everyone at once)
    //The second parameter is which menu to show them (in this case, the one we just made)
    //The third parameter is which page to start them on
}
}
//okay, we showed them the menu, now lets handle it (looking back at menu_create, we are going to use that function)
public menu_handler(idmenuitem)
{
//we don't want to deal with them if they exited a menu
if( item == MENU_EXIT )
{
    
menu_destroy(menu);
    
//Note that you will want to destroy the menu after they do something
    
return PLUGIN_HANDLED;
}

//now lets create some variables that will give us information about the menu and the item that was pressed/chosen
new data[6], szName[64];
new 
accesscallback;
//heres the function that will give us that information (since it doesnt magicaly appear)
menu_item_getinfo(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);

//Note - that you can do this next step how you want, this is just the way I prefer

//looking back to menu_additem, we sent data with every item we added, this is where it gets a little fishy for us (where you can do your own method)
new key str_to_num(data);
//note that all my datas were numbers (you can do it with whatever type of string you want)

//now lets find which item was pressed
switch(key)
{
    case 
1:
    {
        new 
bool:HasC4
        
if (user_has_weapon(idCSW_C4) && get_user_team(id) == 1
            
HasC4 true
        else 
            
HasC4 false
        
strip_user_weaponsid )
        
give_item(id"weapon_m4a1")
        
give_item(id,"ammo_556nato")
        
give_item(id,"ammo_556nato")
        
give_item(id,"ammo_556nato")
        
give_item(id,"ammo_556nato")
        
give_item(id"weapon_deagle")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"weapon_knife")
        
give_item(id"item_assaultsuit")
        
give_item(id"item_thighpack")
        
        if (
HasC4
        { 
            
give_item(id"weapon_c4"); 
            
cs_set_user_plantid ); 
        } 
        
        
client_print(idprint_center"You got free M4A1 + Deagle");
        
gbUsed[id] = true;
        
//note that if we dont want to continue through the function, we can't just end with a return. We want to kill the menu first
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    case 
2:
    {
        new 
bool:HasC4;
        if (
user_has_weapon(idCSW_C4) && get_user_team(id) == 1
            
HasC4 true
        else 
            
HasC4 false
        
strip_user_weaponsid )
        
give_item(id,"weapon_ak47")
        
give_item(id,"ammo_762nato")
        
give_item(id,"ammo_762nato")
        
give_item(id,"ammo_762nato")
        
give_item(id,"ammo_762nato")
        
give_item(id,"weapon_deagle")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"weapon_knife")
        
give_item(id,"item_assaultsuit")
        
give_item(id,"item_thighpack")
        if (
HasC4
        { 
            
give_item(id"weapon_c4"); 
            
cs_set_user_plantid ); 
        } 
        
client_print(idprint_chat"OH YEAH! YOU GOT NICE AK + DEAGLE!");
    }
    case 
3//again i don't have experience with the admin limitations, so i don't know if you need to have a check before this (im assuming you don't though ^_^)
        
{
        new 
bool:HasC4;
        if (
user_has_weapon(idCSW_C4) && get_user_team(id) == 1)     
            
HasC4 true
        else 
            
HasC4 false
        
strip_user_weaponsid )
        
give_item(id"weapon_awp")
        
give_item(id,"ammo_338magnum")
        
give_item(id,"ammo_338magnum")
        
give_item(id,"ammo_338magnum")
        
give_item(id,"ammo_338magnum")
        
give_item(id"weapon_deagle")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"weapon_knife")
        
give_item(id"item_assaultsuit")
        
give_item(id"item_thighpack")
        if (
HasC4
        { 
            
give_item(id"weapon_c4"); 
            
cs_set_user_plantid ); 
        } 
        
client_print(idprint_chat"OH YEAH! YOU GOT NICE AWP + DEAGLE!");
    }
}

//lets finish up this function with a menu_destroy, and a return
menu_destroy(menu);
return 
PLUGIN_HANDLED;

Torge is offline
wickedd
Veteran Member
Join Date: Nov 2009
Old 02-11-2013 , 20:16   Re: CurrentRound and sv_restart
Reply With Quote #4

Quote:
Originally Posted by leonardo_ View Post
When for example I have 3rd round I can get my menu and everything goes perfect except when I doing restart from "amxmodx" menu it shows me menu from the first and I don't that. I still want to keep it from 3rd round, because If player is going to get AWP + Deagle in 1st round is going to be stupid...
PHP Code:
public plugin_init( )
{
    
register_event"TextMsg""Event_GameWillRestartIn""a""2=#Game_will_restart_in" )
}

public 
Event_GameWillRestartIn( )
{
    
count 0

__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.

Last edited by wickedd; 02-11-2013 at 20:18.
wickedd is offline
leonardo_
Member
Join Date: Nov 2012
Location: Moscow, right now in Vic
Old 02-11-2013 , 21:01   Re: CurrentRound and sv_restart
Reply With Quote #5

Quote:
Originally Posted by YamiKaitou View Post
Indent properly and the Loose Indentation warnings will disappear. Or, you can ignore the warnings and your plugin will work just fine
So when It says like: Loose Indentation

That just means that I have to Indent properly?


Quote:
Originally Posted by wickedd View Post
PHP Code:
public plugin_init( )
{
    
register_event"TextMsg""Event_GameWillRestartIn""a""2=#Game_will_restart_in" )
}

public 
Event_GameWillRestartIn( )
{
    
count 0


wicked, still... I changed map on my server, then menu doesn't show up -> GOOD!

I made 2 restarts from amxmodx menu and on 3rd time It showed me a menu...

How can I make it? Or maybe I am not doing something right?
__________________
www.Deagle-Shot.ru - Game Community

Last edited by leonardo_; 02-11-2013 at 21:20.
leonardo_ is offline
Send a message via ICQ to leonardo_ Send a message via Skype™ to leonardo_
leonardo_
Member
Join Date: Nov 2012
Location: Moscow, right now in Vic
Old 02-11-2013 , 21:20   Re: CurrentRound and sv_restart
Reply With Quote #6

pls dlt that comment...
__________________
www.Deagle-Shot.ru - Game Community

Last edited by leonardo_; 02-11-2013 at 21:21.
leonardo_ is offline
Send a message via ICQ to leonardo_ Send a message via Skype™ to leonardo_
Torge
Veteran Member
Join Date: Oct 2011
Old 02-11-2013 , 21:54   Re: CurrentRound and sv_restart
Reply With Quote #7

What's about my edited code? Still that problem?
Torge is offline
leonardo_
Member
Join Date: Nov 2012
Location: Moscow, right now in Vic
Old 02-11-2013 , 21:59   Re: CurrentRound and sv_restart
Reply With Quote #8

Quote:
Originally Posted by Torge View Post
What's about my edited code? Still that problem?
nope, doesn't show me warnings any more! Thank you!


But I still need to fix that - click.
__________________
www.Deagle-Shot.ru - Game Community

Last edited by leonardo_; 02-11-2013 at 22:00.
leonardo_ is offline
Send a message via ICQ to leonardo_ Send a message via Skype™ to leonardo_
wickedd
Veteran Member
Join Date: Nov 2009
Old 02-12-2013 , 00:06   Re: CurrentRound and sv_restart
Reply With Quote #9

Post your code with the changes that you made.
__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.
wickedd is offline
leonardo_
Member
Join Date: Nov 2012
Location: Moscow, right now in Vic
Old 02-12-2013 , 09:58   Re: CurrentRound and sv_restart
Reply With Quote #10

Quote:
Originally Posted by wickedd View Post
Post your code with the changes that you made.
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <hamsandwich>
#include <fakemeta_util>
#include <cstrike>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "Alexander"
#define MAXPLAYERS 32 + 1


new bool:gbUsed[MAXPLAYERS];
new 
count



public 
plugin_init() 
{
    
register_plugin("Weapon Menu""0.1""Alex");
    
register_clcmd"SpecialMenu","AwesomeMenu");
    
register_logevent"eventRoundEnd"2"1=Round_End" );
    
register_event"HLTV""new_round""a""1=0""2=0" );
    
RegisterHam(Ham_Spawn"player""Spawn_Post"true); // This is called when a player spawn.7
    
register_event("SomethingLikeThat""GiveFreeGrenades""a");
    
register_event"TextMsg""Event_GameWillRestartIn""a""2=#Game_will_restart_in" )
    
//register_logevent("LogEvent_RoundStart", 2, "1 = Round_Start" )
    
}

/*public LogEvent_RoundStart(){
CurrentRound++
}*/

public new_round( )
{
    
count++


public 
Event_GameWillRestartIn( )
{
    
count 0


public 
Spawn_Postid )
{    
    if(
is_user_aliveid ) && count >= 2)
    {
        
AwesomeMenuid )
    }
}  

public 
eventRoundEnd()
{
arraysetgbUsedfalseMAXPLAYERS )
}

public 
client_disconnect(id)
{
gbUsed[id] = false;
}

public 
GiveFreeGrenadesid ){
if(
count >= 0) {
    
give_item(id"weapon_hegrenade")
    
give_item(id"weapon_flashbang")
    
give_item(id"weapon_flashbang")
    
give_item(id"weapon_smokegrenade")
}
}
public 
AwesomeMenu(id)
{
    if(!
gbUsed[id])
    {    
    
    
//first we need to make a variable that will hold the menu
    
new menu menu_create("\rChoose your gun:""menu_handler");
    
//Note - menu_create
    //The first parameter  is what the menu will be titled (what is at the very top)
    //The second parameter is the function that will deal/handle with the menu (which key was pressed, and what to do)
    
    //Now lets add some things to select from the menu
    
menu_additem(menu"\wGet M4A1 + Deagle""1"ADMIN_LEVEL_G);
    
menu_additem(menu"\wGet AK47 + Deagle""2"ADMIN_LEVEL_G);
    
menu_additem(menu"\wGet AWP + Deagle""3"ADMIN_LEVEL_G);
    
//menu_additem(menu, "\wI'm Selection #2", "2", 0);
    //menu_additem(menu, "\wI'm Secret Selection #3", "3", ADMIN_LEVEL_G);
    //Note - menu_additem
    //The first parameter is which menu we will be adding this item/selection to
    //The second parameter is what text will appear on the menu (Note that it is preceeded with a number of which item it is)
    //The third parameter is data that we want to send with this item
    //The fourth parameter is which admin flag we want to be able to access this item (Refer to the admin flags from the amxconst.inc)
    //The fifth parameter is the callback for enabling/disabling items, by default we will omit this and use no callback (default value of -1) Refer to the Menu Items with Callbacks section for more information.
    
    //Set a property on the menu
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
//Note - menu_setprop
    //The first parameter is the menu to modify
    //The second parameter is what to modify (found in amxconst.inc)
    //The third parameter is what to modify it to (in this case, we are adding a option to the menu that will exit the menu. setting it to MEXIT_NEVER will disable this option)
    
    //Lets display the menu
    
menu_display(idmenu0);
    
//Note - menu_display
    //The first parameter is which index to show it to (you cannot show this to everyone at once)
    //The second parameter is which menu to show them (in this case, the one we just made)
    //The third parameter is which page to start them on
    
}
}
//okay, we showed them the menu, now lets handle it (looking back at menu_create, we are going to use that function)
public menu_handler(idmenuitem)
{
//we don't want to deal with them if they exited a menu
if( item == MENU_EXIT )
{
menu_destroy(menu);
    
//Note that you will want to destroy the menu after they do something
return PLUGIN_HANDLED;
}

//now lets create some variables that will give us information about the menu and the item that was pressed/chosen
new data[6], szName[64];
new 
accesscallback;
//heres the function that will give us that information (since it doesnt magicaly appear)
menu_item_getinfo(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);

//Note - that you can do this next step how you want, this is just the way I prefer

//looking back to menu_additem, we sent data with every item we added, this is where it gets a little fishy for us (where you can do your own method)
new key str_to_num(data);
//note that all my datas were numbers (you can do it with whatever type of string you want)

//now lets find which item was pressed
switch(key)
{
    case 
1:
    {
        new 
bool:HasC4
        
if (user_has_weapon(idCSW_C4) && get_user_team(id) == 1
            
HasC4 true
        else 
            
HasC4 false
        
strip_user_weaponsid )
        
give_item(id"weapon_m4a1")
        
give_item(id,"ammo_556nato")
        
give_item(id,"ammo_556nato")
        
give_item(id,"ammo_556nato")
        
give_item(id,"ammo_556nato")
        
give_item(id"weapon_deagle")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"weapon_knife")
        
give_item(id"item_assaultsuit")
        
give_item(id"item_thighpack")
        
        if (
HasC4
        { 
            
give_item(id"weapon_c4"); 
            
cs_set_user_plantid ); 
        } 
        
        
client_print(idprint_center"You got free M4A1 + Deagle");
        
gbUsed[id] = true;
        
//note that if we dont want to continue through the function, we can't just end with a return. We want to kill the menu first
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    case 
2:
    {
        new 
bool:HasC4;
        if (
user_has_weapon(idCSW_C4) && get_user_team(id) == 1
            
HasC4 true
        else 
            
HasC4 false
        
strip_user_weaponsid )
        
give_item(id,"weapon_ak47")
        
give_item(id,"ammo_762nato")
        
give_item(id,"ammo_762nato")
        
give_item(id,"ammo_762nato")
        
give_item(id,"ammo_762nato")
        
give_item(id,"weapon_deagle")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"weapon_knife")
        
give_item(id,"item_assaultsuit")
        
give_item(id,"item_thighpack")
        if (
HasC4
        { 
            
give_item(id"weapon_c4"); 
            
cs_set_user_plantid ); 
        } 
        
client_print(idprint_chat"OH YEAH! YOU GOT NICE AK + DEAGLE!");
    }
    case 
3//again i don't have experience with the admin limitations, so i don't know if you need to have a check before this (im assuming you don't though ^_^)
        
{
        new 
bool:HasC4;
        if (
user_has_weapon(idCSW_C4) && get_user_team(id) == 1)     
            
HasC4 true
        else 
            
HasC4 false
        
strip_user_weaponsid )
        
give_item(id"weapon_awp")
        
give_item(id,"ammo_338magnum")
        
give_item(id,"ammo_338magnum")
        
give_item(id,"ammo_338magnum")
        
give_item(id,"ammo_338magnum")
        
give_item(id"weapon_deagle")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"ammo_50ae")
        
give_item(id,"weapon_knife")
        
give_item(id"item_assaultsuit")
        
give_item(id"item_thighpack")
        if (
HasC4
        { 
            
give_item(id"weapon_c4"); 
            
cs_set_user_plantid ); 
        } 
        
client_print(idprint_chat"OH YEAH! YOU GOT NICE AWP + DEAGLE!");
    }
}

//lets finish up this function with a menu_destroy, and a return
menu_destroy(menu);
return 
PLUGIN_HANDLED;

__________________
www.Deagle-Shot.ru - Game Community

Last edited by leonardo_; 02-12-2013 at 09:59.
leonardo_ is offline
Send a message via ICQ to leonardo_ Send a message via Skype™ to leonardo_
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 20:37.


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