Raised This Month: $ Target: $400
 0% 

error 035:argument type mismatch


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Markit0s
Junior Member
Join Date: Dec 2009
Old 10-20-2010 , 03:58   error 035:argument type mismatch
Reply With Quote #1

This is my first time trying to write a plugin and I can't figure out how to get the TF2_AddCondition function to work. I keep getting error 035:argument type mismatch for argument 3 on line 31.


PHP Code:
#include <sourcemod>
#include <tf2>
#include <tf2_stocks>
#include <sdktools>
 
public Plugin:myinfo =
{
    
name "give uber",
    
author "Me",
    
description "My first plugin ever",
    
version "1.0.0.0",
    
url "http://www.sourcemod.net/"
}
 
public 
OnPluginStart()
{
    
RegAdminCmd("sm_giveuber"Command_GiveUberADMFLAG_SLAY)
}

public 
Action:Command_GiveUber(clientargs)
{
    if(
args 2)
    {
        
PrintToChat(client"[SM] Usage: sm_giveuber <#userid|name> [duration]");
        return 
Plugin_Handled;
    }
    
decl String:arg1[65], String:duration[255];
    
GetCmdArg(1arg1sizeof(arg1));    
    
GetCmdArg(2durationsizeof(duration));
    {
                        
TF2_AddCondition(clientTFCond:TFCond_Uberchargedduration);

    }
    return 
Plugin_Handled;


Markit0s is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 10-20-2010 , 04:25   Re: error 035:argument type mismatch
Reply With Quote #2

You're trying to pass a string to a float:

Syntax: native TF2_AddCondition(client, TFCond:condition, Float:duration);

Usage: client - Player's index.
condition - Integer identifier of condition to apply.
duration - Duration of condition (does not apply to all conditions).


Simply use StringToFloat()

PHP Code:
    decl String:arg1[65], String:duration[255];
    
GetCmdArg(1arg1sizeof(arg1));    
    
GetCmdArg(2durationsizeof(duration));
    {
        
TF2_AddCondition(clientTFCond:TFCond_UberchargedStringToFloat(duration));
    } 
__________________
Silvers is offline
Markit0s
Junior Member
Join Date: Dec 2009
Old 10-20-2010 , 15:52   Re: error 035:argument type mismatch
Reply With Quote #3

Thanks for the help!

After adding the StringToFloat(), the plug in compiles.

If I give it 2 arguments in game, the console just responds with an unknown command.

Any ideas on how to fix this?
__________________

Markit0s is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 10-20-2010 , 15:55   Re: error 035:argument type mismatch
Reply With Quote #4

if(args < 2)

Means if the total number of arguments are below 2. So change the 2 to 3
__________________
Silvers is offline
Markit0s
Junior Member
Join Date: Dec 2009
Old 10-20-2010 , 16:24   Re: error 035:argument type mismatch
Reply With Quote #5

I changed the 2 to 3 and it still doesn't work.

I tried removing the entire if statement and now it gives me this error in the server console.

PHP Code:
L 10/20/2010 15:13:24: [SMNative "TF2_AddCondition" reportedFailed to locate function
L 10/20/2010 15:13:24: [SMDisplaying call stack trace for plugin "tf2ubercondition.smx":
L 10/20/2010 15:13:24: [SM]   [0]  Line 26tf2ubercondition.sp::Command_GiveUber()

Edit: Once I updated my sourcemod installation the plugin worked just fine.

Thanks for all your help!
__________________


Last edited by Markit0s; 10-20-2010 at 16:36.
Markit0s is offline
onv
Senior Member
Join Date: Feb 2011
Old 01-21-2013 , 07:23   Re: error 035:argument type mismatch
Reply With Quote #6

Hey there , sorry for the big bump , but I have a problem. I did everything Silvers said , and when i type "sm_giveuber @me 20" , it shows a message "[SM] Usage: sm_giveuber <#userid|name> [duration]"
Here's the .sp :

Code:
#include <sourcemod>
#include <tf2>
#include <tf2_stocks>
#include <sdktools>
 
public Plugin:myinfo =
{
    name = "give uber",
    author = "Me",
    description = "My first plugin ever",
    version = "1.0.0.0",
    url = "http://www.sourcemod.net/"
}
 
public OnPluginStart()
{
    RegAdminCmd("sm_giveuber", Command_GiveUber, ADMFLAG_SLAY)
}

public Action:Command_GiveUber(client, args)
{
    if(args < 3)
    {
        PrintToChat(client, "[SM] Usage: sm_giveuber <#userid|name> [duration]");
        return Plugin_Handled;
    }
    decl String:arg1[65], String:duration[255];
    GetCmdArg(1, arg1, sizeof(arg1));    
    GetCmdArg(2, duration, sizeof(duration));
    {
        TF2_AddCondition(client, TFCond:TFCond_Ubercharged, StringToFloat(duration));
    }
    return Plugin_Handled;
}
onv is offline
Despirator
Senior Member
Join Date: Jun 2011
Location: Kazakhstan ->Shymkent
Old 01-21-2013 , 11:33   Re: error 035:argument type mismatch
Reply With Quote #7

beacuse the code is completely incorrect coded
btw. for your issue change args < 3 to args < 2

Last edited by Despirator; 01-21-2013 at 11:34.
Despirator is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 01-21-2013 , 18:45   Re: error 035:argument type mismatch
Reply With Quote #8

In addition to the args < 3 thing Despirator mentioned, you're not processing arg1 at all. You really need to do a ProcessTargetString on it.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 01-21-2013 at 18:46.
Powerlord 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 17:51.


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