AlliedModders

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

nacho312 09-23-2020 20:16

Question
 
Yo modders, I just want to ask you a question related to menus.
Well, for example, I have a menu, And I have a golden ak47 plugin, how can I put something on the goldenak's sma so It can be called in one of the menu's cases, I think It's called "Native" as far as i know.
I tried to read the menu tutorial submitted by Emp and many more and I understandood the basics of menu functions, I would prefer to know how I can do this my self and test it than posting a sma and telling you to do it instead.
I Dont know if this is the right section but I posted here since this process requires editing a script so It can be done. Thank you for reading

Supremache 09-23-2020 21:10

Re: Question
 
Quote:

Originally Posted by nacho312 (Post 2718557)
Yo modders, I just want to ask you a question related to menus.
Well, for example, I have a menu, And I have a golden ak47 plugin, how can I put something on the goldenak's sma so It can be called in one of the menu's cases, I think It's called "Native" as far as i know.
I tried to read the menu tutorial submitted by Emp and many more and I understandood the basics of menu functions, I would prefer to know how I can do this my self and test it than posting a sma and telling you to do it instead.
I Dont know if this is the right section but I posted here since this process requires editing a script so It can be done. Thank you for reading

https://forums.alliedmods.net/showpo...&postcount=279
https://forums.alliedmods.net/showthread.php?t=327494

nacho312 09-23-2020 21:33

Re: Question
 
Thanks, I've readed that, But still need an answer to my question, how can I find the function that calls the "item get" so I can use it somewhere else like in a menu or something. Thanks again

Supremache 09-23-2020 22:11

Re: Question
 
Quote:

Originally Posted by nacho312 (Post 2718562)
Thanks, I've readed that, But still need an answer to my question, how can I find the function that calls the "item get" so I can use it somewhere else like in a menu or something. Thanks again

Np, For finding that, you have to check public plugin_init() for that function had called on register_clcmd or register_concmd

This is the simple way :wink:
For Example: "The function will be "public CmdBuyAk(id)"
PHP Code:

register_clcmd("goldenshop_goldenak""CmdBuyAk")
    
register_clcmd("goldenshop_goldenak""CmdBuyAk")


public 
CmdBuyAk(id)
{
    if ( !
is_user_alive(id) )
    {
        
client_print(id,print_chat"^4[BB 6.8] To buy golden Ak 47 You need to be alive!")
        return 
PLUGIN_HANDLED
    
}
    
    new 
money cs_get_user_money(id)
    
    if (
money >= get_pcvar_num(cvar_cost))
    {
        
cs_set_user_money(idmoney get_pcvar_num(cvar_cost))
        
give_item(id"weapon_ak47")
        
g_HasAk[id] = true
    
}
    
    else
    {
        
client_print(idprint_chat"^4[BB 6.8] You dont hav enough money to buy Golden Ak 47. Cost $%d "get_pcvar_num(cvar_cost))
    }
    return 
PLUGIN_HANDLED



nacho312 09-23-2020 22:17

Re: Question
 
Quote:

Originally Posted by Supremache (Post 2718565)
Np, For finding that, you have to check public plugin_init() for that function had called on register_clcmd or register_concmd

This is the simple way :wink:
For Example: "The function will be "public CmdBuyAk(id)"
PHP Code:

register_clcmd("goldenshop_goldenak""CmdBuyAk")
    
register_clcmd("goldenshop_goldenak""CmdBuyAk")


public 
CmdBuyAk(id)
{
    if ( !
is_user_alive(id) )
    {
        
client_print(id,print_chat"^4[BB 6.8] To buy golden Ak 47 You need to be alive!")
        return 
PLUGIN_HANDLED
    
}
    
    new 
money cs_get_user_money(id)
    
    if (
money >= get_pcvar_num(cvar_cost))
    {
        
cs_set_user_money(idmoney get_pcvar_num(cvar_cost))
        
give_item(id"weapon_ak47")
        
g_HasAk[id] = true
    
}
    
    else
    {
        
client_print(idprint_chat"^4[BB 6.8] You dont hav enough money to buy Golden Ak 47. Cost $%d "get_pcvar_num(cvar_cost))
    }
    return 
PLUGIN_HANDLED



Ah, thank you :) ,and there is no other way by registring native on goldenak's sma ? I want to add this item in another menu.

Bugsy 09-23-2020 22:29

Re: Question
 
You will want to set g_HasAk[id] = false when player dies or drops AK..if you're using this variable.

nacho312 09-23-2020 22:35

Re: Question
 
Quote:

Originally Posted by Bugsy (Post 2718568)
You will want to set g_HasAk[id] = false when player dies or drops AK..if you're using this variable.

Alright, thanks for replying.

Supremache 09-24-2020 00:18

Re: Question
 
Quote:

Originally Posted by nacho312 (Post 2718567)
Ah, thank you :) ,and there is no other way by registring native on goldenak's sma ? I want to add this item in another menu.

For using this native on any plugin just add this code in global var "native get_user_goldak(id)"
Code:
#define is_valid_connected(%1) (1 <= %1 <= get_maxplayers()) public plugin_natives() {     register_native("get_user_goldak","native_get_user_goldak") } public native_get_user_goldak() {     new index = read_data(1)     if(!is_valid_connected(index))     return 0;         engclient_cmd(index, "weapon_ak47");     g_HasAk[index] = true     checkModel(index);         return 1;     }

nacho312 09-24-2020 00:44

Re: Question
 
Thanks.


All times are GMT -4. The time now is 13:45.

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