27.01.2016, 01:02
Or, if you wanted to, you could also assign random numbers and characters and save them.
Add pCode, and pUsedCode (or whatever) inside of your PlayerInfo enum, and add it to saving it, and loading it. as a string. All you have to do is work out the login command and/or dialog.
You can do it however you like, but that's similar how I would do it.
PHP код:
CMD:makeadmin(playerid, params[])
{
new id, string[128], level, code[5];
randomString(code, 5);
if(PlayerInfo[playerid][pAdmin] < 7)
return SendClientMessage(playerid, COLOR_BLUE, "You don't have acces to that command.");
if(sscanf(params, "ii", id, level))
return SendClientMessage(playerid, COLOR_RED, "SERVER: /makeadmin [ID] [LEVEL]");
//ShowPlayerDialog(id,DIALOG_ADMINBOX,DIALOG_STYLE_MSGBOX, "You are an admin", string, "Ok", "");
format(string, sizeof(string), "%s promoted you to level %i.", PlayerName(playerid), level);
SendClientMessage(id, COLOR_BLUE, string);
PlayerInfo[id][pAdmin] = level;
PlayerInfo[id][pCode] = code; // Assigns the random 5 character code to the player variable
return 1;
}
PlayerName(playerid)
{
new name[21];
GetPlayerName(playerid, name, sizeof(name));
return name;
}
randomString(strDest[], strLen = 10) // ( https://sampforum.blast.hk/showthread.ph...pid1349155 )
{
while(strLen--)
strDest[strLen] = random(2) ? (random(26) + (random(2) ? 'a' : 'A')) : (random(10) + '0');
}
/*
And inside of admin commands you can do shit like
if(!PlayerInfo[playerid][pUsedCode]) return Errormessage..
*/
You can do it however you like, but that's similar how I would do it.