AlliedModders

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

EpicFail. 08-23-2010 17:26

Little Help
 
Hm.. How can i do in shop
if player dont have money for buy the item
this write in chat
"You Need More "XXX$" To Buy This." ??

some can give me the code i try do
PHP Code:

ChatColorid"%s You Need More !g%d$ !yTo Buy This."CLAN_TAG,  cs_get_user_moneyid ) ); 

but this show me in "%d" the money i have ... and no the how much more money i need to buy the item

Sorry for bad English ..

Thanks for Helpers ..

SpeeDeeR 08-23-2010 19:47

Re: Little Help
 
Well yea.. cs_get_user_money gets the current amount of money and the you want the amount of money that you need.So the amount that you dont have and you need is :
the money for the item minus the money that you have.

EpicFail. 08-23-2010 19:50

Re: Little Help
 
can you make one code for me

i want to see how do this ... :D

fysiks 08-23-2010 20:01

Re: Little Help
 
Quote:

Originally Posted by EpicFail. (Post 1280162)
can you make one code for me

i want to see how do this ... :D

It's a simple subtraction problem. 5 - 2 = 3

SpeeDeeR 08-24-2010 05:53

Re: Little Help
 
Since its in Scripting Help I dont have to show you code and you know how to script.

fireattack 08-24-2010 09:16

Re: Little Help
 
omg, people, don't be hard..

here you go.

PHP Code:

 
 
if (cs_get_user_money(id) < 10000

I think "Epic Fail" you will understand this, if not, you have a problem with scripting, however if you are a begginer i can do a example plugin for you.

PHP Code:

// LOOK AT THE "<" ">" "="
 
if (cs_get_user_money(id) < 10000){
 
client_print(idprint_center"Sorry but you're poor")
 return 
PLUGIN_HANDLED;
}
 if (
cs_get_user_money(id) >= 10000 ){
client_print(idprint_center"yeayeayea, you bought this")
 if(
is_user_connected(id))
 {
 
// Here you have to do something
 
 
}
 
cs_set_user_money(id cs_get_user_money(id) - 100000)
 } 


Bugsy 08-24-2010 09:25

Re: Little Help
 
Quote:

Originally Posted by fireattack (Post 1280516)
omg, people, don't be hard..

here you go.

I think "Epic Fail" you will understand this, if not, you have a problem with scripting, however if you are a begginer i can do a example plugin for you.
PHP Code:

 if (cs_get_user_money(id) < 10000){
 
client_print(idprint_center"Sorry but you're poor")
 return 
PLUGIN_HANDLED;
}
 if (
cs_get_user_money(id) >= 10000 ){
client_print(idprint_center"yeayeayea, you bought this")
 if(
is_user_connected(id))
 {
 
// Here you have to do something
 
 



More efficient to use else rather then call another native. Also, it would be better to store the cs_get_user_money() value in a variable so it can be used again to set the users money at cs_set_user_money(id , cs_get_user_money(id) - 10000, 0).
PHP Code:

    if (cs_get_user_money(id) < 10000)
    {

    }
    else
    {

    { 


fireattack 08-24-2010 09:31

Re: Little Help
 
I know, but it's harder to understand for a begginer.

Bugsy 08-24-2010 09:49

Re: Little Help
 
Hardly, plus its better to teach using proper methods.

fysiks 08-24-2010 17:55

Re: Little Help
 
Quote:

Originally Posted by fireattack (Post 1280516)
omg, people, don't be hard..

here you go.

PHP Code:

 
 
if (cs_get_user_money(id) < 10000

I think "Epic Fail" you will understand this, if not, you have a problem with scripting, however if you are a begginer i can do a example plugin for you.

PHP Code:

// LOOK AT THE "<" ">" "="
 
if (cs_get_user_money(id) < 10000){
 
client_print(idprint_center"Sorry but you're poor")
 return 
PLUGIN_HANDLED;
}
 if (
cs_get_user_money(id) >= 10000 ){
client_print(idprint_center"yeayeayea, you bought this")
 if(
is_user_connected(id))
 {
 
// Here you have to do something
 
 
}
 
cs_set_user_money(id cs_get_user_money(id) - 100000)
 } 


Sadly, that doesn't answer his question.

All he needs is this: CostToBuy - UserMoney (This is how much more money is needed to buy the item, which is what he asked for).


All times are GMT -4. The time now is 21:54.

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