AlliedModders

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

Nur56 08-11-2008 05:47

Help me!
 
So I have 3 cases, and I'm making a money check, see if he has the money to buy something, but I'm having an epic problem!(yes I did include cstrike)

PHP Code:

            new money cs_get_user_money(id) - 16000
            str_to_num
(money)
            if(
money 16000){
                
client_print(id,print_chat,"You Don't have enough money to buy godmode")
                
menu_destroy(menu)
                return 
PLUGIN_HANDLED
            


Compile errors:

Code:

Welcome to the AMX Mod X 1.76-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

Error: Must be a constant expression; assumed zero on line 65
Warning: Loose indentation on line 67
Error: Array must be indexed (variable "money") on line 67
Warning: Loose indentation on line 73
Error: Argument type mismatch (argument 2) on line 81
Error: Must be a constant expression; assumed zero on line 90
Error: Array must be indexed (variable "money") on line 92
Warning: Tag mismatch on line 101
Error: Argument type mismatch (argument 2) on line 103
Error: Must be a constant expression; assumed zero on line 109
Error: Array must be indexed (variable "money") on line 112

8 Errors.
Could not locate output file E:\Steam\steamapps\chrissnafu\counter-strike\cstrike\addons\amxmodx\plugins\WMenu.amx (compile failed).

Halp me doctor Phill! +karma!

Arkshine 08-11-2008 05:49

Re: Help me!
 
Since you don't provide the full code I would say just that.

'money' should be a string and the return value the num. money = str_to_num(mystring);

ConnorMcLeod 08-11-2008 05:53

Re: Help me!
 
Or just remove :

str_to_num(money)

Arkshine 08-11-2008 05:55

Re: Help me!
 
Quote:

new money = cs_get_user_money(id) - 16000
This line was not provided when I answered. -_-'

So, obviously, like connor said, str_to_num() is not need.

Nur56 08-11-2008 06:38

Re: Help me!
 
Thanks for the help guys!+karma for ark & connorr

edit: it compiled fine but for some reason menu isnt showing up

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
#define PLUGIN "Woot Menu"
#define VERSION "1.0"
#define AUTHOR "T-Bag"



public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /wmenu","cmd_wmenu")
}



public 
cmd_wmenu(id) {
    new 
menu menu_create("\rWoot Menu:","menu_handler")
    
    
menu_additem(menu,"\wHigh Jump $2000","1",0)
    
menu_additem(menu,"\wFlash Boots   $5000","2",0)
    
menu_additem(menu,"\wHealth Surgery  $10000","1",0)
    
menu_additem(menu,"\wGODMODE!!!1   $16000","1",0)
    
    
menu_setprop(menu,MPROP_EXIT,MEXIT_ALL)
    
    
menu_display(id,menu,0)
}

public 
menu_handler(id,menu,item) {
    if(
item==MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
data[6],iName[64]
    
    new 
access,callback
    
    menu_item_getinfo
(menu,item,access,data,5,iName,63,callback)
    
    new 
key str_to_num(data)
    
    switch(
key)
    {
        case 
1:{
            new 
money cs_get_user_money(id) - 2000
                
if(money 2000) {
                
client_print(id,print_chat,"You Don't have enough money to buy godmode")
                
menu_destroy(menu)
                return 
PLUGIN_HANDLED
            
}
            
            if(!
is_user_alive(id))
            
client_print(id,print_chat,"You can't buy, your dead!!!")
            
menu_destroy(menu);
            
            
            
            
client_print(id,print_chat,"You Now have High Jump, YO!")
            
set_user_gravity(1,0.5)
            
cs_set_user_money(id,money)
            
menu_destroy(menu)
            return 
PLUGIN_HANDLED
            

        
}
        
        case 
2:{
            
            new 
money cs_get_user_money(id) - 5000
            
if(money 5000) {
                
client_print(id,print_chat,"You Don't have enough money to buy godmode")
                
menu_destroy(menu)
                return 
PLUGIN_HANDLED
            
}
            if(!
is_user_alive(id))
            
client_print(id,print_chat,"You can't buy, your dead!!!");
            
            
client_print(id,print_chat,"You Now have Flash Boots, YO!")
            
set_user_maxspeed(id,-5)
            
menu_destroy(menu)
            
cs_set_user_money(id,money)
            

        }
        
        case 
3:{
            new 
money cs_get_user_money(id) - 16000
            
            
if(money 16000){
                
client_print(id,print_chat,"You Don't have enough money to buy godmode")
                
menu_destroy(menu)
                return 
PLUGIN_HANDLED
            
}
            
            
            if(!
is_user_alive(id))
            
client_print(id,print_chat,"You can't buy, your dead!!!");
            
            
            
client_print(id,print_chat,"You Now have GODMODE OMG")
            
set_user_godmode(id,1)
            
menu_destroy(menu)
        }
    }
    
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED



zwfgdlc 08-11-2008 08:52

Re: Help me!
 
Code:
public cmd_wmenu(id) {     new menu = menu_create("\rWoot Menu:","menu_handler")         menu_additem(menu,"\wHigh Jump $2000","1",0)     menu_additem(menu,"\wFlash Boots   $5000","2",0)     menu_additem(menu,"\wHealth Surgery  $10000","1",0)     menu_additem(menu,"\wGODMODE!!!1   $16000","1",0)         menu_setprop(menu,MPROP_EXIT,MEXIT_ALL)         menu_display(id,menu,0) }
change to
Code:
public cmd_wmenu(id) {     new menu = menu_create("\rWoot Menu:","menu_handler")         menu_additem(menu,"\wHigh Jump $2000","1",0)     menu_additem(menu,"\wFlash Boots   $5000","2",0)     menu_additem(menu,"\wHealth Surgery  $10000","3",0)     menu_additem(menu,"\wGODMODE!!!1   $16000","4",0)         menu_setprop(menu,MPROP_EXIT,MEXIT_ALL)         menu_display(id,menu,0) }

Nur56 08-11-2008 09:07

Re: Help me!
 
IT WORKED! even after changing the code to what zwfgdlc said, it still didn't show up, I saw an event register and was like wtf is that doign there.

so i removed it and it worked! thanks for all the help guys!

YamiKaitou 08-11-2008 21:54

Re: Help me!
 
As per the Global Forum Rules, you need to have a descriptive topic. If you wish for this topic to stay open, please correct the topic title before you post again.

Nur56 08-12-2008 02:41

Re: Help me!
 
I do not need help anymore, you may close this topic, next time I will put a descriptive title, thanks.


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

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