AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Returning string by reference (https://forums.alliedmods.net/showthread.php?t=94040)

orglee 06-05-2009 19:44

Returning string by reference
 
How can I make a function set an argument passed to it to string?
Code:
function ReturnString(arg_1, &arg_2) { arg_2 = "some string" }
I'm calling function from other plugin using callfunc_* and after I've read over 20 topics it seems thats the only way to return a string.

Unfortunately that implementation gives me an error "Error: Must be assigned to an array on line 218" So I think the main question is... how to force type to String / Array on argument passed to function.

fysiks 06-05-2009 20:33

Re: Returning string by reference
 
PHP Code:

public function(mystring[]) 

Also, I was told to use copy() to assign a string to an array variable.

orglee 06-05-2009 22:34

Re: Returning string by reference
 
Oh my goodness it was obvious...

But still I have a problem:
Code:

Error: Variable cannot be both a reference and an array (variable "sOutput") on line 185
Alright so how can I return a string from function called by callfunc_* I would like to omit returning some integer and loading that string from 'mother' plugin. But it seams that has to be done that way. :/

Bugsy 06-05-2009 22:40

Re: Returning string by reference
 
Sounds like you are trying to use &theVar[].

PHP Code:

new szTest[25];
fnTestszTest );
    
server_printszTest );

public 
fnTestszString[] )
{
    
formatexszString 25 "hello" );




All times are GMT -4. The time now is 13:47.

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