array size error - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: array size error (
/showthread.php?tid=450171)
array size error -
Rufio - 11.07.2013
Hello,
I am editing LA-RP to a brand new script. But I need help with opening its' mysql which is built in itself.
Here is the lines which has got error:
pawn Код:
public OnPlayerRegister(playerid, password[]) // v1.0 by Luk0r
{
if(IsPlayerConnected(playerid))
{
MySQLCheckConnection();
new playername3[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername3, sizeof(playername3));
new newaccountsqlid = MySQLCreateAccount(playername3, password);
if (newaccountsqlid != 0)
{
PlayerInfo[playerid][pSQLID] = newaccountsqlid;
PlayerInfo[playerid][pKey] = password;
strmid(PlayerInfo[playerid][pKey], password, 0, strlen(password), 255);
OnPlayerUpdate(playerid);
SendClientMessage(playerid, COLOR_YELLOW, "Account registered, you can now log in (/login [password]).");
return 1;
}
else
{
SendClientMessage(playerid, COLOR_DARKNICERED, "There was an error creating your account. You will be disconnected now.");
Kick(playerid);
return 0;
}
}
return 0;
}
and here is the error :
Код:
C:\Documents and Settings\Admin\Desktop\server\gamemodes\larp.pwn(11450) : 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.
Thanks.
edit: This has got the error btw.
pawn Код:
PlayerInfo[playerid][pKey] = password;
Re: array size error -
gtakillerIV - 11.07.2013
Show us the pKey enum.
Edit: *Facepalm* listen to Killer.
Re: array size error -
[HiC]TheKiller - 12.07.2013
You cant really do string = string in PAWN. Use something like strcat or strcpy
pawn Код:
//Top of your script
#define strcpy(%0,%1,%2) strcat((%0[0] = '\0', %0), %1, %2)
//Your code
strcpy(PlayerInfo[playerid][pKey], password, sizeof(PlayerInfo[playerid][pKey]));
Respuesta: array size error -
CIzaquita - 12.07.2013
Put pKey on "PlayersInfoEnum" or whatever you called it.
pawn Код:
PlayerInfo[MAX_PLAYERS][PlayerInfoEnum];
enum PlayersInfoEnum
{
pKey,
Username
}
Something like that, its only an example.
Re: array size error -
Rufio - 12.07.2013
Thanks for all helps. I solved my problem ^^