AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   argument type mismatch (https://forums.alliedmods.net/showthread.php?t=209424)

xfirestorm 02-25-2013 08:18

argument type mismatch
 
Hi,

I'm having a bit of trouble with this code:
Code:

public func1() {
new var1[32];
var1 = func2();
}

public func2() {
new var2[32];
if(something) var2 = "0";
else var2 = "<here come 32 chars>";
return var2;
}

I'm getting "argument type mismatch" on var1 = func2();, I also tried replacing this line with:
strcat(var1,func2(),31);
same result.

Is this not allowed?

xfirestorm 02-25-2013 08:40

Re: argument type mismatch
 
How the...
Anyway, I just tried compiling that sample code and it works...
Well, here is the actual code:
Quote:

public hbID_check(data[1],taskid) {
new id = data[0];
new name[32];
get_user_name(id,name,31);
new old_hbID[32];

strcat(old_hbID,db_check_name_exists(id,name) ,31);
/* ... more code ... */
return 0;
}

public db_check_name_exists(id,name) {
new return_val[32];
new hbID[32];
return_val = "0";
new Sql:conn;
conn = dbi_connect("localhost","user","secret","dev_ db");
new rHandle;
rHandle = dbi_query(conn,"SELECT hbid FROM hbid_store WHERE player_name = '%s'",name);
if(rHandle < 0) {
return_val = "-1";
} else if (rHandle > 0) {
dbi_nextrow(rHandle);
dbi_result(rHandle,"hbid",hbID,31);

dbi_free_result(rHandle);
dbi_close(conn);

return_val = hbID;
}

dbi_close(conn);

return return_val;
}
Error is on this line: strcat(old_hbID,db_check_name_exists(id,name) ,31);

xfirestorm 02-25-2013 08:52

Re: argument type mismatch
 
Ah...I will always use brains before asking stupid questions. I will always use brains before asking stupid questions.

I seriously doubt that someone will do such a dumb mistake as I did again, but just in case.
After changing second function declaration to:
public db_check_name_exists(id,name[])
things started to work as expected.


All times are GMT -4. The time now is 21:43.

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