AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP]Need Help. (https://forums.alliedmods.net/showthread.php?t=295624)

yas17sin 03-31-2017 09:38

[HELP]Need Help.
 
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*/ 


edon1337 03-31-2017 09:56

Re: [HELP]Need Help.
 
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) }

yas17sin 03-31-2017 10:30

Re: [HELP]Need Help.
 
Thanks for you help.

realy i can't see what's wrong :/.

OciXCrom 03-31-2017 10:40

Re: [HELP]Need Help.
 
PHP Code:

damage >= 

?

CrazY. 03-31-2017 10:57

Re: [HELP]Need Help.
 
What is that? I think u need change to that:

Code:
damage *= 2

yas17sin 03-31-2017 11:57

Re: [HELP]Need Help.
 
Quote:

Originally Posted by OciXCrom (Post 2508213)
PHP Code:

damage >= 

?

Quote:

Originally Posted by CrazY. (Post 2508220)
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.

OciXCrom 03-31-2017 14:11

Re: [HELP]Need Help.
 
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.

yas17sin 03-31-2017 15:38

Re: [HELP]Need Help.
 
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.

OciXCrom 03-31-2017 17:16

Re: [HELP]Need Help.
 
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.

EFFx 03-31-2017 17:28

Re: [HELP]Need Help.
 
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))




All times are GMT -4. The time now is 18:03.

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