hi all im new at programming so i dont know how to be admin in any server help pls :( :(
learn squirrel
code
code x2
look wiki
search scrripts
????
profit
Quote from: Kewun on Feb 06, 2017, 01:50 PMlearn squirrel
code
code x2
look wiki
search scrripts
????
profit
Kindly don't post shit like this again.
@ahmedzead, To be admin in your server you firstly need a
Account system. There are some released ones in the Released scripts section so you can try to look for it.
i was trying to help. i didnt post shit like you do
Quote from: Kewun on Feb 06, 2017, 03:52 PMi was trying to help. i didnt post shit like you do
Summoning
@Shadow
Quote from: Kewun on Feb 06, 2017, 03:52 PMi was trying to help. i didnt post shit like you do
Omg...
the truth is that kewun was always right
The truth is you registered today and have no idea about this forum. (or you're kewun)
SIMPLE CODE FOR ADMIN XD
if ( cmd == "YOUR CMD" )
{
if ( player.Name == "YOUR NAME FOR ACESS THE COMMAND" )
{
The function () // The command
}
} else MessagePlayer( "YOU NO ARE ADMIN", player );
For more security on your server you can change the player.Name to
player.UniqueID , player.IP , player.UniqueID2 , or create one data base XD
player.Admin = true;
you can use your uid instead making account system, maybe someone able to change his uid to your one and 'hack' your server, but i think nobody will do that.
Quote from: iReaL on Feb 10, 2017, 01:39 AMSIMPLE CODE FOR ADMIN XD
if ( cmd == "YOUR CMD" )
{
if ( player.Name == "YOUR NAME FOR ACESS THE COMMAND" )
{
The function () // The command
}
} else MessagePlayer( "YOU NO ARE ADMIN", player );
For more security on your server you can change the player.Name to
player.UniqueID , player.IP , player.UniqueID2 , or create one data base XD
So if I join with your name. Does that make me an admin on your server?
And also, how primitive that can be. If I want to use a different nickname, I have to search and edit the scripts and reboot the server.
This is the worst of the worst of the worst examples that could be given for something like this.
Quote from: jWeb on Feb 10, 2017, 02:20 PMQuote from: iReaL on Feb 10, 2017, 01:39 AMSIMPLE CODE FOR ADMIN XD
if ( cmd == "YOUR CMD" )
{
if ( player.Name == "YOUR NAME FOR ACESS THE COMMAND" )
{
The function () // The command
}
} else MessagePlayer( "YOU NO ARE ADMIN", player );
For more security on your server you can change the player.Name to
player.UniqueID , player.IP , player.UniqueID2 , or create one data base XD
So if I join with your name. Does that make me an admin on your server?
And also, how primitive that can be. If I want to use a different nickname, I have to search and edit the scripts and reboot the server.
This is the worst of the worst of the worst examples that could be given for something like this.
Not the worst, the worst would be if the admin needs a level ()
I said that it can become more secure with the .uniqueID, .IP, and other commands.
Quote from: iReaL on Feb 10, 2017, 03:11 PMNot the worst, the worst would be if the admin needs a level ()
I said that it can become more secure with the .uniqueID, .IP, and other commands.
That implies you have a static IP address. And most people don't. As for the UID. Well, that can be stolen and replicated. Thus exposing you even further.
Quote from: jWeb on Feb 10, 2017, 03:58 PMAs for the UID. Well, that can be stolen and replicated.
Nobody will do that. Even if he will set password 123456 nobody will hack it. It's vcmp.
Quote from: vito on Feb 10, 2017, 04:56 PMQuote from: jWeb on Feb 10, 2017, 03:58 PMAs for the UID. Well, that can be stolen and replicated.
Nobody will do that. Even if he will set password 123456 nobody will hack it. It's vcmp.
Yes...
Here you go. The simplest admin implementation I can think of. It uses a .txt file to store and load administrators based on their nicks. Uses a table with name->password as the key->value pair to represent the list of admins and be efficient when searching.
Load/save functions:
// ============================================================================
function LoadAdmins(filepath) {
local f = file(filepath, "rb+"), t = {};
while (f.eos() == null) {
local name = "", pass = "", c = 0;
for (c = f.readn('c'); c != '|' && f.eos() == null; c = f.readn('c')) {
name += format("%c", c);
}
if (f.eos() != null) break;
for (c = f.readn('c'); c != '\n' && f.eos() == null; c = f.readn('c')) {
pass += format("%c", c);
}
if (f.eos() != null && c != '\n' && c != '\r') pass += format("%c", c);
name = strip(name), pass = strip(pass);
if (name.len() > 0 && pass.len() > 0) t.rawset(name, pass);
}
return t;
}
function SaveAdmins(adminlist, filepath) {
local f = file(filepath, "wb+");
foreach (name, pass in adminlist) {
name = strip(name), pass = strip(pass);
foreach (c in name) f.writen(c, 'c');
f.writen('|', 'c');
foreach (c in pass) f.writen(c, 'c');
f.writen('\n', 'c');
}
}
Helper functions:
// ============================================================================
function EncryptPassword(password) {
return password; // INSERT YOUR HASHING METHOD HERE! ex: SHA256(password);
}
function AdminCheck(player) {
if (player.IsAdmin == true) return true;
MessagePlayer("You do not have the privilege to perform this action!", player);
return false;
}
NOTE: I would suggest using the Hashing plugin to encrypt the passwords by updating the EncryptPassword() function accordingly. But that's your choice.
Load and save admins:
// ============================================================================
function onServerStart() {
g_AdminList <- LoadAdmins("adminlist.txt");
}
function onServerStop() {
SaveAdmins(g_AdminList, "adminlist.txt");
}
NOTE: Make sure you have a "adminlist.txt" file in the server folder.
And 3 simple commands to manage them:
// ============================================================================
function onPlayerCommand(player, cmd, args) {
args = strip(args);
switch (cmd) {
// ====================================================================
case "getadmin": {
if (player.IsAdmin == true) MessagePlayer("You are already an administrator", player);
else if (args.len() <= 0) {
MessagePlayer("Syntax: cmd <password>", player);
return;
}
else if (g_AdminList.rawin(player.Name)) {
local pass = g_AdminList.rawget(player.Name), args = EncryptPassword(args);
if (pass != args)
MessagePlayer("Wrong administrator password", player);
else {
player.IsAdmin = true;
MessagePlayer("You are now recognized as administrator", player);
}
}
} break;
// ====================================================================
case "setadmin": {
if (!AdminCheck(player)) return;
else if (args.len() <= 0) {
MessagePlayer("Syntax: cmd <player_id> <password>", player);
return;
}
local sep = args.find(" ");
if (sep == null) {
MessagePlayer("Syntax: cmd <player_id> <password>", player);
return;
}
local player_id = null;
try {
player_id = args.slice(0, sep).tointeger();
} catch (e) {
MessagePlayer("Invalid player id", player);
return;
}
local admin = FindPlayer(player_id)
if (admin == null) {
MessagePlayer("No such player on the server", player);
return;
}
local password = null;
try {
password = strip(args.slice(sep + 1).tostring());
} catch(e) {
MessagePlayer("Invalid or missing password", player);
return;
}
if (password.len() <= 0) {
MessagePlayer("Invalid or empty password", player);
return;
}
g_AdminList.rawset(admin.Name, EncryptPassword(password));
admin.IsAdmin = true;
MessagePlayer("Successfully included (" + admin.Name + ") into administrators", player);
} break;
// ====================================================================
case "unsetadmin": {
if (!AdminCheck(player)) return;
else if (args.len() <= 0) {
MessagePlayer("Syntax: cmd <admin_name>", player);
return;
} else if (g_AdminList.rawin(args)) {
g_AdminList.rawdelete(args);
local admin = FindPlayer(args);
if (admin != null) admin.IsAdmin = false;
MessagePlayer("Successfully excluded (" + admin.Name + ") from administrators", player);
} else MessagePlayer("No administrator named (" + args + ")", player);
} break;
}
}
When a player switches to admin mode. It simple sets the player.IsAdmin property to true. So if (player.IsAdmin == true) then that player is an admin. Other wise it's just a regular player.
I'm not sure how you can get more simple than this.
@jweb I think You dont know he is totally new thats why no one geting interest in it Wait for hiss Next error
:D
Quote from: vito on Feb 10, 2017, 04:56 PMQuote from: jWeb on Feb 10, 2017, 03:58 PMAs for the UID. Well, that can be stolen and replicated.
Nobody will do that. Even if he will set password 123456 nobody will hack it. It's vcmp.
I wouldnt count on it.
/