AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need help compiling this (https://forums.alliedmods.net/showthread.php?t=74836)

PvtSmithFSSF 07-25-2008 21:41

Need help compiling this
 
1 Attachment(s)
This won't compile :( I'm a new scripter and this is my first attempt at making MENUs. Can you help tell me what's wrong? Thanks! :up::up:

IneedHelp 07-25-2008 22:17

Re: Need help compiling this
 
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>

#define PLUGIN "Buy Gravity"
#define VERSION "2.0"
#define AUTHOR "PvtSmithFSSF"

new Pcvars[4]

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_clcmd"/grav","GravMenu");
    
register_clcmd".grav","GravMenu");
    
    
Pcvars[0] = register_cvar("200_price""8000");
    
Pcvars[1] = register_cvar("300_price""7000");
    
Pcvars[2] = register_cvar("400_price""5000");
    
Pcvars[3] = register_cvar("500_price""3000");
}

public 
GravMenu(id)
{
    new 
menu menu_create("\rGravMenu:""menu_handler");
    
menu_additem(menu"\w200 Gravity""1"0);
    
menu_additem(menu"\w300 Gravity""2"0);
    
menu_additem(menu"\w400 Gravity""3"0);
    
menu_additem(menu"\w500 Gravity""4"0);
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
menu_display(idmenu0)
}

public 
menu_handler(idmenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
data[6], iName[64]
    new 
accescallback
    menu_item_getinfo
(menuitemaccesdata,5iName63callback);
    
    new 
key str_to_num(data);
    
    switch(
key)
    {
        case 
1:
        {
            new 
Pcvar get_pcvar_num(Pcvars[0])
            new 
Money cs_get_user_money(id)
            
            if (
Money Pcvar)
            {
                
client_print(id,print_chat,"[Gravity] You don't have enough money!");
            } else {
                 
client_print(idprint_chat"You have successfully bought low gravity [200]");
                
cs_set_user_money(idMoney-Pcvar);
            }    
        }
    
        case 
2:
        {  
            new 
Pcvar get_pcvar_num(Pcvars[1])
            new 
Money cs_get_user_money(id)
            
            if (
Money Pcvar)
            {
                
client_print(id,print_chat,"[Gravity] You don't have enough money!");
            } else {
                 
client_print(idprint_chat"You have successfully bought low gravity [300]");
                
cs_set_user_money(idMoney-Pcvar);
            }
        }
    
        case 
3:
        { 
            new 
Pcvar get_pcvar_num(Pcvars[2])
            new 
Money cs_get_user_money(id)
            
            if (
Money Pcvar)
            {
                
client_print(id,print_chat,"[Gravity] You don't have enough money!");
            } else {
                 
client_print(idprint_chat"You have successfully bought low gravity [400]");
                
cs_set_user_money(idMoney-Pcvar);
            }
        }

        case 
4:
        { 
            new 
Pcvar get_pcvar_num(Pcvars[3])
            new 
Money cs_get_user_money(id)
            
            if (
Money Pcvar)
            {
                
client_print(id,print_chat,"[Gravity] You don't have enough money!");
            } 
            else 
            {
                 
client_print(idprint_chat"You have successfully bought low gravity [500]");
                
cs_set_user_money(idMoney-Pcvar);
            }
        }
    }
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED


Well, i remove this variables:

PHP Code:

    money cs_get_user_money(id);
    
g200price get_pcvar_num(200price);
    
g300price get_pcvar_num(300price);
    
g400price get_pcvar_num(400price);
    
g500price get_pcvar_num(500price); 

I create 1 variable which hold 4 slots for the pcvars

PHP Code:

    new Pcvars[4]; 

I create new variables on each switch statement for get user money and get pcvar num, to see if player have the money to buy the gravity.

PHP Code:

            new Pcvar get_pcvar_num(Pcvars[0])
            new 
Money cs_get_user_money(id)
            
            if (
Money Pcvar)
            {
                
client_print(id,print_chat,"[Gravity] You don't have enough money!");
            } else {
                 
client_print(idprint_chat"You have successfully bought low gravity [200]");
                
cs_set_user_money(idMoney-Pcvar);
            } 

I didn't agree the set_user_gravity() function because i don't know very well how it is.
I indent the code because you miss many "{ }".

The menu destroys when you select one case from the switch statement, so, isn't necessary the menu_destroy(menu) on each case...

PvtSmithFSSF 07-25-2008 22:21

Re: Need help compiling this
 
1 Attachment(s)
Thanks, I'll upload that and see if it works


edit: it compiles! :D

Too bad I don't have a server to test, if anybody does, I'd love for you to.

IneedHelp 07-25-2008 22:26

Re: Need help compiling this
 
Well, im going to download the amxx 1.8 to test it, if you wait some minutes :)

PvtSmithFSSF 07-25-2008 22:27

Re: Need help compiling this
 
I would greatly appreciate it :)
I am trying to get a little temporary job somewhere around the neighborhood, should have 100 or so bucks (already 15 on first day) in around a week.. To buy a little server to enjoy.

Wow that was off-topic :D Anyways, thanks again.

danielkza 07-25-2008 22:49

Re: Need help compiling this
 
You can always test in a listen server,or on the steam dedicated server,as i do. It's recommended to have a development setup at home, with the same software as the main server, configure everything there,then transfer your work to the external one to avoid down-times,player complaints,etc.

IneedHelp 07-25-2008 22:51

Re: Need help compiling this
 
I think this plugin is going to work good, i test it and works good for the money, i don't know very well the function of set_user_gravity(), so didn't add me the gravity :P.

I tested with amxx 1.76d because i have it before and amxx1.8 installer give me some error: 'Haven't found any files on the cstrike directory' bla bla...

PvtSmithFSSF 07-25-2008 23:06

Re: Need help compiling this
 
um. so the gravity doesn't change? it should last for the whole round after you buy it.

IneedHelp 07-25-2008 23:38

Re: Need help compiling this
 
I didn't add the function of set_user_gravity() to the plugin, because i don't know how to add it very well.

PvtSmithFSSF 07-25-2008 23:45

Re: Need help compiling this
 
I did though. Check my version. in the 3rd post of this topic.
Please tell me if it works :D


All times are GMT -4. The time now is 05:35.

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