Raised This Month: $ Target: $400
 0% 

[HELP] Strange tag mismatch - float algorhytm


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-21-2014 , 16:11   [HELP] Strange tag mismatch - float algorhytm
Reply With Quote #1

Hey there! I made an algorhytm plugin, which will calculate typed value by following conditions in the stock and we will get result. Nevermind, I'm getting some strange tag mismatch on the closing bracket in the stock, can't understand why?! And also, my way of making these all float story is little messed, so if someone can suggest better way and tell me why is that tag mismatch there, I'll be very grateful. Thanks.
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>

#define PLUGIN "Algorhytm"
#define VERSION "1.0"
#define AUTHOR "Flicker"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd    ("say","Say")
    
register_clcmd    ("say_team","Say")
}

public 
Say(id)
{
    new 
args[129], command[11], arg2[32]
    
    
read_args(argscharsmax(args))
    
remove_quotes(args)
    
    
parse(argscommandcharsmax(command), arg2charsmax(arg2))
    
    new 
parameter str_to_num(arg2)
    
    if(
equali(command"/calculate"))
    {
        if(!
parameter)
        {
            
client_print(idprint_chat"You should add some value of X to calculate")
            return 
PLUGIN_HANDLED
        
}
        
        new 
value[32]
        
float_to_str(float(calculation(parameter*1.0)), valuecharsmax(value))
        
client_print(idprint_chat"Your result is %s"value)
    }
    
    return 
PLUGIN_CONTINUE
}

stock calculation(const Float:x)
{
    new 
Float:Result
    
    
if(1)
        
Result / (1)
    else if(
== 1)
        
Result 0
    
else if(1)
        
Result = (x) - 2
        
    
return Result
        

__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 06-21-2014 , 16:28   Re: [HELP] Strange tag mismatch - float algorhytm
Reply With Quote #2

Because you're trying to return a Float: tagged variable through a non-tagged stock.

Code:
stock calculation(const Float:x) {     new Float:Result           if(x > 1)         Result = 3 / (x - 1)     else if(x == 1)         Result = x * 0     else if(x < 1)         Result = (4 * x * x) - 2               return Result           }
__________________

Last edited by Black Rose; 06-21-2014 at 16:30.
Black Rose is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-21-2014 , 16:32   Re: [HELP] Strange tag mismatch - float algorhytm
Reply With Quote #3

Тhat was clear and helpfull enough, big thanks! I also removed that float() tag from the stock-calling in the float_to_string native, it was useless.
Here is the redacted code, if someone is interested.
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>

#define PLUGIN "Algorhytm"
#define VERSION "1.0"
#define AUTHOR "Flicker"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd    ("say","Say")
    
register_clcmd    ("say_team","Say")
}

public 
Say(id)
{
    new 
args[129], command[11], arg2[32]
    
    
read_args(argscharsmax(args))
    
remove_quotes(args)
    
    
parse(argscommandcharsmax(command), arg2charsmax(arg2))
    
    new 
parameter str_to_num(arg2)
    
    if(
equali(command"/calculate"))
    {
        if(!
parameter)
        {
            
client_print(idprint_chat"You should add some value of X to calculate")
            return 
PLUGIN_HANDLED
        
}
        
        new 
value[32]
        
float_to_str(calculation(float(parameter)), valuecharsmax(value))
        
client_print(idprint_chat"Your result is %s"value)
    }
    
    return 
PLUGIN_CONTINUE
}

stock Float:calculation(const Float:x)
{
    new 
Float:Result
    
    
if(1)
        
Result / (1)
    else if(
== 1)
        
Result 0
    
else if(1)
        
Result = (x) - 2
        
    
return Result
        

Black Rose, saving good noobs again!
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
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 21:14.


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