Raised This Month: $ Target: $400
 0% 

[SOLVED] How to properly use set_string()?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-14-2016 , 09:36   [SOLVED] How to properly use set_string()?
Reply With Quote #1

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.

Last edited by OciXCrom; 06-27-2016 at 17:56.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 04-14-2016 , 15:38   Re: How to properly use set_string()?
Reply With Quote #2

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)) ;


Last edited by SpeeDeeR; 04-14-2016 at 15:39.
SpeeDeeR is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-14-2016 , 15:47   Re: How to properly use set_string()?
Reply With Quote #3

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.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 04-14-2016 , 16:31   Re: How to properly use set_string()?
Reply With Quote #4

Pass it byref.
Format the message directly in szOutput or use copy() in the end.
SpeeDeeR is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-15-2016 , 14:46   Re: How to properly use set_string()?
Reply With Quote #5

I think I got it, but without using charsmax. Thank you.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
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 11:19.


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