Raised This Month: $ Target: $400
 0% 

[ HELP ] Don't allow select same case in round


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JoaoVieira
Senior Member
Join Date: May 2013
Location: Portugal
Old 09-01-2016 , 23:32   [ HELP ] Don't allow select same case in round
Reply With Quote #1

I want to dont allow player to select same case in round like , If user select deagle , he won't be able to select it again in the same round. Thanks.
PS: This is a test menu.

Sorry for my english

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

#include <amxmodx>
#include <amxmisc>
#include <colorchat>
#include <fun>

#define PLUGIN "Simple Menu"
#define VERSION "1.0"
#define AUTHOR "NapoleoN#"

new iPoints[33]

new 
pCvarPreco1

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /points""DisplayMenu")
    
    
register_event("DeathMsg""eDeath""a""1>0")
    
    
pCvarPreco1 register_cvar("preco1""5")
}

public 
DisplayMenu(id) {
    new 
menu menu_create("\w[\r AMXX \w]^n\yBuy""menu_handler")
    
    
menu_additem(menu"\ybuy 1""1")
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
menu_display(idmenu)
}

public 
menu_handler(idmenuitem) {
    new 
price get_pcvar_num(pCvarPreco1)
    
    switch(
item) {
        case 
0: {
            if(
iPoints[id] >= price && is_user_alive(id)) {
                
give_item(id"weapon_deagle")
            } 
            else {
                
ColorChat(idGREEN"[AMXX]^1 You don't have enough points.")
            }
        }
    }
    
menu_destroy(menu)
}

public 
eDeath() {
    new 
killer    read_data(1)
    new 
victim    read_data(2)
    
    if(
killer != victim) {
        
iPoints[killer]++
    }


Last edited by JoaoVieira; 09-01-2016 at 23:37.
JoaoVieira is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 09-02-2016 , 04:27   Re: [ HELP ] Don't allow select same case in round
Reply With Quote #2

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <colorchat>
#include <fun>

#define PLUGIN "Simple Menu"
#define VERSION "1.0"
#define AUTHOR "NapoleoN#"

new iPoints[33]

new 
pCvarPreco1

new bool:hasDeagle[33]

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /points""DisplayMenu")
    
    
register_event("DeathMsg""eDeath""a""1>0")
    
    
register_logevent("RoundStart"2"1=Round_Start")
    
    
pCvarPreco1 register_cvar("preco1""5")
}

public 
RoundStart() {
    new 
players[32], inum
    get_players
(playersinum)
    
    for(new 
iinumi++) {
        if(
hasDeagle[players[i]] == true) {
            
hasDeagle[players[i]] = false
        
}
    }
}

public 
DisplayMenu(id) {
    new 
menu menu_create("\w[\r AMXX \w]^n\yBuy""menu_handler")
    
    
menu_additem(menu"\ybuy 1""1")
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
menu_display(idmenu)
}

public 
menu_handler(idmenuitem) {
    new 
price get_pcvar_num(pCvarPreco1)
    
    switch(
item) {
        case 
0: {
            if(
hasDeagle[id] == false) {
                if(
iPoints[id] >= price && is_user_alive(id)) {
                    
give_item(id"weapon_deagle")
                } 
                else {
                    
ColorChat(idGREEN"[AMXX]^1 You don't have enough points.")
                }
            }
            else {
                
ColorChat(idGREEN"[AMXX]^1 You can only use this once per round.")
            }
        }
    }
    
menu_destroy(menu)
}

public 
eDeath() {
    new 
killer    read_data(1)
    new 
victim    read_data(2)
    
    if(
killer != victim) {
        
iPoints[killer]++
    }

__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
JoaoVieira
Senior Member
Join Date: May 2013
Location: Portugal
Old 09-02-2016 , 08:58   Re: [ HELP ] Don't allow select same case in round
Reply With Quote #3

Can i use this
Code:
   if(hasDeagle[id] == false) {
for every case?

#edit

Didn't work , i can still buy more than 1 time per round the same case

Last edited by JoaoVieira; 09-02-2016 at 09:11.
JoaoVieira is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 09-02-2016 , 09:38   Re: [ HELP ] Don't allow select same case in round
Reply With Quote #4

Should work now

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <colorchat>
#include <fun>

#define PLUGIN "Simple Menu"
#define VERSION "1.0"
#define AUTHOR "NapoleoN#"

new iPoints[33]

new 
pCvarPreco1

new bool:hasDeagle[33]

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /points""DisplayMenu")
    
    
register_event("DeathMsg""eDeath""a""1>0")
    
    
register_logevent("RoundStart"2"1=Round_Start")
    
    
pCvarPreco1 register_cvar("preco1""5")
}

public 
RoundStart() {
    new 
players[32], inum
    get_players
(playersinum)
    
    for(new 
iinumi++) {
        if(
hasDeagle[players[i]] == true) {
            
hasDeagle[players[i]] = false
        
}
    }
}

public 
DisplayMenu(id) {
    new 
menu menu_create("\w[\r AMXX \w]^n\yBuy""menu_handler")
    
    
menu_additem(menu"\ybuy 1""1")
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
menu_display(idmenu)
}

public 
menu_handler(idmenuitem) {
    new 
price get_pcvar_num(pCvarPreco1)
    
    switch(
item) {
        case 
0: {
            if(
hasDeagle[id] == false) {
                if(
iPoints[id] >= price && is_user_alive(id)) {
                    
give_item(id"weapon_deagle")
                    
hasDeagle[id] = true
                

                else {
                    
ColorChat(idGREEN"[AMXX]^1 You don't have enough points.")
                }
            }
            else {
                
ColorChat(idGREEN"[AMXX]^1 You can only use this once per round.")
            }
        }
    }
    
menu_destroy(menu)
}

public 
eDeath() {
    new 
killer    read_data(1)
    new 
victim    read_data(2)
    
    if(
killer != victim) {
        
iPoints[killer]++
    }

__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
JoaoVieira
Senior Member
Join Date: May 2013
Location: Portugal
Old 09-02-2016 , 09:57   Re: [ HELP ] Don't allow select same case in round
Reply With Quote #5

Can i use that for every case? Like , if user select case 1 he wont be able to chose it again but he will be able to chose case 2 but if he chose case 2 he wont be able to open on same round aswell
JoaoVieira is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 09-02-2016 , 10:00   Re: [ HELP ] Don't allow select same case in round
Reply With Quote #6

You want every item to be purchased once?

So for example if you buy a deagle, you should still be able to buy another item or you just want to completely limit it with 1 item per round?
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
JoaoVieira
Senior Member
Join Date: May 2013
Location: Portugal
Old 09-02-2016 , 10:02   Re: [ HELP ] Don't allow select same case in round
Reply With Quote #7

Yes , xD
#edit
as i said , this is a test menu xD

Last edited by JoaoVieira; 09-02-2016 at 10:05.
JoaoVieira is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 09-02-2016 , 10:03   Re: [ HELP ] Don't allow select same case in round
Reply With Quote #8

What yes? 1 item per round no matter which item?
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
JoaoVieira
Senior Member
Join Date: May 2013
Location: Portugal
Old 09-02-2016 , 10:05   Re: [ HELP ] Don't allow select same case in round
Reply With Quote #9

No , every item to be purchased once per round!

Last edited by JoaoVieira; 09-02-2016 at 10:08.
JoaoVieira is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 09-02-2016 , 10:15   Re: [ HELP ] Don't allow select same case in round
Reply With Quote #10

Then you gotta create a new bool for every single item.

Look at what i did.

PHP Code:
new bool:hasDeagle[33// Declare a new bool. This only returns true or false. 
PHP Code:
public RoundStart() { // Reset all bools at round start.
    
new players[32], inum
    get_players
(playersinum)
    
    for(new 
iinumi++) {
        if(
hasDeagle[players[i]] == true) {
            
hasDeagle[players[i]] = false // Set deagle to false of every single player.
        
}
    }

PHP Code:
if(hasDeagle[id] == false) { // Check if user has a deagle or not, if not, continue with following code.
                
if(iPoints[id] >= price && is_user_alive(id)) {
                    
give_item(id"weapon_deagle")
                    
hasDeagle[id] = true // Set Deagle to true.
                                                // So the check we did earlier, will never pass since hasDeagle[id] = true now.
                

                else {
                    
ColorChat(idGREEN"[AMXX]^1 You don't have enough points.")
                }
            }
            else {
                
ColorChat(idGREEN"[AMXX]^1 You can only use this once per round.")
            } 
I will add a new item using M4A1 to give you another example.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <colorchat>
#include <fun>

#define PLUGIN "Simple Menu"
#define VERSION "1.0"
#define AUTHOR "NapoleoN#"

new iPoints[33]

new 
pCvarPreco1

new bool:hasDeagle[33]
new 
bool:hasM4A1[33// Declare our new bool for the new item we gonna add.

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /points""DisplayMenu")
    
    
register_event("DeathMsg""eDeath""a""1>0")
    
    
register_logevent("RoundStart"2"1=Round_Start")
    
    
pCvarPreco1 register_cvar("preco1""5")
}

public 
RoundStart() {
    new 
players[32], inum
    get_players
(playersinum)
    
    for(new 
iinumi++) {
        if(
hasDeagle[players[i]] == true) {
            
hasDeagle[players[i]] = false
            hasM4A1
[players[i]] = false // Set to false at round start so player will be able to buy M4A1 again.
        
}
    }
}

public 
DisplayMenu(id) {
    new 
menu menu_create("\w[\r AMXX \w]^n\yBuy""menu_handler")
    
    
menu_additem(menu"\ybuy 1")
    
menu_additem(menu"\yM4A1"// Adding our item to the menu to display.
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
menu_display(idmenu)
}

public 
menu_handler(idmenuitem) {
    new 
price get_pcvar_num(pCvarPreco1)
    
    switch(
item) {
        case 
0: {
            if(
hasDeagle[id] == false) {
                if(
iPoints[id] >= price && is_user_alive(id)) {
                    
give_item(id"weapon_deagle")
                    
hasDeagle[id] = true
                

                else {
                    
ColorChat(idGREEN"[AMXX]^1 You don't have enough points.")
                }
            }
            else {
                
ColorChat(idGREEN"[AMXX]^1 You can only use this once per round.")
            }
        }
        case 
1: { // Adding our new case since we have a new menu item
            
if(hasM4A1[id] == false) { // Check if user has M4A1, if not, continue with following code.
                
if(iPoints[id] >= price && is_user_alive(id)) { // Check if player has enough points to buy it and also if player is alive.
                    
give_item(id"weapon_m4a1"// Give the weapon
                    
hasM4A1[id] = true // Set to true so the player can't buy again, this gets reset at round start.
                
}
                else { 
// If player doesn't have enough points, print out the message.
                    
ColorChat(idGREEN"[AMXX]^1 You don't have enough points.")
                }
            }
            else { 
// If player already bought M4A1 this round, print a message
                
ColorChat(idGREEN"[AMXX]^1 You can only use this once per round.")
            }
        }
    }
    
menu_destroy(menu)
}

public 
eDeath() {
    new 
killer    read_data(1)
    new 
victim    read_data(2)
    
    if(
killer != victim) {
        
iPoints[killer]++
    }

Hope you understand it a bit.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
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 17:30.


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