AlliedModders

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

Fedde 10-27-2011 08:54

Money as Health
 
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.

Xellath 10-27-2011 08:58

Re: Money as Health
 
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).

Fedde 10-27-2011 09:10

Re: Money as Health
 
Quote:

Originally Posted by Xellath (Post 1584181)
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)


amxinclude 10-27-2011 09:16

Re: Money as Health
 
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
   
     
        }  
    } 


Fedde 10-27-2011 09:20

Re: Money as Health
 
Quote:

Originally Posted by amxinclude (Post 1584192)
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

Backstabnoob 10-27-2011 09:41

Re: Money as Health
 
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

Fedde 10-27-2011 09:46

Re: Money as Health
 
Quote:

Originally Posted by Backstabnoob (Post 1584205)
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...

Backstabnoob 10-27-2011 09:50

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

Fedde 10-27-2011 09:57

Re: Money as Health
 
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);     }

Bugsy 10-27-2011 10:06

Re: Money as Health
 
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?


All times are GMT -4. The time now is 14:28.

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