Raised This Month: $ Target: $400
 0% 

[SOLVED]


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 06-05-2009 , 15:24   Re: help with setting users health
Reply With Quote #6

In my opinion your code looks horrible and you made many mistakes and I'm not talking about indentation or about if it works fine or not, but the whole idea.

Why do you divide players into ts and cts? You could get the same effect by displaying only 2 items in menu (increase health when in ct, increase health when in t). You should store costs and health bonuses in some global arrays so you can use them to check everything in 2 lines of code instead of making very long switch with 10 cases. In other words: your menu handler could be like 10 times shorter and much easier to read.

When you are coding xp/points mod you should do it step by step and make sure it all works fine after each step. Before you code saving and loading from database, you should check if health adding works by doing this:
PHP Code:
client_authorized(id){
    
gPlayerPoints[id] = 100000
    
//disable loading from database

Then you go in game and make tests. After that you can play around with saving and loading points.

Recently I started to code RPG mod and this is how my handler for buy upgrades menu with multiple pages looks like:
PHP Code:
public hnd_menu_buy_upg(id,key){
    static 
upg

    
if(key<8){
        
upg g_enabled_list[g_p_menu_page[id]*8+key]
        
g_p_credits[id] -= g_upg_sp[upg] + g_upg_ip[upg]*g_p_upg[id][upg]
        
g_p_upg[id][upg]++
        
upgrade_change(idupgUPGC_AP)
        
menu_buy_upg(idg_p_menu_page[id])
    }else if(
key==8){
        
menu_buy_upg(idg_p_menu_page[id]+1)
    }else{
        
menu_main(id)
    }

    return 
PLUGIN_HANDLED

well, I check if you can buy it in function that creates menu, but still it's just few lines in for loop...
__________________
Impossible is Nothing
Sylwester is offline
 



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 23:34.


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