Raised This Month: $12 Target: $400
 3% 

2 Problems/Questions in SourcePawn 1.7


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Eun
Member
Join Date: Jan 2011
Old 06-22-2015 , 08:05   2 Problems/Questions in SourcePawn 1.7
Reply With Quote #1

Can someone explain me why this is not possible and / or howto solve these problems in the following code:

PHP Code:
#pragma newdecls required

#include <sourcemod>

char[] TestChars()
{
    
char[] buffer = new char[21];
    
strcopy(buffer20"Hello!");
    return 
buffer;
}

char[] TestChars2()
{
    
// this is working
    
char[] buffer "";
    return 
buffer;
    
    
// this is not working
    //return "" // error 039: constant symbol has no size
}


void main()
{
    
// this is working
    
PrintToServer("Chars: %s\n"TestChars());
    
    
// this is not:
    
char[] buffer TestChars(); // error 001: expected token: "-string-", but found "-identifier-"
    
PrintToServer("Chars: %s\n"buffer);
    
    
PrintToServer("Chars: %s\n"TestChars2());


Last edited by Eun; 06-22-2015 at 08:06.
Eun is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 06-22-2015 , 08:31   Re: 2 Problems/Questions in SourcePawn 1.7
Reply With Quote #2

Pretty sure you can't return arrays still.
__________________
WildCard65 is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 06-23-2015 , 19:45   Re: 2 Problems/Questions in SourcePawn 1.7
Reply With Quote #3

Um. You cant return char[] for a function. You need to parse a buffer char array and write to it.

Just think. Is there a sourcemod function that returns char[]?
__________________
Neuro Toxin is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 06-23-2015 , 19:49   Re: 2 Problems/Questions in SourcePawn 1.7
Reply With Quote #4

PHP Code:
stock void TestChars(char[] bufferint length)
{
    
strcopy(bufferlength"Hello!");

__________________
Neuro Toxin is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 06-24-2015 , 01:53   Re: 2 Problems/Questions in SourcePawn 1.7
Reply With Quote #5

According to Asherkin, non-public functions can return strings.

No idea if that capability is gone in 1.7.
Potato Uno 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 01:06.


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