AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED] How to properly use set_string()? (https://forums.alliedmods.net/showthread.php?t=281559)

OciXCrom 04-14-2016 09:36

[SOLVED] How to properly use set_string()?
 
This is probably a very simple question for some of you, but I just can't figure out how to properly use set_string(). I have this function:

PHP Code:

public get_message(idiPlayerszMsg[], szArg[], szOutput[], iLen)
{
    new 
szMessage[192]

    ... 
some stuff about formatting szMessage here ...

    
set_string(5szMessageiLen)


And I'm trying to set the string using all the parameters in it with this code:

PHP Code:

new szMessage[192]
get_message(id00szArgszMessagecharsmax(szMessage)) 

It doesn't work. I tried and tried and couldn't get it right. It even gives me a warning that szOutput isn't used.

SpeeDeeR 04-14-2016 15:38

Re: How to properly use set_string()?
 
set_string is for natives to start with. I'm sure you know that.
As stated above:

PHP Code:

public get_message(id,iParams//native
{
    new 
szMessage[192]
    
//    ... some stuff about formatting szMessage here ...
    
    
set_string(5szMessageiLen)
}  
//usage
public test() {
    new 
szMessage[192]
    
get_message(id00szArgszMessagecharsmax(szMessage)) ;



OciXCrom 04-14-2016 15:47

Re: How to properly use set_string()?
 
Hmm, guess I don't. Which function do I need to use if we're not talking about natives? I need this only inside one plugin. I'm currently using return szMessage, and I see that people are always saying it's not recommended.

SpeeDeeR 04-14-2016 16:31

Re: How to properly use set_string()?
 
Pass it byref.
Format the message directly in szOutput or use copy() in the end.

OciXCrom 04-15-2016 14:46

Re: How to properly use set_string()?
 
I think I got it, but without using charsmax. Thank you.


All times are GMT -4. The time now is 18:36.

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