SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 07/12/2018, 02:44 PM   #1
StRaphael
Big Clucker
 
Join Date: Nov 2016
Posts: 87
Reputation: 0
Default Formatting string weird error

Hello, when I try to format a string I get these errors, and I don't really know why...
Code:
error 001: expected token: "]", but found "-identifier-"
warning 215: expression has no effect
error 001: expected token: ";", but found "]"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
Code:
PHP Code:
enum NewbieMessagesInfo
{
    
nMessage[518]
};
new 
NewbieMessageInfo[MAX_NEWBIESMESSAGES][NewbieMessagesInfo];
stock SendQuestion(playeridmessage[])
{
    
format(NewbieMessageInfo[playerid][nMessage], sizeof(NewbieMessageInfo[playerid][nMessage]), "%s"message);// this is the error line
    //Other code

Any solution?
StRaphael is offline   Reply With Quote
Old 07/12/2018, 03:08 PM   #2
sampkinq
Big Clucker
 
Join Date: Sep 2013
Location: Turkey
Posts: 187
Reputation: 6
Default Re: Formatting string weird error

Code:
#include	<a_samp>

#define     MAX_NEWBIESMESSAGES     (500)
#define     MAX_MESSAGE_STR         (518)

enum NewbieMessagesInfo
{
    nMessage[MAX_MESSAGE_STR]
};
new NewbieMessageInfo[MAX_NEWBIESMESSAGES][NewbieMessagesInfo];

main()
{
}

public OnPlayerConnect(playerid)
{
	SendQuestion(playerid, "TR");
	return 1;
}

stock SendQuestion(playerid, message[])
{
    format(NewbieMessageInfo[playerid][nMessage], MAX_MESSAGE_STR, message);
}
sampkinq is offline   Reply With Quote
Old 07/12/2018, 03:16 PM   #3
StRaphael
Big Clucker
 
Join Date: Nov 2016
Posts: 87
Reputation: 0
Default Re: Formatting string weird error

Quote:
Originally Posted by sampkinq View Post
Code:
#include	<a_samp>

#define     MAX_NEWBIESMESSAGES     (500)
#define     MAX_MESSAGE_STR         (518)

enum NewbieMessagesInfo
{
    nMessage[MAX_MESSAGE_STR]
};
new NewbieMessageInfo[MAX_NEWBIESMESSAGES][NewbieMessagesInfo];

main()
{
}

public OnPlayerConnect(playerid)
{
	SendQuestion(playerid, "TR");
	return 1;
}

stock SendQuestion(playerid, message[])
{
    format(NewbieMessageInfo[playerid][nMessage], MAX_MESSAGE_STR, message);
}
It works, thanks!
But can you explain me what I did wrong?
Anyway, +rep
StRaphael is offline   Reply With Quote
Old 07/12/2018, 03:31 PM   #4
Y_Less
Beta Tester
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 15,317
Reputation: 3191
Default Re: Formatting string weird error

From a very similar question yesterday:

https://forum.sa-mp.com/showpost.php...35&postcount=4
Y_Less is online now   Reply With Quote
Old 07/12/2018, 04:15 PM   #5
StRaphael
Big Clucker
 
Join Date: Nov 2016
Posts: 87
Reputation: 0
Default Re: Formatting string weird error

Quote:
Originally Posted by Y_Less View Post
From a very similar question yesterday:

https://forum.sa-mp.com/showpost.php...35&postcount=4
Ok, I think I understood what the problem is, thanks!
StRaphael is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
String formatting problem andrejc999 Scripting Help 5 09/06/2018 10:55 PM
[Tutorial] String Formatting krogsgaard20 Tutorials 37 15/12/2017 01:13 PM
String Formatting. zT KiNgKoNg Scripting Help 2 25/12/2014 05:48 PM
Formatting string question AphexCCFC Scripting Help 3 12/04/2014 09:25 PM
After formatting string it won't print string out Typhome Scripting Help 3 04/07/2013 10:19 AM


All times are GMT. The time now is 02:16 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.