dini questions
#1

Hi there. I'm trying to check whenever a player connects, the server uses dini to check if a dini key exists for that player in a certain file. Then, it saves the value of the key to an array to avoid excessive accessing of the ini file.

pawn Код:
public OnPlayerConnect(playerid)
{
  SetPlayerMapIcon(playerid,20,337.5643,-1370.2089,14.3267,55,0); // THE ICON
  new NameString[MAX_PLAYER_NAME];
  new string[255];
  GetPlayerName(playerid,NameString,sizeof(NameString));
  string = dini_Get("LicenseInfo.ini", NameString);
  pLicensesInfo[playerid] = string; // LINE 79
  return 1;
}
Код:
C:\Users\Family\Desktop\()\SAMP server shit\filterscripts\CarSchool.pwn(79) : error 006: must be assigned to an array
Any help?
Reply
#2

You are trying to save a string to a variable, so it needs to be an array, for example "pLicensesInfo[MAX_PLAYERS][<maximum number of letters in string + 1>]". If it is a number that you are retrieving with dini, try "pLicensesInfo[playerid] = strval(string)".

Not sure if either will work, but you can try it.
Reply
#3

Eh, that didn't work.

pawn Код:
// TOP
new pLicensesInfo[playerid][256];

// CALLBACK

public OnPlayerConnect(playerid)
{
  SetPlayerMapIcon(playerid,20,337.5643,-1370.2089,14.3267,55,0); // THE ICON
  new NameString[MAX_PLAYER_NAME];
  new string[256];
  GetPlayerName(playerid,NameString,sizeof(NameString));
  string = dini_Get("LicenseInfo.ini", NameString);
  pLicensesInfo[playerid][256] = string; // LINE 80
  return 1;
}
Код:
C:\Users\Family\Desktop\()\SAMP server shit\filterscripts\CarSchool.pwn(80) : error 032: array index out of bounds (variable "pLicensesInfo")
C:\Users\Family\Desktop\()\SAMP server shit\filterscripts\CarSchool.pwn(80) : error 006: must be assigned to an array
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Any help?
Reply
#4

I think:

pawn Код:
pLicensesInfo[playerid][256] = string[128]; // LINE 80
Reply
#5

Quote:
Originally Posted by CAR
I think:

pawn Код:
pLicensesInfo[playerid][256] = string[128]; // LINE 80
Just wondering, why? And I still get

Код:
C:\Users\Family\Desktop\()\SAMP server shit\filterscripts\CarSchool.pwn(80) : error 032: array index out of bounds (variable "pLicensesInfo")
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#6

Top
Код:
new pLicensesInfo[MAX_PLAYERS][255];
Код:
pLicensesInfo[playerid] = string; // LINE 80
Reply
#7

Quote:
Originally Posted by Jefff
Top
Код:
new pLicensesInfo[MAX_PLAYERS][255];
Код:
pLicensesInfo[playerid] = string; // LINE 80
Код:
C:\Users\Family\Desktop\()\SAMP server shit\filterscripts\CarSchool.pwn(80) : error 047: array sizes do not match, or destination array is too small
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Ey.
Reply
#8

public OnPlayerConnect(playerid)
{
....
new string[128];
....
}

Reply
#9

You want to set a string. This does not work with assignment, try format-function instead.

format(pLicensesInfo[playerid], sizeof(pLicensesInfo[playerid]), "%s", string);

Have fun coding,
Draco
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)