AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] For item which cost money. (https://forums.alliedmods.net/showthread.php?t=194843)

sintetic 08-31-2012 19:30

[HELP] For item which cost money.
 
Hello there,first let me tell you that I am not englisham and I don't know english perfectly,also I am still newbie at scripting/coding,but I can make my own menu,with some functions but I want some of the functions to cost money in game money,so I will give you a short example.
As you type /menu,a menu displays on your screen you choose the first option,which give you "HE grenade" and I want the "HE grenade" to cost like 1000$,or 500$.
So how can I make that funciton to cost,I have watched deathrun shops but I can't understand anything there...So please help me,tell me as much as information you can tell me.Thanks in advance :)

Infernuz 08-31-2012 19:32

Re: [HELP] For item which cost money.
 
Show first what you have done.

sintetic 08-31-2012 19:39

Re: [HELP] For item which cost money.
 
That's my menu with options,but how can I make the first option to cost like 500$ ?

PHP Code:

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


public plugin_init()
{
    
register_plugin("TEST","1.0","Pris")
    
register_clcmd("say /menu","ClientCommand_Menu")
    
register_clcmd("say /menu","ClientCommand_Menu")
    
register_clcmd("say /menu","sht_silent")
    
register_event("CurWeapon","FwdSetMaxSpeed","be")
    
}
public 
FwdSetMaxSpeed(id)
{
    
set_user_maxspeed(id,1040.0)
}


public 
sht_silent()
{
    return 
PLUGIN_HANDLED_MAIN
}

public  
ClientCommand_Menu(id)
{
    new 
menu menu_create("Select option","function")
    
    
menu_additem(menu,"HE GRENADE","1",0)
    
menu_additem(menu ,"600 SPEED","2",0)
    
menu_additem(menu,"200 GRAVITY","3",0)
    
menu_additem(menu,"10k ARMOR","4",0)
    
    
menu_display(id,menu,0)
}
public  function(
id,menu,item)
{
    if(
item==MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    new 
iData[6],szName[64]
    new 
access,callback
    
    menu_item_getinfo
(menu,item,access,iData,charsmax(iData),szName,charsmax (szName),callback)
    
    new 
key str_to_num(iData)
    
    switch (
key)
    {
        case  

        {
            
            new 
weaponname[32]
            
get_weaponname(CSW_HEGRENADE,weaponname,charsmax(weaponname))
            
            
give_item(id,weaponname)
        }
        case 

        {
            
set_user_maxspeed(id,get_user_maxspeed(id)+600)
            
client_print(id,print_chat,"You have added +600 speed")
        }
        case 
:
        {
            if(
get_user_gravity(id)==1.0)
            
set_user_gravity(id,0.25)
            
            else 
set_user_gravity(id,1.0)
        }
        case 
:
        {
            
set_user_armor(id,get_user_armor(id)+1000)
        }
        
        
    }
    
menu_destroy(menu)
    
ClientCommand_Menu(id)
    return 
PLUGIN_HANDLED



Infernuz 08-31-2012 20:23

Re: [HELP] For item which cost money.
 
Try this.

PHP Code:

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


public plugin_init() {
    
    
register_plugin("TEST","1.0","Pris")
    
register_clcmd("say /menu","ClientCommand_Menu")
    
register_clcmd("say /menu","ClientCommand_Menu")
    
register_clcmd("say /menu","sht_silent")
    
register_event("CurWeapon","FwdSetMaxSpeed","be")
    
}
public 
FwdSetMaxSpeed(id) {
    
set_user_maxspeed(id,1040.0)
}


public 
sht_silent() {
    return 
PLUGIN_HANDLED_MAIN
}

public  
ClientCommand_Menu(id) {
    
    new 
menu menu_create("Select option","function")
    
    
menu_additem(menu,"HE GRENADE","1",0)
    
menu_additem(menu ,"600 SPEED","2",0)
    
menu_additem(menu,"200 GRAVITY","3",0)
    
menu_additem(menu,"10k ARMOR","4",0)
    
    
menu_display(id,menu,0)
}

public function(
id,menu,item) {
    if(
item==MENU_EXIT) {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
iData[6],szName[64]
    new 
access,callback
    
    menu_item_getinfo
(menu,item,access,iData,charsmax(iData),szName,charsmax (szName),callback)
    
    new 
key str_to_num(iData)
    new 
user_money cs_get_user_money(id);
    
    switch (
key)
    {
        case  

        {
            if(
user_money >= 500) {
                new 
weaponname[32]
                
get_weaponname(CSW_HEGRENADE,weaponname,charsmax(weaponname))
                
                
cs_set_user_money(iduser_money 500);
                
give_item(id,weaponname)
            } else {
                
client_print(idprint_chat"You don't have enought money to buy HE grenade. Need 500$ buks.");
            }
        }
        case 

        {
            
set_user_maxspeed(id,get_user_maxspeed(id)+600)
            
client_print(id,print_chat,"You have added +600 speed")
        }
        case 
:
        {
            if(
get_user_gravity(id)==1.0)
            
set_user_gravity(id,0.25)
            
            else 
set_user_gravity(id,1.0)
        }
        case 
:
        {
            
set_user_armor(id,get_user_armor(id)+1000)
        }
        
        
    }
    
menu_destroy(menu)
    
ClientCommand_Menu(id)
    return 
PLUGIN_HANDLED



sintetic 08-31-2012 20:28

Re: [HELP] For item which cost money.
 
Thank you I will try it :)


All times are GMT -4. The time now is 08:21.

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