Problem with enums.
#1

Hi there. I am developind a new GM from scratch, and I have a little problem with enums (it`s true I haven`t scripting for a while )

Here`s the enum:

Код:
 enum pInfo
{
	pName[MAX_PLAYER_NAME],
	pKey[128],
	pSecKey[128],
	Float:pMoney,
	pScore,
	pLevel,
	pAdminLevel,
}
Here`s the command:

Код:
 dcmd_register(playerid, params[])
{
	new string[256];
(line 153)	GetPlayerName(playerid, pData[playerid][pName], sizeof(pData[playerid][pName]));
	sscanf(params, "s", pData[playerid][pKey]);
	format(string, sizeof(string),"/accounts/%s.ini", pData[playerid][pName]);
	if(dini_Exists(string))
	{
	    SendClientMessage(playerid, RED, "[ERROR]: Account already exists. Please log in!");
	    return 1;
 	}
	else
	{
	    if(!isnull(params))
	    {
	    	dini_Create(pData[playerid][pName]);
	    	dini_Set(string, "pName", pData[playerid][pName]);
	    	dini_Set(string, "pKey", pData[playerid][pKey]);
	    	dini_FloatSet(string, "pMoney", 0);
	    	dini_IntSet(string, "pScore", 0);
	    	dini_IntSet(string, "pAdminLevel", 0);
	    	dini_Unset(string, "pSecKey");
		}
		else SendClientMessage(playerid, RED, "The password field must not be empty!");
		return 1;
	}
	return 1;
}
And here are the errors :

Код:
 C:\Users\Anthony\Desktop\scripting\gamemodes\lvtdm.pwn(28) : warning 201: redefinition of constant/macro (symbol "CMD")
C:\Users\Anthony\Desktop\scripting\gamemodes\lvtdm.pwn(153) : error 001: expected token: "]", but found "-identifier-"
C:\Users\Anthony\Desktop\scripting\gamemodes\lvtdm.pwn(153) : warning 215: expression has no effect
C:\Users\Anthony\Desktop\scripting\gamemodes\lvtdm.pwn(153) : error 001: expected token: ";", but found "]"
C:\Users\Anthony\Desktop\scripting\gamemodes\lvtdm.pwn(153) : error 029: invalid expression, assumed zero
C:\Users\Anthony\Desktop\scripting\gamemodes\lvtdm.pwn(153) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Some help maybe?
Reply
#2

Try using MAX_PLAYER_NAME on the GetPlayerName.
Reply
#3

change this
pawn Код:
enum pInfo
{
    pName[MAX_PLAYER_NAME],
    pKey[128],
    pSecKey[128],
    Float:pMoney,
    pScore,
    pLevel,
    pAdminLevel,
}
to this
pawn Код:
enum pInfo
{
    pName[MAX_PLAYER_NAME],
    pKey[128],
    pSecKey[128],
    Float:pMoney,
    pScore,
    pLevel,
    pAdminLevel
};
Reply
#4

None working
Reply
#5

pawn Код:
dcmd_register(playerid, params[])
{
    new string[256], pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pname,sizeof(pname));
    sscanf(params, "s", pData[playerid][pKey]);
    format(string, sizeof(string),"/accounts/%s.ini", pname);
    if(dini_Exists(string))
    {
        SendClientMessage(playerid, RED, "[ERROR]: Account already exists. Please log in!");
        return 1;
    }
    else
    {
        if(!isnull(params))
        {
            dini_Create(string);
            dini_Set(string, "pName", pname
            dini_Set(string, "pKey", pData[playerid][pKey]);
            dini_FloatSet(string, "pMoney", 0);
            dini_IntSet(string, "pScore", 0);
            dini_IntSet(string, "pAdminLevel", 0);
            dini_Unset(string, "pSecKey");
        }
        else SendClientMessage(playerid, RED, "The password field must not be empty!");
        return 1;
    }
    return 1;
}
try that, i just removed the pData[playerid][pName] it should work, also you where creating the wrong file on dini_Create, i changed that to string
Reply
#6

Alright. Thanks. Works now . I can switch it to dialogs now
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)