Raised This Month: $ Target: $400
 0% 

How is this argument a mismatch?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 02-08-2010 , 17:52   How is this argument a mismatch?
Reply With Quote #1

I'm trying to run a formatex function in a plugin that I'm making, but it gives me some error that tells me
Code:
error 035: argument type mismatch (argument 1)
The line I'm trying to execute is
PHP Code:
formatexmessage63"%s^nHealth: %i^n[%s]"targetnameget_user_healthtarget ), randomsz_Reasons ) ) 
and the message declaration is
Code:
new message[64]
Any help would be appreciated.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 02-08-2010 , 18:08   Re: How is this argument a mismatch?
Reply With Quote #2

I don't get any errors on this. Paste whole code or at least whole function.
__________________
Impossible is Nothing
Sylwester is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 02-08-2010 , 18:13   Re: How is this argument a mismatch?
Reply With Quote #3

PHP Code:
public fw_PlayerPreThinkid )
{
    if( !
is_user_aliveid ) )
    {
        return;
    }
    new 
targetbody
    
    get_user_aiming
idtargetbody )
    
    new 
CsTeams:targteam cs_get_user_teamtarget )
    
    new 
targetname[32]
    
    
get_user_nametargettargetname63 )
    
    new 
message[64]
    
    if( 
targteam == CS_TEAM_T )
    {
        
set_hudmessage000, -1.0, -1.000.00.10.00.0, -)
        
formatexmessage63"%s^nHealth: %i^n[%s]"targetnameget_user_healthtarget ), randomsz_Reasons ) )
    }
    else if( 
targteam == CS_TEAM_CT )
    {
        
set_hudmessage15000, -1.0, -1.000.00.10.00.0, -)
        
formatexmessage63"%s^nHealth: %i^n[Guard]"targetnameget_user_healthtarget ) )
    }
    
show_hudmessageid"%s"message )

__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 02-08-2010 , 18:20   Re: How is this argument a mismatch?
Reply With Quote #4

It's because of sz_Reasons. It should be int and you probably declared it as an array. Maybe you want:
PHP Code:
formatexmessage63"%s^nHealth: %i^n[%s]"targetnameget_user_healthtarget ), sz_Reasons[random(MAX_REASONS)] ) 
__________________
Impossible is Nothing
Sylwester is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 02-08-2010 , 18:30   Re: How is this argument a mismatch?
Reply With Quote #5

Compiled perfectly. Thanks for the help.

Quick question: I had previously done
PHP Code:
#define MAX_REASONS    7

new const sz_Reasons[MAX_REASONS] = {
    
"Wifebeater",
    
"Robber",
    
"Bank Heister",
    
"Hitman",
    
"Rapist",
    
"Computer Hacker",
    
"Identity Thief"

But it gave me an error saying initialization data exceeds declared size, and I also tried defining it as 8. So I changed it to
PHP Code:
#define MAX_REASONS    7

new const sz_Reasons[MAX_REASONS][] = {
    
"Wifebeater",
    
"Robber",
    
"Bank Heister",
    
"Hitman",
    
"Rapist",
    
"Computer Hacker",
    
"Identity Thief"

Is that correct, the double array? Or should I change it to something different?
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 02-08-2010 , 18:41   Re: How is this argument a mismatch?
Reply With Quote #6

It's correct.
__________________
Impossible is Nothing
Sylwester is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 02-08-2010 , 18:42   Re: How is this argument a mismatch?
Reply With Quote #7

Quote:
Originally Posted by Sylwester View Post
It's correct.
Aight, thanks for the help.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-08-2010 , 18:53   Re: How is this argument a mismatch?
Reply With Quote #8

I would use:

PHP Code:
new const sz_Reasons[][] = {
    
"Wifebeater",
    
"Robber",
    
"Bank Heister",
    
"Hitman",
    
"Rapist",
    
"Computer Hacker",
    
"Identity Thief"
}
// . . .
sz_Reasons[random(sizeof(sz_Reasons))] 
This way when you add or remove "reasons" from the list you won't have to change anything else. The way you currently have it you have to change MAX_REASONS to match the declaration of sz_Reasons.
__________________
fysiks is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 02-08-2010 , 18:56   Re: How is this argument a mismatch?
Reply With Quote #9

Quote:
Originally Posted by fysiks View Post
I would use:

PHP Code:
new const sz_Reasons[][] = {
    
"Wifebeater",
    
"Robber",
    
"Bank Heister",
    
"Hitman",
    
"Rapist",
    
"Computer Hacker",
    
"Identity Thief"
}
// . . .
sz_Reasons[random(sizeof(sz_Reasons))] 
This way when you add or remove "reasons" from the list you won't have to change anything else. The way you currently have it you have to change MAX_REASONS to match the declaration of sz_Reasons.
Good point, especially since the plugin's for 2+ other people.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-08-2010 , 19:07   Re: How is this argument a mismatch?
Reply With Quote #10

Yeah, it's not a huge difference but when people (who didn't code it) add or remove things they won't have to worry about needing to change anything else.
__________________
fysiks 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 07:25.


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