Error Assigned to an array
#1

I have written a simple system about phone saving information.
I want to do: Player use command '/addinfo1 [information]'.
Код:
CMD:addino1(playerid, params[])
{
    new string[128], playerinfo[64];
    if(sscanf(params, "s[64]", playerinfo)) return SendMessage(playerid, 0xFFFF00FF, "Usage: /addinfo1 [Information about another player].");
	format(string, sizeof(string), "You have add: [%d] at line Info 1 of your phone.", playerinfo);
    SendClientMessageEx(playerid, COLOR_REPORT, string);
    PlayerInfo[playerid][pNoidungdanhbas][1] = playerinfo;//This line is error
Код:
error 006: must be assigned to an array
Reply
#2

How..you declared pNoidungdanhbas in your enum?
Reply
#3

Here mate
Код:
pNoidungdanhbas[11],
Reply
#4

First, don't use sscanf if you have only one string..thats nonsense

Ok, write it like this:

PHP код:
CMD:addino1(playeridparams[])
{
    if(
IsNull(params)) return SendMessage(playerid0xFFFF00FF"Usage: /addinfo1 [Information about another player].");
    if(
strlen(params) > 11) return SendMessage(playerid0xFFFF00FF,"* Too long information!");
    new 
string[128];
    
format(stringsizeof(string), "You have add: [%s] at line Info 1 of your phone."params);
    
SendClientMessageEx(playeridCOLOR_REPORTstring);
    
format(PlayerInfo[playerid][pNoidungdanhbas],11,params);

Maybe you should set the maxlen not to 11..32 or sth like this..should be better about information

Just chance these 11 to 32 in the code, it all should worked fine
Reply
#5

Код:
format(PlayerInfo[playerid][pNoidungdanhbas],11,params);
The number 11, what does it means ?
Reply
#6

Its the length of the information of the player...
Reply
#7

My full code about this system
Код:
//My code view information from navicat.
CMD:viewphonebook(playerid, params[])
{
    if(PlayerInfo[playerid][pPhoneBook] == 1)
	{
		new string[128];
		SendClientMessageEx(playerid, COLOR_GREEN, "____________________ Phone book Information _____________________");
		for(new i = 1; i < 11; i++)
		{
  		    format(string, sizeof(string), "Info number %d: %s.", i, PlayerInfo[playerid][pNoidungdanhbas][i]);
			SendClientMessageEx(playerid, COLOR_GREEN, string);
		}
		SendClientMessageEx(playerid, COLOR_GREEN, "_________________________________________________________");
	}
	else SendClientMessageEx(playerid, COLOR_LIGHTRED, "You don't have phone book.");
	return 1;
}
//My code import the params to navicat.
CMD:addinfo1(playerid, params[])
{
if(isnull(params)) return SendClientMessageEx(playerid, COLOR_GREEN, "(( Usage: /addinfo1 [Player Information] ))");
    if(strlen(params) > 11) return SendClientMessageEx(playerid, COLOR_LIGHTRED,"(( Character is too long. ))");
    new string[128];
    format(string, sizeof(string), "Text: [%s] was added at line 1.", params);
    SendClientMessageEx(playerid, COLOR_REPORT, string);
    format(PlayerInfo[playerid][pNoidungdanhbas][1],11,params);
	return 1;
}
And the result when I use command /viewphonebook ingame. I'm just use command "/addinfo1 cailongithe", and it's spamming to another number.


And in my Navicat, it's just saving a number. I have change the type to varchar(20), but it's still be a number, not a text.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)