Raised This Month: $ Target: $400
 0% 

Health help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
prole
Member
Join Date: Jun 2010
Location: Sweden, Eskilstuna
Old 05-06-2011 , 14:37   Health help
Reply With Quote #1

Hello!
Code:
  case 6:
  {
   new money = cs_get_user_money(id)
   
   if (money >= 1000)
   {
    set_user_health( id, get_user_health(id) + 25 )
    cs_set_user_money(id, money - 1000)
    
    client_print_color(id, print_chat, "^4[L15]^3You just bought Extra HP")
   }
   
   else
   {
    client_print_color(id, print_chat, "^4[L15]^3You did not afford Extra HP")
    return PLUGIN_HANDLED;
   }
When I buy first Extra HP I get 125 hp. And when I buy it again I get 150 hp but I want the money to dublicate from 1000 - 2000 next time and so on. How can I make this?
__________________
prole is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-06-2011 , 14:49   Re: Health help
Reply With Quote #2

You have to store in some variable how many time (per map, or per round, as you want/need) the same player has bought this item.
Or you may want to set the price according to player health. The more the player has health when he try to by some HP, the more the item is expensive.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
prole
Member
Join Date: Jun 2010
Location: Sweden, Eskilstuna
Old 05-06-2011 , 14:52   Re: Health help
Reply With Quote #3

How to do that? Im a beginner on this!
__________________
prole is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 05-06-2011 , 18:33   Re: Health help
Reply With Quote #4

Make a global array of 33 cells, add to it, multiply price by it and then reset it when you want (on new round for example).

Example:
Code:
new g_iBoughtHP[33]

public plugin_init()
{
    register_event("HLTV", "event_newRound", "a", "1=0", "2=0")
}

function event_newRound()
{
    for(new i = 1; i <= sizeof g_iBoughtHP; i++)
        g_iBoughtHP[i] = 0 /* reset it for all players on new round */
}
Then:
Code:
  case 6:
  {
   new money = cs_get_user_money(id)
   new cost = g_iBoughtHP[id] * 1000

   if (money >= cost)
   {
    set_user_health(id, get_user_health(id) + 25)
    cs_set_user_money(id, money - cost)

    g_iBoughtHP[id]++

    client_print_color(id, print_chat, "^4[L15]^3You just bought Extra HP")
   }
   else
   {
    client_print_color(id, print_chat, "^4[L15]^3You did not afford Extra HP")
    return PLUGIN_HANDLED;
   }
__________________
Hunter-Digital is offline
prole
Member
Join Date: Jun 2010
Location: Sweden, Eskilstuna
Old 05-06-2011 , 20:17   Re: Health help
Reply With Quote #5

Thank you!
But in the menu can I do so the price displays?

Code:
menu_additem(menu, "Buy Health", "6", 0);
__________________
prole is offline
prole
Member
Join Date: Jun 2010
Location: Sweden, Eskilstuna
Old 05-06-2011 , 20:22   Re: Health help
Reply With Quote #6

I also regognized that the first one to 125 hp is free and then it costs 1000 money and so on.
__________________
prole is offline
kotinha
Senior Member
Join Date: Jun 2009
Location: Alentejo, Portugal :)
Old 05-06-2011 , 20:35   Re: Health help
Reply With Quote #7

PHP Code:
new cost g_iBoughtHP[id] * 1000 

PHP Code:
new cost = (g_iBoughtHP[id]+1) * 1000 
__________________
"If God exists, I hope he has a good excuse." - Woody Allen
kotinha is offline
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 05-06-2011 , 22:26   Re: Health help
Reply With Quote #8

Quote:
Originally Posted by prole View Post
Thank you!
But in the menu can I do so the price displays?

Code:
menu_additem(menu, "Buy Health", "6", 0);
you can format the textmenu.

PHP Code:
new menuText[512]

new 
len formatex(menuText,511,"\rMy menu,id)
len += formatex(menuText[len],511-len,"
\wfirst time hp is free",id )
& ...
show_menu(id,1023,menuText,-1,"
Menu_CMD") 
__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 05-07-2011 , 11:05   Re: Health help
Reply With Quote #9

prole
PHP Code:
static strtemp[256]
format(strtempcharsmax(strtemp), "Buy Health: \R\y%d $"g_iBoughtHP[id] * 1000)
menu_additem(menustrtemp"6"); 
__________________

SonicSonedit 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 04:21.


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