array size error
#1

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;
Reply
#2

Show us the pKey enum.

Edit: *Facepalm* listen to Killer.
Reply
#3

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]));
Reply
#4

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.
Reply
#5

Thanks for all helps. I solved my problem ^^
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)