Formatting string weird error
#1

Hello, when I try to format a string I get these errors, and I don't really know why...
Код:
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 код:
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?
Reply
#2

Код:
#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);
}
Reply
#3

Quote:
Originally Posted by sampkinq
Посмотреть сообщение
Код:
#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
Reply
#4

Quote:
Originally Posted by ******
Посмотреть сообщение
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!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)