AlliedModders

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

prole 05-06-2011 14:37

Health help
 
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?

ConnorMcLeod 05-06-2011 14:49

Re: Health help
 
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.

prole 05-06-2011 14:52

Re: Health help
 
How to do that? :) Im a beginner on this!

Hunter-Digital 05-06-2011 18:33

Re: Health help
 
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;
  }


prole 05-06-2011 20:17

Re: Health help
 
Thank you!
But in the menu can I do so the price displays?

Code:

menu_additem(menu, "Buy Health", "6", 0);

prole 05-06-2011 20:22

Re: Health help
 
I also regognized that the first one to 125 hp is free and then it costs 1000 money and so on.

kotinha 05-06-2011 20:35

Re: Health help
 
PHP Code:

new cost g_iBoughtHP[id] * 1000 

:arrow:
PHP Code:

new cost = (g_iBoughtHP[id]+1) * 1000 


One 05-06-2011 22:26

Re: Health help
 
Quote:

Originally Posted by prole (Post 1464712)
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") 


SonicSonedit 05-07-2011 11:05

Re: Health help
 
prole
PHP Code:

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



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

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