Raised This Month: $ Target: $400
 0% 

[HELP]Need Help.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
yas17sin
Veteran Member
Join Date: Oct 2016
Location: Morocco/Sale
Old 03-31-2017 , 09:38   [HELP]Need Help.
Reply With Quote #1

Hi all.

I have created this code for my mod, but i have some problems like ( if i hit tamemates even if the firendlyfire is turned off i can get money and, the hud of the money doesn't work problley it show me 300000 the admin limit that i set, and it does stay stuck at there, so please can anyone tell me what i am doing wrong ?

CODE :
PHP Code:
#include <amxmodx>
#include <cstrike>
#include <hamsandwich>
#include <colorchat>

#define    PLUGIN    "Money System"
#define    VERSION    "1.0"
#define    AUTHOR    "yas17sin"

#define ADMIN_ACCESS ADMIN_LEVEL_H

#define LIMIT 150000
#define LIMIT_ADMIN_VIP 300000

new players_menuplayers[32], numi
new accessmenuiName[64], callback

//new pcvar_dmg_money

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /give""transfer_menu"ADMIN_ALL"")    // transfer money
    
register_clcmd("say /donate""transfer_menu"ADMIN_ALL"")
    
register_clcmd("say_team /donate""transfer_menu"ADMIN_ALL"")
    
register_clcmd("say_team /give""transfer_menu"ADMIN_ALL"")
    
    
register_clcmd("transfer""transfer_money"ADMIN_ALL"")
    
    
RegisterHam(Ham_TakeDamage"player""fwTakeDamage"1)
    
    
//pcvar_dmg_money = register_cvar("damage_money", "2")
}

public 
transfer_menu(id)
{
    
get_players(playersnum"h")
    
    if (
num <= 1)
    {
        
ColorChat(idGREEN"x04There is no one to transfer money")
        return 
PLUGIN_HANDLED
    
}
    
    new 
tempname[32], info[10]
    
    
players_menu menu_create("Player""players_menu_handler")
    
    for(
0numi++)
    {
        if(
players[i] == id)
            continue
        
        
get_user_name(players[i], tempname31)
        
num_to_str(players[i], info9)
        
menu_additem(players_menutempnameinfo0)
    }
    
    
menu_setprop(players_menuMPROP_EXITMEXIT_ALL)
    
    
menu_display(idplayers_menu0)
    return 
PLUGIN_CONTINUE
}

public 
players_menu_handler(idplayers_menuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(players_menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
data[6]
    
    
menu_item_getinfo(players_menuitemaccessmenudatacharsmax(data), iNamecharsmax(iName), callback)
    
    new 
player str_to_num(data)
    
    
client_cmd(id"messagemode ^"transfer %i^""player)
    
    return 
PLUGIN_CONTINUE
}

public 
transfer_money(id)
{
    new 
param[5]
    
read_argv(2paramcharsmax(param))
    
    for (new 
xstrlen(param); x++)
    {
        if(!
isdigit(param[x]))
        {
            
ColorChat(idGREEN"x04The parameter must be a number")
            return 
PLUGIN_HANDLED
        
}
    }
    
    new 
amount str_to_num(param)
    
    new 
money cs_get_user_money(id)
    
    if (
money amount)
    {
        
ColorChat(idGREEN"x04You do not have enough money!")
        return 
PLUGIN_HANDLED
    
}
    
    
read_argv(1paramcharsmax(param))
    new 
player str_to_num(param)
    
    new 
player_money cs_get_user_money(player)
    
    
cs_set_user_money(idmoney amount1)
    
cs_set_user_money(playerplayer_money amount1)
    
    new 
names[2][32]
    
    
get_user_name(idnames[0], 31)
    
get_user_name(playernames[1], 31)
    
    
ColorChat(idGREEN"x04Player x01%s x04give x01$%i x04%s"names[0], amountnames[1])
    
    return 
PLUGIN_HANDLED
}
public 
fwTakeDamage(iVictimweaponiAttackerFloat:damage)
{
    if(!
is_user_alive(iAttacker))
        return     
    
    if( 
get_user_team(iAttacker) == get_user_team(iVictim))
        return
    
    if(
damage 2.0)
        
cs_set_user_money(iAttackerclamp(cs_get_user_money(iAttacker) + floatround(damage), .max = (get_user_flags(iAttacker) & ADMIN_ACCESS) ? LIMIT_ADMIN_VIP LIMIT))

/*public set_money(id, value)
{
    new money = cs_get_user_money(id)+value

    money = clamp(money, .max =(get_user_flags(id) & ADMIN_ACCESS) ? LIMIT_ADMIN_VIP:LIMIT)

    cs_set_user_money(id, money)
}
stock amx_clamp(value, maximum)

    return value>maximum?maximum:value*/ 
__________________
FINISHED WORKING ON : Attack On Titan Mod (100% Done).

FB Acc : FaceBook Account.

pic: http://prntscr.com/fszkke not good quality

Last edited by yas17sin; 03-31-2017 at 17:41.
yas17sin is offline
Send a message via ICQ to yas17sin
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 03-31-2017 , 09:56   Re: [HELP]Need Help.
Reply With Quote #2

Code:
public fwTakeDamage(id, weapon, attacker, Float:damage) {     if(!is_user_alive(attacker))     return             if( get_user_team( attacker ) == get_user_team( id ) )     return ;         damage >= 2         set_money(attacker, floatround(damage)) }

About the second problem there's probably something wrong in your calculation here
Code:
public set_money(id, value) {     new money = cs_get_user_money(id)+value     money = amx_clamp(money, (get_user_flags(id) & ADMIN_ACCESS) ? LIMIT_ADMIN_VIP:LIMIT)     cs_set_user_money(id, money) }
__________________
edon1337 is offline
yas17sin
Veteran Member
Join Date: Oct 2016
Location: Morocco/Sale
Old 03-31-2017 , 10:30   Re: [HELP]Need Help.
Reply With Quote #3

Thanks for you help.

realy i can't see what's wrong :/.
__________________
FINISHED WORKING ON : Attack On Titan Mod (100% Done).

FB Acc : FaceBook Account.

pic: http://prntscr.com/fszkke not good quality

Last edited by yas17sin; 03-31-2017 at 10:31.
yas17sin is offline
Send a message via ICQ to yas17sin
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-31-2017 , 10:40   Re: [HELP]Need Help.
Reply With Quote #4

PHP Code:
damage >= 
?
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 03-31-2017 , 10:57   Re: [HELP]Need Help.
Reply With Quote #5

What is that? I think u need change to that:

Code:
damage *= 2
__________________








CrazY. is offline
yas17sin
Veteran Member
Join Date: Oct 2016
Location: Morocco/Sale
Old 03-31-2017 , 11:57   Re: [HELP]Need Help.
Reply With Quote #6

Quote:
Originally Posted by OciXCrom View Post
PHP Code:
damage >= 
?
Quote:
Originally Posted by CrazY. View Post
What is that? I think u need change to that:

Code:
damage *= 2
Thanks but i tought the damage >= 2 is correct to check if an attacker have done 2 dmg to somone so he get money with every single 2 dmg.
__________________
FINISHED WORKING ON : Attack On Titan Mod (100% Done).

FB Acc : FaceBook Account.

pic: http://prntscr.com/fszkke not good quality

Last edited by yas17sin; 03-31-2017 at 12:00.
yas17sin is offline
Send a message via ICQ to yas17sin
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-31-2017 , 14:11   Re: [HELP]Need Help.
Reply With Quote #7

It will be correct if you add an actual if check for the damage and change it if it's true. That line you wrote does nothing.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
yas17sin
Veteran Member
Join Date: Oct 2016
Location: Morocco/Sale
Old 03-31-2017 , 15:38   Re: [HELP]Need Help.
Reply With Quote #8

it's work so good far now, the problems remain is the limit is not working and also the money hud doesn't show money probaley.
__________________
FINISHED WORKING ON : Attack On Titan Mod (100% Done).

FB Acc : FaceBook Account.

pic: http://prntscr.com/fszkke not good quality
yas17sin is offline
Send a message via ICQ to yas17sin
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-31-2017 , 17:16   Re: [HELP]Need Help.
Reply With Quote #9

I don't see a HUD in this code. Also, what's the point of amx_clamp? You can do clamp(money, .max = max value). Post the new code.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 03-31-2017 , 17:28   Re: [HELP]Need Help.
Reply With Quote #10

Try

PHP Code:
public fwTakeDamage(iVictimweaponiAttackerFloat:damage)
{
    if(!
is_user_alive(iAttacker))
        return     
    
    if( 
get_user_team(iAttacker) == get_user_team(iVictim))
        return
    
    if(
damage 2.0)
        
cs_set_user_money(iAttackerclamp(cs_get_user_money(iAttacker) + floatround(damage), .max = (get_user_flags(iAttacker) & ADMIN_ACCESS) ? LIMIT_ADMIN_VIP LIMIT))

__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 03-31-2017 at 17:31.
EFFx 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 18:03.


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