Raised This Month: $ Target: $400
 0% 

[SOLVED]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
zacky
Senior Member
Join Date: Mar 2008
Location: Sweden
Old 06-05-2009 , 10:03   [SOLVED]
Reply With Quote #1

[SOLVED] Thanks to xPaw

Last edited by zacky; 06-05-2009 at 16:21.
zacky is offline
Send a message via Skype™ to zacky
[X]-RayCat
Senior Member
Join Date: Sep 2006
Old 06-05-2009 , 10:34   Re: help with setting users health
Reply With Quote #2

Quote:
Originally Posted by zacky View Post
Hi, i've been making my own point plugin.
But i have 1 problem, you can buy extra hp as ct/t, but, when it is new round you dont get the health you bought :/.

Heres some code for you to see whats wrong :/
PHP Code:
public cmdNewRound() {
    for (new 
1<= gMaxPlayersi++) {
        if (
is_user_alive(i)) {
            new 
iHealth get_user_health(i);
            
            switch (
cs_get_user_team(i)) {
                case 
CS_TEAM_CTset_user_health(iiHealth gPlayerCtHealth[i]);
                case 
CS_TEAM_Tset_user_health(iiHealth gPlayerTHealth[i]);
            }
        }
    }

First don't declare new varibles inside loop. And post some more code.
__________________
[X]-RayCat is offline
zacky
Senior Member
Join Date: Mar 2008
Location: Sweden
Old 06-05-2009 , 10:34   Re: help with setting users health
Reply With Quote #3

Theres no need to post more code, all other codes works fine, and its pretty much code
zacky is offline
Send a message via Skype™ to zacky
[X]-RayCat
Senior Member
Join Date: Sep 2006
Old 06-05-2009 , 10:43   Re: help with setting users health
Reply With Quote #4

Quote:
Originally Posted by zacky View Post
Theres no need to post more code, all other codes works fine, and its pretty much code
There is probably something wrong with your event registering.
__________________
[X]-RayCat is offline
zacky
Senior Member
Join Date: Mar 2008
Location: Sweden
Old 06-05-2009 , 12:20   Re: help with setting users health
Reply With Quote #5

[SOLVED]

Last edited by zacky; 06-05-2009 at 16:21.
zacky is offline
Send a message via Skype™ to zacky
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
zacky
Senior Member
Join Date: Mar 2008
Location: Sweden
Old 06-05-2009 , 16:10   Re: help with setting users health
Reply With Quote #7

@Sylwester: Am i done with this plugin yet? No.
First i make it, then i make it better.

EDIT: I make all first to see if it works, then i make it better...
zacky is offline
Send a message via Skype™ to zacky
Old 06-05-2009, 16:20
[X]-RayCat
This message has been deleted by [X]-RayCat. Reason: nvm...
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 06-05-2009 , 16:23   Re: [SOLVED]
Reply With Quote #8

The problem was what he was registering pre spawn forward, and in that moment player wasnt alive, so putting it as post forward solved problem.
__________________
xPaw is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-05-2009 , 16:24   Re: [SOLVED]
Reply With Quote #9

zacky, why did you remove your problem in the first post, it's really stupid. Back your changes, please.
__________________
Arkshine is offline
zacky
Senior Member
Join Date: Mar 2008
Location: Sweden
Old 06-05-2009 , 16:25   Re: [SOLVED]
Reply With Quote #10

Quote:
Originally Posted by arkshine View Post
zacky, why did you remove your problem in the first post, it's really stupid. Back your changes, please.
Because its solved now...
zacky is offline
Send a message via Skype™ to zacky
Reply



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 12:19.


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