Raised This Month: $ Target: $400
 0% 

Money as Health


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Fedde
BANNED
Join Date: Sep 2011
Old 10-27-2011 , 08:54   Money as Health
Reply With Quote #1

How I can get the health and put where the money is...

I made this method...
Code:
new Money; public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         Money = get_user_msgid("Money");     register_message(Money,"cmdMoney"); } public cmdMoney(MsgId,MsgDest,id) {     new plyrMoney = get_user_health(id)         set_msg_arg_int(1,ARG_LONG,plyrMoney);     set_pdata_int(id,155,0); }

But when I hurt or get more health the money is not updated.

Thanks.
Fedde is offline
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 10-27-2011 , 08:58   Re: Money as Health
Reply With Quote #2

Money is not updated when you lose or gain health. You'll have to hook Ham_TakeDamage and update there (cs_set_user_money could be used to set health and update the message as well).
__________________
Achievements API - a simple way for you to create your OWN custom achievements!
Xellath is offline
Fedde
BANNED
Join Date: Sep 2011
Old 10-27-2011 , 09:10   Re: Money as Health
Reply With Quote #3

Quote:
Originally Posted by Xellath View Post
Money is not updated when you lose or gain health. You'll have to hook Ham_TakeDamage and update there (cs_set_user_money could be used to set health and update the message as well).
Code:
new Money; public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         Money = get_user_msgid("Money");     register_message(Money,"cmdMoney");         RegisterHam(Ham_TakeDamage,"player","HamTakeDamage",1); } public cmdMoney(MsgId,MsgDest,id) {     new plyrMoney = get_user_health(id)         set_msg_arg_int(1,ARG_LONG,plyrMoney);     set_pdata_int(id,155,0); } public HamTakeDamage(victim,attacker,Float:fldamage)     cs_set_user_money(victim,get_user_health(victim));

Code:
L 10/27/2011 - 10:09:14: Invalid message argument 1
L 10/27/2011 - 10:09:14: [AMXX] Displaying debug trace (plugin "Untitled.amxx")
L 10/27/2011 - 10:09:14: [AMXX] Run time error 10: native error (native "set_msg_arg_int")
L 10/27/2011 - 10:09:14: [AMXX]    [0] Untitled.sma::cmdMoney (line 31)

Last edited by Fedde; 10-27-2011 at 09:10.
Fedde is offline
amxinclude
Member
Join Date: Oct 2011
Old 10-27-2011 , 09:16   Re: Money as Health
Reply With Quote #4

Tested.
PHP Code:
#include <amxmodx> 
#include <amxmisc> 
#include <fun> 
#include <cstrike> 
#include <hamsandwich> 

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

public plugin_init() 

    
register_plugin(PLUGINVERSIONAUTHOR)   
    
    
// Ham TakeDamage 
    
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage"

public 
fw_TakeDamage(victiminflictorattackerFloat:damage

    if(
get_user_health(victim) >= 0)
    {
    new 
money cs_get_user_money(victim
        new 
damaget SetHamParamFloat(4damage  )  
    
cs_set_user_money(victim,money -= damaget
   
     
        }  
    } 
amxinclude is offline
Fedde
BANNED
Join Date: Sep 2011
Old 10-27-2011 , 09:20   Re: Money as Health
Reply With Quote #5

Quote:
Originally Posted by amxinclude View Post
Tested.
PHP Code:
#include <amxmodx> 
#include <amxmisc> 
#include <fun> 
#include <cstrike> 
#include <hamsandwich> 

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

public plugin_init() 

    
register_plugin(PLUGINVERSIONAUTHOR)   
    
    
// Ham TakeDamage 
    
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage"

public 
fw_TakeDamage(victiminflictorattackerFloat:damage

    if(
get_user_health(victim) >= 0)
    {
    new 
money cs_get_user_money(victim
        new 
damaget SetHamParamFloat(4damage  )  
    
cs_set_user_money(victim,money -= damaget
   
     
        }  
    } 
Not working for me u.u
Fedde is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 10-27-2011 , 09:41   Re: Money as Health
Reply With Quote #6

PHP Code:
cs_set_user_money(victim,money -= damaget
->
PHP Code:
cs_set_user_money(victimmoney damaget
You should also check if the money is higher than the damage actually done
Backstabnoob is offline
Fedde
BANNED
Join Date: Sep 2011
Old 10-27-2011 , 09:46   Re: Money as Health
Reply With Quote #7

Quote:
Originally Posted by Backstabnoob View Post
PHP Code:
cs_set_user_money(victim,money -= damaget
->
PHP Code:
cs_set_user_money(victimmoney damaget
You should also check if the money is higher than the damage actually done
Still not working...
Fedde is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 10-27-2011 , 09:50   Re: Money as Health
Reply With Quote #8

Code:
public plugin_init()       RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage", 1)   public fw_TakeDamage(victim, inflictor, attacker, Float:damage) {      if(is_user_alive(victim))           cs_set_user_money(victim, cs_get_user_money(victim) - floatround(damage))      else           cs_set_user_money(victim, 0) }

Assuming you're setting clients' money to their HP on spawn or whereever.

Last edited by Backstabnoob; 10-27-2011 at 09:53.
Backstabnoob is offline
Fedde
BANNED
Join Date: Sep 2011
Old 10-27-2011 , 09:57   Re: Money as Health
Reply With Quote #9

Check by yourself,isn't working...Howerever the money is not the trouble,the update is it...
Code:
#include <amxmodx>   #include <amxmisc>   #include <fun>   #include <fakemeta> #include <cstrike>   #include <hamsandwich>   #define PLUGIN "New Plug-In" #define VERSION "1.0" #define AUTHOR "author" new Money; public plugin_init()   {       register_plugin(PLUGIN, VERSION, AUTHOR)               Money = get_user_msgid("Money");     register_message(Money,"cmdMoney");         RegisterHam(Ham_TakeDamage,"player","HamTakeDamage",1); } public cmdMoney(MsgId,MsgDest,id) {     new plyrMoney = get_user_health(id)         set_msg_arg_int(1,ARG_LONG,plyrMoney);     set_pdata_int(id,155,0); } public HamTakeDamage(victim, inflictor, attacker, Float:damage) {      if(is_user_alive(victim))           cs_set_user_money(victim, cs_get_user_money(victim) - floatround(damage))      else           cs_set_user_money(victim, 0);     }
Fedde is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-27-2011 , 10:06   Re: Money as Health
Reply With Quote #10

What do you want displayed in the regular health HUD? Does the money HUD get reduced by purchases and increased for kills etc like normal money?
__________________
Bugsy 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 14:28.


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