Raised This Month: $535 Target: $400
 133% 

Question


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
nacho312
Member
Join Date: Mar 2020
Old 09-23-2020 , 21:16   Question
Reply With Quote #1

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

Last edited by nacho312; 09-23-2020 at 21:18.
nacho312 is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 09-23-2020 , 22:10   Re: Question
Reply With Quote #2

Quote:
Originally Posted by nacho312 View Post
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
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
nacho312
Member
Join Date: Mar 2020
Old 09-23-2020 , 22:33   Re: Question
Reply With Quote #3

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

Last edited by nacho312; 09-23-2020 at 22:37.
nacho312 is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 09-23-2020 , 23:11   Re: Question
Reply With Quote #4

Quote:
Originally Posted by nacho312 View Post
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
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

__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
nacho312
Member
Join Date: Mar 2020
Old 09-23-2020 , 23:17   Re: Question
Reply With Quote #5

Quote:
Originally Posted by Supremache View Post
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
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.

Last edited by nacho312; 09-23-2020 at 23:19.
nacho312 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-23-2020 , 23:29   Re: Question
Reply With Quote #6

You will want to set g_HasAk[id] = false when player dies or drops AK..if you're using this variable.
__________________
Bugsy is offline
nacho312
Member
Join Date: Mar 2020
Old 09-23-2020 , 23:35   Re: Question
Reply With Quote #7

Quote:
Originally Posted by Bugsy View Post
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.
nacho312 is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 09-24-2020 , 01:18   Re: Question
Reply With Quote #8

Quote:
Originally Posted by nacho312 View Post
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;    }
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.

Last edited by Supremache; 09-24-2020 at 01:22.
Supremache is offline
nacho312
Member
Join Date: Mar 2020
Old 09-24-2020 , 01:44   Re: Question
Reply With Quote #9

Thanks.
nacho312 is offline
Reply


Thread Tools
Display Modes

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 04:02.


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