AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Team limiting + round limiting. (https://forums.alliedmods.net/showthread.php?t=170542)

eskemo 10-26-2011 07:24

Team limiting + round limiting.
 
Not to sure on scripting but i have started, I don't know what includes are needed for this but i added aload. Ok In the menu i want it to make it you can only use that menu item once per round (NO IDEA HOW TO DO THIS AND WOULD LOVE SOME HELP!) and the 2nd thing would be making case 1 limited to the Counter-terrorist team.. and the case 2 limited to the terrorist and case 3 is to be left alone as i am not to sure if i am going to add any more thing's like a new wep or something in their atm.

If you find my typing isn't lacking grammer and letter's. Sorry I havn't had much sleep and school/work is fucking with me.
Please help me if you can thank you.

EDIT : Forgot to add can i get help on making it have a delay time from start of round so it doesn't screw with other things.
Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <amxmisc>
#include <fakemeta>
#include <fun>


#define PLUGIN "Poison + Bazooka"
#define VERSION "1.0"
#define AUTHOR "eskemo"


public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR);
    register_clcmd("avpBP","PosionBazooka" );
}

public PosionBazooka(id)
{
    new menu = menu_create("\rAlien + Predator Spec's :", "menu_handler");
    menu_additem(menu, "\wPredator Bazooka", "1", 0);
    menu_additem(menu, "\wAlien Acid", "2", 0);
    menu_additem(menu, "\rComming Soon", "3", ADMIN_ADMIN);
    menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
    menu_display(id, menu, 0);
}

public menu_handler(id, menu, item)
{
    if( item == MENU_EXIT )
    {
        menu_destroy(menu);
        return PLUGIN_HANDLED;
    }
   
    new data[6], szName[64];
    new access, callback;
    menu_item_getinfo(menu, item, access, data,charsmax(data), szName,charsmax(szName), callback);

    new key = str_to_num(data);
    switch(key)
    {
        case 1:
        if( CS_TEAM_CT == 1 )
        {
            client_print(id, print_chat, "You have just used your only Predator Missile.");
            client_print(id, print_chat, "You were given 25 Armour as a bonus of using this feature.");
            menu_destroy(menu);
            return PLUGIN_HANDLED;
        }
        else
        {
            client_print(id, print_chat, "eskemo.info : Please wait till you are on the Predators Team.");
            menu_destroy(menu);
            return PLUGIN_HANDLED;
        }
        case 2:
        if( CS_TEAM_T == 1 )
        {
            client_print(id, print_chat, "You have just used your only Alien Acid");
            client_print(id, print_chat, "You were given a 200 health bonus for using this feature");
            menu_destroy(menu);
            return PLUGIN_HANDLED;
        }
        else
        {
            client_print(id, print_chat, "Eskemo.info : Please wait till you are on the Aliens Team.");
            menu_destroy(menu);
            return PLUGIN_HANDLED;
        }
        case 3:
        {
            client_print(id, print_chat, "Admin Selection Comming soon");
            return PLUGIN_HANDLED;
        }
    }
    menu_destroy(menu);
    return PLUGIN_HANDLED;
}


Evaldas.Grigas 10-26-2011 09:25

Re: Team limiting + round limiting.
 
Here this code should make it that it could be used once per round.
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <amxmisc>
#include <fakemeta>
#include <fun>

#define MAXPLAYERS 10 + 1

#define PLUGIN "Poison + Bazooka"
#define VERSION "1.0"
#define AUTHOR "eskemo"

new bool:gbUsed[MAXPLAYERS];

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_clcmd("avpBP","PosionBazooka" );
}

public 
eventRoundEnd()
{
    
arraysetgbUsedfalseMAXPLAYERS )
}

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

public 
PosionBazooka(id)
{
    if (!
gbUsed[id])
    {
    new 
menu menu_create("\rAlien + Predator Spec's :""menu_handler");
    
menu_additem(menu"\wPredator Bazooka""1"0);
    
menu_additem(menu"\wAlien Acid""2"0);
    
menu_additem(menu"\rComming Soon""3"ADMIN_ADMIN);
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
menu_display(idmenu0);
    
gbUsed[id] = true;
    }
    return 
PLUGIN_HANDLED
}

public 
menu_handler(idmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    new 
data[6], szName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);

    new 
key str_to_num(data);
    switch(
key)
    {
    case 
1:
    {
    if( 
get_user_team(id) == )
    {
        
client_print(idprint_chat"You have just used your only Predator Missile.");
        
client_print(idprint_chat"You were given 25 Armour as a bonus of using this feature.");
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    else
    {
        
client_print(idprint_chat"eskemo.info : Please wait till you are on the Predators Team.");
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    }
    case 
2:
    {
    if( 
get_user_team(id) == )
    {
        
client_print(idprint_chat"You have just used your only Alien Acid");
        
client_print(idprint_chat"You were given a 200 health bonus for using this feature");
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    else
    {
        
client_print(idprint_chat"Eskemo.info : Please wait till you are on the Aliens Team.");
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    }
    case 
3:
    {
        
client_print(idprint_chat"Admin Selection Comming soon");
        return 
PLUGIN_HANDLED;
    }
    }
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;



eskemo 10-26-2011 17:27

Re: Team limiting + round limiting.
 
Thanks :) Now i see what i did wrong for the player teams aswell :o

Just tested it's still being used multiple times :o

eskemo 10-26-2011 17:43

Re: Team limiting + round limiting.
 
I apologise, It does work. but by the looks of it once per map. I need it once per round. how do you change this?

Blue Snake. 10-27-2011 08:23

Re: Team limiting + round limiting.
 
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <amxmisc>
#include <fakemeta>
#include <fun>

#define MAXPLAYERS 33

#define PLUGIN "Poison + Bazooka"
#define VERSION "1.0"
#define AUTHOR "eskemo"

new bool:gbUsed[MAXPLAYERS];

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_logevent"EventRoundEnd"2"1=Round_End" );
    
register_clcmd("avpBP","PosionBazooka" );
}

public 
EventRoundEnd()
{
    for(new 
i=0;i<MAXPLAYERS;i++)
        
gbUsed[i]=false;
}

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

public 
PosionBazooka(id)
{
    if (!
gbUsed[id])
    {
    new 
menu menu_create("\rAlien + Predator Spec's :""menu_handler");
    
menu_additem(menu"\wPredator Bazooka""1"0);
    
menu_additem(menu"\wAlien Acid""2"0);
    
menu_additem(menu"\rComming Soon""3"ADMIN_ADMIN);
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
menu_display(idmenu0);
    
gbUsed[id] = true;
    }
    return 
PLUGIN_HANDLED
}

public 
menu_handler(idmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    new 
data[6], szName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);

    new 
key str_to_num(data);
    switch(
key)
    {
    case 
1:
    {
    if( 
get_user_team(id) == )
    {
        
client_print(idprint_chat"You have just used your only Predator Missile.");
        
client_print(idprint_chat"You were given 25 Armour as a bonus of using this feature.");
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    else
    {
        
client_print(idprint_chat"eskemo.info : Please wait till you are on the Predators Team.");
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    }
    case 
2:
    {
    if( 
get_user_team(id) == )
    {
        
client_print(idprint_chat"You have just used your only Alien Acid");
        
client_print(idprint_chat"You were given a 200 health bonus for using this feature");
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    else
    {
        
client_print(idprint_chat"Eskemo.info : Please wait till you are on the Aliens Team.");
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    }
    case 
3:
    {
        
client_print(idprint_chat"Admin Selection Comming soon");
        return 
PLUGIN_HANDLED;
    }
    }
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;


Try this.

Xellath 10-27-2011 09:02

Re: Team limiting + round limiting.
 
Use arrayset() to set an array to a certain value instead of looping through players.

Instead of:
Code:
// MAXPLAYERS shouldn't be hardcoded either, cache and use get_maxplayers() for(new i=0;i<MAXPLAYERS;i++)     gbUsed[i]=false;

Use:
Code:
// hardcoding MAXPLAYERS to 33 here is okay, because the array is created with 33 cells (of course using the cached value of get_maxplayers() is fine as well, but just for reference) arrayset(gbUsed, false, MAXPLAYERS);


All times are GMT -4. The time now is 14:16.

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