02.05.2009, 07:57
Hello there!
I tried to make a simple /register and /login script with dini.
Here's the script:
The error says that params and pw should be indexed. Since the password is a string, I can't index it to a specific character. This may be too obvious, but I'm a newb. So please help 
Thanks!
EDIT: Btw the register part works just fine. When I read the file, the password is set correctly.
I tried to make a simple /register and /login script with dini.
Here's the script:
Код:
public OnPlayerCommandText(playerid, cmdtext[]) { dcmd(register, 8, cmdtext); dcmd(login, 5, cmdtext); return 1; } dcmd_register(playerid, params[]) { if (dini_Exists(gPlayerfile[playerid])) { SendClientMessage(playerid, 0xFF0000FF, "You have already registered."); return 0; } else { if (!params[0]) { SendClientMessage(playerid, 0xFF0000FF, "Usage: /register <password>"); return 0; } else { dini_Create(gPlayerfile[playerid]); dini_Set(gPlayerfile[playerid], "Password", params); SendClientMessage(playerid, 0x00FF00FF, "You have successfully registered. Proceed to login thanks."); return 1; } } } dcmd_login(playerid, params[]) { if (!dini_Exists(gPlayerfile[playerid])) { SendClientMessage(playerid, 0xFF0000FF, "You have not registered."); return 0; } else if (gPlayerlogged[playerid]) { SendClientMessage(playerid, 0x00FF00FF, "You have already logged in."); return 0; } else { new pw[1000]; pw = dini_Get(gPlayerfile[playerid], "Password"); if (params == pw) // THIS LINE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< { gPlayerlogged[playerid] = 1; SendClientMessage(playerid, 0x00FF00FF, "Login successful."); return 1; } else { SendClientMessage(playerid, 0xFF0000FF, "Wrong password."); return 0; } } }

Thanks!
EDIT: Btw the register part works just fine. When I read the file, the password is set correctly.