Raised This Month: $ Target: $400
 0% 

get_pcvar_num


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mati009988
Member
Join Date: Jul 2009
Old 09-07-2015 , 13:37   get_pcvar_num
Reply With Quote #1

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
mati009988 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-07-2015 , 13:39   Re: get_pcvar_num
Reply With Quote #2

koszt is a float ?
__________________
HamletEagle is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-07-2015 , 13:40   Re: get_pcvar_num
Reply With Quote #3

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.
__________________
fysiks is offline
mati009988
Member
Join Date: Jul 2009
Old 09-07-2015 , 14:28   Re: get_pcvar_num
Reply With Quote #4

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 
}

Last edited by mati009988; 09-07-2015 at 14:28.
mati009988 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-07-2015 , 16:26   Re: get_pcvar_num
Reply With Quote #5

You can do

PHP Code:
cost floatround(get_pcvar_float(cvar) * 0.7
__________________
fysiks is offline
mati009988
Member
Join Date: Jul 2009
Old 09-11-2015 , 16:25   Re: get_pcvar_num
Reply With Quote #6

Quote:
Originally Posted by fysiks View Post
You can do

PHP Code:
cost floatround(get_pcvar_float(cvar) * 0.7
Work perfect, thank You
mati009988 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 22:10.


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