AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Plugin Bug (https://forums.alliedmods.net/showthread.php?t=311515)

PutoMike 10-21-2018 05:17

Plugin Bug
 
I was trying to remove the knife menu from the furien_mod plugin (https://forums.alliedmods.net/showthread.php?t=295084) I think I did everything right, the plugin is supposed to be working but it does not let you use the menu knives do not open it.

Plugin

Kushfield 10-21-2018 05:40

Re: Plugin Bug
 
Quote:

Originally Posted by PutoMike (Post 2620612)
I was trying to remove the knife menu from the furien_mod plugin (https://forums.alliedmods.net/showthread.php?t=295084) I think I did everything right, the plugin is supposed to be working but it does not let you use the menu knives do not open it.

So you tried to remove the knife menu and now the knife menu doesn't work?
I don't get what the problem is.

PutoMike 10-21-2018 06:13

Re: Plugin Bug
 
The plugin work but just don't open the menu -.-

OciXCrom 10-21-2018 07:50

Re: Plugin Bug
 
Are you even listening to yourself?

Kanek1 10-21-2018 10:21

Re: Plugin Bug
 
Quote:

Originally Posted by PutoMike (Post 2620612)
I was trying to remove the knife menu from the furien_mod plugin (https://forums.alliedmods.net/showthread.php?t=295084) I think I did everything right, the plugin is supposed to be working but it does not let you use the menu knives do not open it.

Plugin

Example:
Code:

if (is_user_alive(id)){
Show your menu
}

And add in plugin init if round start show your menu

PutoMike 10-21-2018 11:08

Re: Plugin Bug
 
I've solved this BUG, ​​now I wanted to know how I can type choose only 1 knife per round, when I choose the knife the menu does not open anymore only in the next round

New Plugin

Kanek1 10-21-2018 11:28

Re: Plugin Bug
 
Quote:

Originally Posted by PutoMike (Post 2620648)
I've solved this BUG, ​​now I wanted to know how I can type choose only 1 knife per round, when I choose the knife the menu does not open anymore only in the next round

New Plugin

Done :)
You need add/remake this.

PHP Code:


new g_round[33]

public 
plugin_init() 

RegisterHam(Ham_Spawn"player""FwdHamSpawn_Post"1); 
}

public 
FwdHamSpawn_Post(id

    if(
is_user_alive(id)){ 
        
g_round[id] = 0        
    

}

Open_ShopKnives(id
{
    if(!
is_user_alive(id) || cs_get_user_team(id) == CS_TEAM_CT)
    {
        return 
PLUGIN_HANDLED
    
}

 if(
g_round[id] == 0)
{
    new 
formatMsg[80]
    
    new 
hKnf menu_create("\yFurien \d|| \rFacas""Handler_ShopKnives")
    
    new 
szComprado[MAX_PLAYERS]
    
formatex(szCompradocharsmax(szComprado), "\w[%L]"id"MENU_BOUGHT")
    
    
formatex(formatMsgcharsmax(formatMsg), "Normal Knife ^t^t^t^t%s^n\d - %L", (g_szKnife[id][TOTAL_KNIVES] == KNIFE_DEFAULT) ? szComprado ""id"MENU_KNIFE_DEFAULT")
    
menu_additem(hKnf,formatMsg,"1",0)
    
    
formatex(formatMsgcharsmax(formatMsg), "Combat Knife ^t^t^t^t%s^n\d - %L", (g_szKnife[id][TOTAL_KNIVES] == KNIFE_COMBAT) ? szComprado "\r15$"id"MENU_KNIFE_COMBAT")
    
menu_additem(hKnf,formatMsg,"2",0)
    
    
formatex(formatMsgcharsmax(formatMsg), "PickAxe Knife ^t^t^t %s^n\d - %L", (g_szKnife[id][TOTAL_KNIVES] == KNIFE_AXE) ? szComprado "\r25$"id"MENU_KNIFE_AXE")
    
menu_additem(hKnf,formatMsg,"3",0)
    
    
formatex(formatMsgcharsmax(formatMsg), "Silver Knife  ^t^t^t^t %s^n\d - %L", (g_szKnife[id][TOTAL_KNIVES] == KNIFE_SILVER) ? szComprado "\r20$ \y[VIP]"id"MENU_KNIFE_SILVER")
    
menu_additem(hKnf,formatMsg,"4",0)
    
    
formatex(formatMsgcharsmax(formatMsg), "Hunter Knife ^t^t^t^t %s^n\d - %L", (g_szKnife[id][TOTAL_KNIVES] == KNIFE_HUNTER) ? szComprado "\r40$ \y[VIP]"id"MENU_KNIFE_HUNTER")
    
menu_additem(hKnf,formatMsg,"5",0)
    
    
formatex(formatMsgcharsmax(formatMsg), "%L"id"MORE")
    
menu_additem(hKnf,formatMsg,"6",0)
    
    
formatex(formatMsgcharsmax(formatMsg), "\r%L"id"BACK")
    
menu_additem(hKnf,formatMsg,"7",0)
    
    
menu_setprop(hKnfMPROP_EXITMEXIT_ALL)
    
menu_display(idhKnf0)
    
    }
    return 
PLUGIN_HANDLED
}

Open_ShopKnives2(id
{
    if(!
is_user_alive(id) || cs_get_user_team(id) == CS_TEAM_CT)
    {
        return 
PLUGIN_HANDLED
    
}
if(
g_round[id] == 0)
{
    new 
formatMsg[70]
    
    new 
hKnf menu_create("\yFurien \d|| \rFacas""Handler_ShopKnives2")
    
    new 
szComprado[MAX_PLAYERS]
    
formatex(szCompradocharsmax(szComprado), "\w[%L]"id"MENU_BOUGHT")
    
    
formatex(formatMsgcharsmax(formatMsg), "Spirit Knife ^t^t^t^t %s^n\d - %L", (g_szKnife[id][TOTAL_KNIVES] == KNIFE_SPIRIT) ? szComprado "\r20$"id"MENU_KNIFE_SPIRIT")
    
menu_additem(hKnf,formatMsg,"1",0)
    
    
formatex(formatMsgcharsmax(formatMsg), "Epic Knife  ^t^t^t^t %s^n\d - %L", (g_szKnife[id][TOTAL_KNIVES] == KNIFE_EPIC) ? szComprado "\r30$ \y[ExtraVIP]"id"MENU_KNIFE_EPIC")
    
menu_additem(hKnf,formatMsg,"2",0)
    
    
formatex(formatMsgcharsmax(formatMsg), "Crowbar Knife^t^t %s^n\d - %L", (g_szKnife[id][TOTAL_KNIVES] == KNIFE_CROWBAR) ? szComprado "\r40$ \y[ExtraVIP]"id"MENU_KNIFE_CROWBAR")
    
menu_additem(hKnf,formatMsg,"3",0)
    
    
formatex(formatMsgcharsmax(formatMsg), "Dead Knife ^t^t^t^t %s^n\d - %L", (g_szKnife[id][TOTAL_KNIVES] == KNIFE_DEAD) ? szComprado "\r50$ \y[ExtraVIP]"id"MENU_KNIFE_DEAD")
    
menu_additem(hKnf,formatMsg,"4",0)
    
    
formatex(formatMsgcharsmax(formatMsg), "%L"id"BACK")
    
menu_additem(hKnf,formatMsg,"5",0)
    
    
menu_setprop(hKnfMPROP_EXITMEXIT_ALL)
    
menu_display(idhKnf0)
}
    
    return 
PLUGIN_HANDLED
}

public 
Handler_ShopKnives(idhMenuiItem) {
    if(
iItem == MENU_EXIT || !is_user_alive(id) || cs_get_user_team(id) == CS_TEAM_CT)
    {
        
menu_destroy(hMenu)
        return 
PLUGIN_HANDLED
    
}
    
    if(
g_bRoundEnd)
    {
        
        
CantRightNow(id)
        return 
PLUGIN_HANDLED
    
}
    
    new 
szData[6], iAccess2hCallback
    menu_item_getinfo
(hMenuiItemiAccess2szData5__hCallback)
    new 
iKey str_to_num(szData)
    new 
iUserFlag get_user_flags(id)
    
    switch(
iKey)
    {
        case 
1:
        {
            if(
g_szKnife[id][TOTAL_KNIVES] != KNIFE_DEFAULT)
            {
                
g_round[id] = 1
                g_szKnife
[id][TOTAL_KNIVES] = KNIFE_DEFAULT
                EmitSnd
(id,ItemBoughtSound)
            }
            else 
            {
                
youAlreadyHave(id"Normal knife")
            }
            
Open_ShopKnives(id)
        }
        
        case 
2:
        {
            if(
g_szKnife[id][TOTAL_KNIVES] != KNIFE_COMBAT)
            {
                
g_round[id] = 1
                fm_set_user_armor
(idpev(idpev_armorvalue) + 10)
                
                
g_szKnife[id][TOTAL_KNIVES] = KNIFE_COMBAT
                EmitSnd
(id,ItemBoughtSound)
                
            } 
            else 
            {
                
youAlreadyHave(id"Combat knife")
            }
            
Open_ShopKnives(id)
        }
        
        case 
3
        {
            if(
g_szKnife[id][TOTAL_KNIVES] != KNIFE_AXE)
            {
                
g_round[id] = 1
                fm_set_user_health
(idpev(idpev_health) + 20)
                
                
g_szKnife[id][TOTAL_KNIVES] = KNIFE_AXE
                EmitSnd
(id,ItemBoughtSound)
            } 
            else 
            {
                
youAlreadyHave(id"Axe knife")
            }
            
Open_ShopKnives(id)
        }
        
        case 
4:
        {
            if(
iUserFlag ADMIN_VIP || iUserFlag ADMIN_SVIP)
            {
                if(
g_szKnife[id][TOTAL_KNIVES] != KNIFE_SILVER)
                {
                    
g_round[id] = 1
                    fm_set_user_health
(idpev(idpev_health) + 10)
                    
                    
g_szKnife[id][TOTAL_KNIVES] = KNIFE_SILVER
                    EmitSnd
(idItemBoughtSound)
                } 
                else 
                {
                    
youAlreadyHave(id"Silver knife")
                }
            }
            else
            {
                
noAccessfunc(id,ADMIN_SVIP)
            }
            
Open_ShopKnives(id)
        }
        
        case 
5
        {
            if(
iUserFlag ADMIN_VIP || iUserFlag ADMIN_SVIP)
            {
                if(
g_szKnife[id][TOTAL_KNIVES] != KNIFE_HUNTER)
                {
                    
g_round[id] = 1
                    g_szKnife
[id][TOTAL_KNIVES] = KNIFE_HUNTER
                    EmitSnd
(id,ItemBoughtSound)
                    
                } 
                else 
                {
                    
youAlreadyHave(id"Hunter knife")
                }
            }
            else
            {
                
noAccessfunc(id,ADMIN_SVIP)
            }
            
Open_ShopKnives(id)
        }
        
        case 
6Open_ShopKnives2(id)
            
    }
    
    return 
PLUGIN_HANDLED
}

public 
Handler_ShopKnives2(idhMenuiItem
{
    if(
iItem == MENU_EXIT || !is_user_alive(id) || cs_get_user_team(id) == CS_TEAM_CT)
    {
        
menu_destroy(hMenu)
        return 
PLUGIN_HANDLED
    
}
    
    if(
g_bRoundEnd)
    {
        
CantRightNow(id)
        return 
PLUGIN_HANDLED
    
}
    
    new 
szData[6], iAccess2hCallback
    menu_item_getinfo
(hMenuiItemiAccess2szData5__hCallback)
    new 
iKey str_to_num(szData)
    new 
iUserFlag get_user_flags(id)
    
    switch(
iKey)
    {
        case 
1
        {
            if(
g_szKnife[id][TOTAL_KNIVES] != KNIFE_SPIRIT)
            {
                
g_round[id] = 1
                fm_set_user_health
(idpev(idpev_health) + 5)
                
                
g_szKnife[id][TOTAL_KNIVES] = KNIFE_SPIRIT
                EmitSnd
(id,ItemBoughtSound)
                
                
            } 
            else 
            {
                
youAlreadyHave(id"Spirit knife")
            }
            
Open_ShopKnives2(id)
        }
        
        case 
2
        {
            if(
iUserFlag ADMIN_SVIP)
            {
                if(
g_szKnife[id][TOTAL_KNIVES] != KNIFE_EPIC)
                {
                    
g_round[id] = 1
                    g_szKnife
[id][TOTAL_KNIVES] = KNIFE_EPIC
                    EmitSnd
(id,ItemBoughtSound)
                    
                    
                } 
                else 
                {
                    
youAlreadyHave(id"Epic knife")
                }
            }
            else
            {
                
noAccessfunc(id,ADMIN_SVIP)
            }
            
Open_ShopKnives2(id)
        }
        
        case 
3:
        {
            if(
iUserFlag ADMIN_SVIP)
            {
                if(
g_szKnife[id][TOTAL_KNIVES] != KNIFE_CROWBAR)
                {
                    
g_round[id] = 1
                    fm_set_user_health
(idpev(idpev_health) + 10)
                    
                    
g_szKnife[id][TOTAL_KNIVES] = KNIFE_CROWBAR
                    EmitSnd
(id,ItemBoughtSound)
                    
                    
                } 
                else 
                {
                    
youAlreadyHave(id"Crowbar knife")
                }
            }
            else
            {
                
noAccessfunc(id,ADMIN_SVIP)
            }
            
Open_ShopKnives2(id)
        }
        
        case 
4:
        {
            if(
iUserFlag ADMIN_SVIP)
            {
                if(
g_szKnife[id][TOTAL_KNIVES] != KNIFE_DEAD)
                {
                    
g_round[id] = 1
                    g_szKnife
[id][TOTAL_KNIVES] = KNIFE_DEAD
                    EmitSnd
(id,ItemBoughtSound)
                    
                    
                } 
                else 
                {
                    
youAlreadyHave(id"Dead knife")
                }
            }
            else
            {
                
noAccessfunc(id,ADMIN_SVIP)
            }
            
Open_ShopKnives2(id)
        }
        
        case 
5Open_ShopKnives(id)
        }
    
    return 
PLUGIN_HANDLED



Kushfield 10-21-2018 11:30

Re: Plugin Bug
 
Create a global boolean array with 33 (MAX_PLAYERS + 1) cell size. When a player gets a knife, set the array index corresponding to player's index to true. Before displaying the menu to the player, add an if clause to make sure that the player hasn't already opened the menu (!array[id]). On new round or player spawn, reset the value(s) to false.

EDIT: Too late, but @Kanek1, your code never sets "g_round[id] = 1" so it won't do anything

Kanek1 10-21-2018 11:45

Re: Plugin Bug
 
Quote:

Originally Posted by Kushfield (Post 2620654)
Create a global boolean array with 33 (MAX_PLAYERS + 1) cell size. When a player gets a knife, set the array index corresponding to player's index to true. Before displaying the menu to the player, add an if clause to make sure that the player hasn't already opened the menu (!array[id]). On new round or player spawn, reset the value(s) to false.

EDIT: Too late, but @Kanek1, your code never sets "g_round[id] = 1" so it won't do anything

sorry i dont done that because i lost net xD

PutoMike 10-21-2018 14:51

Re: Plugin Bug
 
Thanks


All times are GMT -4. The time now is 03:06.

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