Raised This Month: $32 Target: $400
 8% 

Argument type mismatch?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Balloons
Member
Join Date: Feb 2020
Old 10-15-2022 , 11:57   Argument type mismatch?
Reply With Quote #1

It's been a while since I've worked on plugins, which is why I'm struggling with this simple edit.

Errors:
HTML Code:
plugin.sp(287) : error 035: argument type mismatch (argument 3)
plugin.sp(291) : error 092: number of arguments does not match definition
Code:
PHP Code:
        if (IsValidEdict(i) && IsClientInGame(i) && GetClientTeam(i) == TEAM_SURVIVORS)
        {
            if (
damagepct && damagepct 75)
            {
                
CheatCMD(i"sm_setscore %d"damagepct); // Line 287
            
}
            if (
damagepct >= 75)
            {
                
CheatCMD(i"sm_setscore 75"); // Line 291
            
}
        } 
Stock:
PHP Code:
void CheatCMD(int client, const char[] command, const char[] argument1)
{
    
int userFlags GetUserFlagBits(client);
    
SetUserFlagBits(clientADMFLAG_ROOT);
    
int flags GetCommandFlags(command);
    
SetCommandFlags(commandflags & ~FCVAR_CHEAT);
    
FakeClientCommand(client"%s %s"commandargument1);
    
SetCommandFlags(commandflags);
    
SetUserFlagBits(clientuserFlags);

Balloons is offline
ProjectSky
AlliedModders Donor
Join Date: Aug 2020
Old 10-15-2022 , 12:27   Re: Argument type mismatch?
Reply With Quote #2

1. CheatCMD not accept format param
2. CheatCMD have 3 param but you code only pass 2 param
ProjectSky is offline
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 10-15-2022 , 12:37   Re: Argument type mismatch?
Reply With Quote #3

I have no idea what ur script do, but this is only an example

PHP Code:
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>

#pragma semicolon 1
#pragma newdecls required

public void OnPluginStart()
{
    
RegConsoleCmd("sm_test"Command_Test"Test Command");
}

Action Command_Test(int clientint args)
{
    
int damagepct 50;
    
    
int CmdFlags GetCommandFlags("sm_setscore");
    
SetCommandFlags("sm_setscore"CmdFlags & ~FCVAR_CHEAT);
    
FakeClientCommand(client"sm_setscore %d"damagepct);
    
SetCommandFlags("sm_setscore"CmdFlags);
    return 
Plugin_Handled;

__________________

Last edited by alasfourom; 10-15-2022 at 12:38.
alasfourom is offline
Balloons
Member
Join Date: Feb 2020
Old 10-15-2022 , 19:40   Re: Argument type mismatch?
Reply With Quote #4

Thank you for the suggestions. I managed to figure it out by changing some format functions. Probably not the ideal method, but it works for me.

PHP Code:
void CheatCMD(int clientchar[] commandint score)
{
    
int userFlags GetUserFlagBits(client);
    
SetUserFlagBits(clientADMFLAG_ROOT);
    
int flags GetCommandFlags(command);
    
SetCommandFlags(commandflags & ~FCVAR_CHEAT);
    
FakeClientCommand(client"%s %d"commandscore);
    
SetCommandFlags(commandflags);
    
SetUserFlagBits(clientuserFlags);

PHP Code:
int damagepct GetDamageAsPercent(TankDamage[i]);
        
//if (IsValidEdict(i) && IsClientInGame(i) && !IsFakeClient(i))
        
if (IsValidEdict(i) && IsClientInGame(i) && GetClientTeam(i) == TEAM_SURVIVORS)
        {
            if (
damagepct && damagepct 75)
            {
                
CheatCMD(i"sm_setscore"damagepct);
            }
            if (
damagepct >= 75)
            {
                
CheatCMD(i"sm_setscore"75);
            }
        } 
Balloons is offline
BRU7US
Member
Join Date: Jul 2020
Location: Tatarstan, Kazan
Old 10-16-2022 , 07:12   Re: Argument type mismatch?
Reply With Quote #5

PHP Code:
if (IsValidEdict(i) && IsClientInGame(i) && GetClientTeam(i) == TEAM_SURVIVORS)
{
            
char s_damagepct[3];
            
IntToString(damagepcts_damagepctsizeof(s_damagepct))

            if (
damagepct && damagepct 75)
            {
                
CheatCMD(i"sm_setscore"s_damagepct); // Line 287
            
}
            if (
damagepct >= 75)
            {
                
CheatCMD(i"sm_setscore""75"); // Line 291
            
}

you need to convert you integer "damagepct" to char-type variable, because your CheatCMD function uses char variable in third argument, but you trying to use integer variable. It causes "argument mismatch" error like in line #287
BRU7US is offline
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 10-16-2022 , 10:01   Re: Argument type mismatch?
Reply With Quote #6

I'm not sure but I think this "sm_setscore" is a command from an external plugin not a cvar which doent require you to bypass cheats command.

if so, the only thing u need to do is like this:

PHP Code:
if (IsValidEdict(i) && IsClientInGame(i) && GetClientTeam(i) == TEAM_SURVIVORS)
{
    
char s_damagepct[3];
    
IntToString(damagepcts_damagepctsizeof(s_damagepct))
    
    if (
damagepct && damagepct 75FakeClientCommand(i"sm_setscore %s"s_damagepct);
    else if (
damagepct >= 75FakeClientCommand(i"sm_setscore 75");

__________________

Last edited by alasfourom; 10-16-2022 at 10:06.
alasfourom is offline
Earendil
Senior Member
Join Date: Jan 2020
Location: Spain
Old 10-22-2022 , 06:20   Re: Argument type mismatch?
Reply With Quote #7

Try this:
PHP Code:
    if (IsValidEdict(i) && IsClientInGame(i) && GetClientTeam(i) == TEAM_SURVIVORS)
        {
            
char sAmt[8];
            if (
damagepct && damagepct 75)
            {
                
Format(sAmtsizeof(sAmt), "%d"damagepct);
                
CheatCMD(i"sm_setscore"sAmt);
            }
            if (
damagepct >= 75)
            {
                
CheatCMD(i"sm_setscore",  "75");
            }
        } 
__________________
>>My plugins<<
>>GitHub<<
Earendil 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 10:33.


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