Problem with enums. -
sobolanux - 02.09.2010
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
![Cheesy](images/smilies/biggrin.png)
)
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?
Re: Problem with enums. -
CyNiC - 02.09.2010
Try using MAX_PLAYER_NAME on the GetPlayerName.
Re: Problem with enums. -
mrcoolballs - 02.09.2010
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
};
Re: Problem with enums. -
sobolanux - 02.09.2010
None working
Re: Problem with enums. -
mrcoolballs - 02.09.2010
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
Re: Problem with enums. -
sobolanux - 02.09.2010
Alright. Thanks. Works now
![Smiley](images/smilies/smile.png)
. I can switch it to dialogs now