Raised This Month: $ Target: $400
 0% 

[PROBLEM SOLVED] [fcos] Arguement Type Mismatch Help Page


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SubStream
Veteran Member
Join Date: Aug 2005
Location: USA
Old 04-08-2006 , 13:24   [PROBLEM SOLVED] [fcos] Arguement Type Mismatch Help Page
Reply With Quote #1

This help page is directly related to my plugin [fcos]. If you need to view the full plugin script go there and download the .sma file.

I am trying to shorten the code for my plugin fcos by forwarding parameters to fn_fcosandlogentry and fn_showadmin. When I compile I get this
Code:
Welcome to the AMX Mod X 1.70-300 Compiler.
Copyright (c) 1997-2005 ITB CompuPhase, AMX Mod X Team

Error: Argument type mismatch (argument 2) on line 873
Error: Argument type mismatch (argument 3) on line 888

2 Errors.
Could not locate output file C:\Documents and Settings\Owner\My Documents\CS\serverfinal1\cstrike\addons\amxmodx\scripting\compiled\fcospassfn.amx (compile failed).
Line 873
Code:
fn_fcosandlogentry ( gi_playerID, s_cvarname, gf_valuefromplayer, gf_calfloatvalue )
Line 888
Code:
fn_showadmin ( gi_playerID, gi_playerID2, s_cvarname, gf_valuefromplayer, gf_calfloatvalue )
I need the cvar name represented by variable s_cvarname to be a parameter in those two functions ( fn_fcosandlogentry and fn_showadmin ). What do I need to do in order to forward/pass the string s_cvarname[] as a parameter and not get arguement type mismatch when compiling? Here is the function line 873 and 888 are in.
Code:
public fn_cl_weather ( gi_playerID, const s_cvarname[], const value[] ) {     gf_valuefromplayer = floatstr ( value )     gf_calfloatvalue = 1.0         if ( ! ( gf_valuefromplayer == gf_calfloatvalue ) )     {         fn_fcosandlogentry ( gi_playerID, s_cvarname, gf_valuefromplayer, gf_calfloatvalue )                 get_players ( gi_players2, gi_playercnt2, "ch" )                 for ( gi_playernum2 = 0; gi_playernum2 < gi_playercnt2; gi_playernum2++ )         {             gi_playerID2 = gi_players2[gi_playernum2]                         if ( ! ( is_user_admin ( gi_playerID2 ) ) )             {                 return PLUGIN_HANDLED             }                         else             {                 fn_showadmin ( gi_playerID, gi_playerID2, s_cvarname, gf_valuefromplayer, gf_calfloatvalue )             }         }     }         else     {         return PLUGIN_HANDLED     }         return PLUGIN_HANDLED }
fn_cl_weather is the result function for
Code:
query_client_cvar ( gi_playerID, "cl_weather", "fn_cl_weather" )
which is inside of fn_query1 function for the fcos plugin. Here are the two functions I want s_cvarname forwarded/passed to
Code:
public fn_fcosandlogentry ( gi_playerID, s_cvarname, gf_valuefromplayer, gf_calfloatvalue ) {     client_cmd ( gi_playerID, "%s %f", s_cvarname, gf_calfloatvalue )         get_user_name ( gi_playerID, gs_logname, 31 ) // Outputs the user's name into gs_logname     get_user_authid ( gi_playerID, gs_logauthid, 32 ) //  Outputs the user's authid into gs_logauthid     get_user_ip ( gi_playerID, gs_logip, 43 ) // Outputs the user's IP into gs_logip             log_amx ( "%L", LANG_SERVER, "FCOS_LANG_LOG_ENTRY", gs_logname, get_user_userid ( gi_playerID ), gs_logauthid, gs_logip, s_cvarname, gf_valuefromplayer, gf_calfloatvalue ) // Logs FCOS_LANG_LOG_ENTRY } public fn_showadmin ( gi_playerID, gi_playerID2, s_cvarname, gf_valuefromplayer, gf_calfloatvalue ) {     get_user_name ( gi_playerID, gs_logname, 31 )         client_print ( gi_playerID2, print_console, "%L", LANG_SERVER, "FCOS_LANG_SHOW_ADMIN", gs_logname, s_cvarname, gf_valuefromplayer, gf_calfloatvalue ) }
If you can help me forward the string s_cvarname to these two functions please show me how.

Edit: This problem has been solved. Thank you VEN for the help on this.
SubStream is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 04-08-2006 , 14:41  
Reply With Quote #2

Try both ways.
Code:
const s_cvarname[] = ""
Code:
s_cvarname[]
VEN is offline
SubStream
Veteran Member
Join Date: Aug 2005
Location: USA
Old 04-08-2006 , 15:22  
Reply With Quote #3

VEN maybe I should have included that fn_cl_weather is the result function of query_client_cvar for cl_weather so s_cvarname already has a value and does not need to be defined.

Also I've tried s_cvarname[] instead of s_cvarname when forwarding the parameter s_cvarname and it says

"Invalid expression, assumed zero on line ...."

and i've tried const cvarname[]

Same result.

To view the full code for the fcos plugin to see what I am talking about go to http://forums.alliedmods.net/showthread.php?t=25927

The plugin is too large to post in this forum. You have to look at the actual .sma to see the whole thing.
SubStream is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 04-08-2006 , 15:53  
Reply With Quote #4

Replace all instances of "const s_cvarname[]" and "s_cvarname" which appears in function headers with "s_cvarname[]" and try to compile again.

If there are still errors. Post compiler output and post lines of source code where errors appears.
VEN is offline
SubStream
Veteran Member
Join Date: Aug 2005
Location: USA
Old 04-08-2006 , 16:01  
Reply With Quote #5

Quote:
Originally Posted by VEN
Replace all instances of "const s_cvarname[]" and "s_cvarname" which appears in function headers. Try to compile.

If there are still errors. Post compiler output and post lines of source code where errors happens.
OK I replaced those with s_cvarname[] and this is the full compiler message
Code:
Welcome to the AMX Mod X 1.70-300 Compiler.
Copyright (c) 1997-2005 ITB CompuPhase, AMX Mod X Team

Error: Invalid expression, assumed zero on line 909
Error: Invalid expression, assumed zero on line 924

2 Errors.
Could not locate output file C:\Documents and Settings\Owner\My Documents\CS\serverfinal1\cstrike\addons\amxmodx\scripting\compiled\fcos.amx (compilefailed).
Line 909
Code:
fn_fcosandlogentry ( gi_playerID, s_cvarname[], gf_valuefromplayer, gf_calfloatvalue )
Line 924
Code:
fn_showadmin ( gi_playerID, gi_playerID2, s_cvarname[], gf_valuefromplayer, gf_calfloatvalue )
Here is the full function that these lines were in:
Code:
public fn_cl_weather ( gi_playerID, s_cvarname[], const value[] ) // replaced const s_cvarname[] with s_cvarname[] as you said to do {     gf_valuefromplayer = floatstr ( value )     gf_calfloatvalue = 1.0         if ( ! ( gf_valuefromplayer == gf_calfloatvalue ) )     {         fn_fcosandlogentry ( gi_playerID, s_cvarname[], gf_valuefromplayer, gf_calfloatvalue ) // replaced s_cvarname with s_cvarname[] as you said to do                 get_players ( gi_players2, gi_playercnt2, "ch" )             for ( gi_playernum2 = 0; gi_playernum2 < gi_playercnt2; gi_playernum2++ )         {             gi_playerID2 = gi_players2[gi_playernum2]                     if ( ! ( is_user_admin ( gi_playerID2 ) ) )             {                 return PLUGIN_HANDLED             }                         else             {                 fn_showadmin ( gi_playerID, gi_playerID2, s_cvarname[], gf_valuefromplayer, gf_calfloatvalue ) // replaced s_cvarname with s_cvarname[] as you said to do             }         }     }         else     {         return PLUGIN_HANDLED     }         return PLUGIN_HANDLED }
SubStream is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 04-08-2006 , 16:14  
Reply With Quote #6

No, when i said "function headers" i mean only where function body begins.

Example:

Code:
my_func(param[]) { // function's header     another_func(another_param) // notice no brackets for another_param }
VEN is offline
SubStream
Veteran Member
Join Date: Aug 2005
Location: USA
Old 04-08-2006 , 16:56  
Reply With Quote #7

Quote:
Originally Posted by VEN
No, when i said "function headers" i mean only where function body begins.

Example:

Code:
my_func(param[]) { // function's header     another_func(another_param) // notice no brackets for another_param }
So thats kinda like doing this?
Code:
public fn_cl_weather ( gi_playerID, s_cvarname[], const value[] )  // function's header {         fn_fcosandlogentry ( gi_playerID, s_cvarname, gf_valuefromplayer, gf_calfloatvalue ) // notice no brackets for s_cvarname as I originally had it
Is that correct to what you talking about doing? The only difference is that const was taken out of the function param for fn_cl_weather. If I am wrong please just post what I originally posted the correct way. Changing the function header for fn_cl_weather from const s_cvarname[] to s_cvarname[] did nothing and I still get the same problem when I compile.
SubStream is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 04-09-2006 , 06:59  
Reply With Quote #8

I think i got where is the problem.
Do not use global variables in function headers.
VEN is offline
SubStream
Veteran Member
Join Date: Aug 2005
Location: USA
Old 04-09-2006 , 09:16  
Reply With Quote #9

VEN the variable that won't pass through to the other functions is s_cvarname... that isn't a global variable so that can't be the problem.
SubStream is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 04-09-2006 , 11:28  
Reply With Quote #10

Attach the whole source. If it's to big, archive it. I'll see what happens.
VEN 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 16:34.


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