#include <dini>
enum pInfo
{
logged,
admin
}
new PlayerInfo[MAX_PLAYERS][pInfo];
if(strcmp("/register", cmdtext, true, 9) == 0)
{
new pname[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "accounts/%s.acc", pname); //format "string" as where you save the account too
//this isn't nessessary but it makes life easyer.
if(PlayerInfo[playerid][logged] == 1) return SendClientMessage(playerid, red, "You are already logged in");
if(dini_Exists(string) == 1) return SendClientMessage(playerid, red, "Your account is registered, please /login"); // account already exists
if(strlen(cmdtext[10]) == 0) return SendClientMessage(playerid, red, "Usage: /register [password]");
if(strlen(cmdtext[12]) == 0) return SendClientMessage(playerid, red, "Your password is not long enough"); // their pass must be more then 2 chars
dini_Create(string); // create their account
dini_Set(string, "password", cmdtext[10]); // put their pass in it
dini_IntSet(string, "admin", 0); // create an admin level variable
format(string, sizeof(string), "Welcome %s, you may now /login", pname);
SendClientMessage(playerid, yellow, string);
return 1;
}
if(strcmp("/login", cmdtext, true, 6) == 0)
{
new pname[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "accounts//%s.acc", pname);
if(PlayerInfo[playerid][logged] == 1) return SendClientMessage(playerid, red, "You are already logged in");
if(dini_Exists(string) == 0) return SendClientMessage(playerid, red, "You do not have an account, please /register"); // their account (file with their name) does not exist
if(strlen(cmdtext[7]) == 0) return SendClientMessage(playerid, red, "Usage: /login [password]");
if(strcmp(dini_Get(string, "password"), cmdtext[7], true) != 0) return SendClientMessage(playerid, red, "Passwords did not match"); // pass they entered and pass in the file
PlayerInfo[playerid][logged] = 1;
PlayerInfo[playerid][admin] = dini_Int(string, "admin");
return 1;
}
if(strcmp("/kick", cmdtext, true, 5) == 0)
{
new pname[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "accounts//%s.acc", pname);
if(dini_Int(string, "admin") != 1) return SendClientMessage(playerid, red, "You are not a level 1 admin!"); // they where not level 1
// include more checks to see if they're connected and all that
Kick(strval(cmdtext[5])); // kick them
//tell everyone they're kicked
return 1;
}
strval
new string[128];
0123456789
string = "hello 11aa".
Originally Posted by Shady91
wow you must of sent ages making that post lol as when you go over like a certian ammount of letters in post box it sticks to the top so you cant see what your typing lol
|
Originally Posted by [B
Vortex ]
Btw, I cant find anything on enums |
enum pInfo
{
AdminLevel,
Level,
};
new AInfo[MAX_PLAYERS][pInfo];
Originally Posted by JaTochNietDan
Quote:
pawn Код:
Yes but he told me if I don't understand to look it up. |
AInfo[playerid][AdminLevel] = 1;
Originally Posted by JaTochNietDan
With the enum I provided you with, you could do things like
pawn Код:
|