Raised This Month: $ Target: $400
 0% 

need some logical help


Post New Thread Reply   
 
Thread Tools Display Modes
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-04-2011 , 20:56   Re: need some logical help
Reply With Quote #11

Quote:
Originally Posted by reinert View Post
Ok thanks, I will try it, And I'm almost sure that this line:

client_print(id, print_chat, "[ BANK ] You have withdrawn $%d.")

should be

client_print(id, print_chat, "[ BANK ] You have withdrawn $%d.", iAmount)


Probably. You can print what ever you want there.



Quote:
Originally Posted by reinert View Post
other value still doesn't work, and menu closes sometimes itself I don't want it :S,


Maybe I will have to test that part. It should reopen the menu after you submit your value. If you want it to stay open you should show the menu again in that option in the switch() statement and not in the Withdraw_Other_Value() function.



Quote:
Originally Posted by reinert View Post
And is it possible to make that if user has less than 16000 in bank, the 16000 option will be shown in grey. And I like my menu style more, because I think it's easier :S
Yes, you can redo the menu part and to do that. However, at the very least, I would suggest that you do something like:

PHP Code:
    formatex(szStringcharsmax(szString), "%s$1000"iMoney[id] >= 1000 "" "\d")
    
menu_additem(menuszString"1000")
    
// etc. 
Or, you need to use a callback (which would actually disable the button).

Quote:
Originally Posted by reinert View Post
I just want some logical help here:

If user has more than 15000 (15001, 15002 etc..), and he choose to withdraw 1000 money, the maximum amount of money is 16000, so how could I make, that he gets maximum, but the rest money goes back to his bank balance.

something like that, yeah ?

iMoney[id]-= 1000 - (16000 - cs_get_user_money(id))

I've got 15500 on me, 1000 - (16000 - 15500)) = 500. I think I'm right xD
That is why I put the comment:
PHP Code:
        // Optionally you could process a partial withdrawal to be at $16000 in-game (must return true instead of false). 
Also, I would seriously suggest not trying to do the whole process in one line. It can be confusing (obviously since you don't know if that works). Also, use the cached value iUserMoney instead of cs_get_user_money(id), using iUserMoney is an optimization that you really need to learn when using a value several times.

I helped you on the overall layout of the withdrawal system, it should be much easier to deal with like this. You can modify it from here since you are wanting to do this yourself.
__________________
fysiks is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 01-05-2011 , 07:17   Re: need some logical help
Reply With Quote #12

Ok I've done it... But I still want to know why this code (Other value) is not working...

PHP Code:
new szArg[4]
    
read_argv(1szArgcharsmax(szArg))
    new 
iArg str_to_num(szArg)
    if(
iMoney[id] >= iArg)
    {
        if(
cs_get_user_money(id) + iArg >= 16000)
        {
            
iMoney[id]-= 16000 cs_get_user_money(id);
            
client_printc(id"\g[ BANK ]\n You've just withdrawn %d$ money from your bank account"16000 cs_get_user_money(id))
            
cs_set_user_money(id16000)
        }
        else
        {
             
iMoney[id]-= iArg;
         
client_printc(id"\g[ BANK ]\n You've just withdrawn %d$ money from your bank account"iArg)
         
cs_set_user_money(idcs_get_user_money(id) + iArg )
        }
    }
    else
    {
    
client_printc(id"\g[ BANK ]\n You can't withdraw that much, you have only %d$"iMoney[id])
    }
    
Save_MySql(id);

PS: The other code, that was written by fysiks doesn't work also


Could someone fix it ? and maybe could someone give me an example with string which has spaces between words for example Hi, its reinert from AlliedModds

Last edited by reinert; 01-05-2011 at 07:36.
reinert is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-05-2011 , 19:50   Re: need some logical help
Reply With Quote #13

This is why I asked you for the full code.

PHP Code:
    register_clcmd("Withdraw_Other_Value""Withdraw_Other_Value"
__________________
fysiks is offline
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 01:57.


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