AlliedModders

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

mati009988 09-07-2015 13:37

get_pcvar_num
 
Hi,
I need to change pcvars values for person with defined flag.

I wrote something like this:

PHP Code:

    if(get_user_flags(id) & ADMIN_LEVEL_A && get_user_flags(id) & ADMIN_LEVEL_B)
        
koszt get_pcvar_num(hpap_koszt) * 0.7;
    else
        
koszt get_pcvar_num(hpap_koszt

but compiler return
Quote:

Warning: Tag mismatch on line xxx
How to define this?
PHP Code:

koszt get_pcvar_num(hpap_koszt) * 0.7


HamletEagle 09-07-2015 13:39

Re: get_pcvar_num
 
koszt is a float ?

fysiks 09-07-2015 13:40

Re: get_pcvar_num
 
get_pcvar_num() will give you an integer. You multiply it by a floating point value (float) which doesn't work. I'm also assuming that the variable koszt is an integer which also won't work.

mati009988 09-07-2015 14:28

Re: get_pcvar_num
 
Koszt is a integer an i need integer for money, so how to get a 70% of price?
Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

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


public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
   
    register_clcmd("say buy", "buy_item")
    gravity_koszt= register_cvar("item_cost","6000")
}

public buy_item(id){
    if(get_user_flags(id) & ADMIN_LEVEL_A && get_user_flags(id) & ADMIN_LEVEL_B)
        cost = get_pcvar_float(item_cost) * 0.7;
    else
        cost = get_pcvar_float(item_cost) 
       
    if(cs_get_user_money(id) <= cost)
    {
        client_print(id,print_chat,"%L",LANG_PLAYER,"NO_MONEY")
        return PLUGIN_HANDLED
    }
    client_print(id,print_chat,"%L",LANG_PLAYER,"BUY_ITEM")
    /* Give any item */
    cs_set_user_money(id,cs_get_user_money(id)-cost)
    return PLUGIN_HANDLED
}


fysiks 09-07-2015 16:26

Re: get_pcvar_num
 
You can do

PHP Code:

cost floatround(get_pcvar_float(cvar) * 0.7


mati009988 09-11-2015 16:25

Re: get_pcvar_num
 
Quote:

Originally Posted by fysiks (Post 2340794)
You can do

PHP Code:

cost floatround(get_pcvar_float(cvar) * 0.7


Work perfect, thank You :)


All times are GMT -4. The time now is 22:10.

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