Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- This script has been made to basically "boost" the ZCMD command usage. It has been said many times that ZCMD is by far
- the most efficient command coding, so why doesn't it get used? Because nobody knows about it! This script will hopefully
- show you how to efficiently use ZCMD and get it to your likings, it's a piece of cake! Don't understand one of my explainations?
- Feel free to post on this topic, and I will explain it to you through the best of my ability.
- Have Fun,
- sizeof(Sky));
- */
- /* Includes */
- #include <a_samp>
- #include <zcmd>
- /* Color Defines */
- #define purple 0xC2A2DAAA
- #define grey 0xAFAFAFAA
- #define green 0x33AA33AA
- #define red 0xAA3333AA
- #define lightred 0xFF6347AA
- #define lb 0x33CCFFAA
- #define lg 0x9ACD32AA
- #define yellow 0xFFFF00AA
- #define yellow2 0xF5DEB3AA
- #define white 0xFFFFFFAA
- #define blue 0x4089BFFF
- main() //Basically what happens in the command prompt when you open up the samp-server.exe.
- {
- new year, month, day; //Make sure you ALWAYS define what you're trying to make into a string, or pawno will say, "What are you trying to do?" and have a bitch-fit.
- getdate(year, month, day); //getdate is actually a built-in function to SA:MP, I actually did not figure this out until I started experimenting (About 3 years in?)
- printf("[SERVER]: Server has been started. (%d-%d-%d)", month, day, year);
- /*^ Prints "[SERVER]: Server has been started. (MONTH-DAY-YEAR) into the console.
- Example: [SERVER]: Server has been started. (10-10-2009)*/
- }
- enum pInfo //This is just defining the variables for the Registration + Login System.
- {
- pKey[64],
- pAdmin,
- pReg
- };
- new gPlayerLogged[MAX_PLAYERS]; new threesectimer; new SInfo[MAX_PLAYERS][pInfo]; //SInfo is what I use in place of PlayerInfo, because 1: It's shorter, 2: It's my RL name that the prefix is, so i think it's pretty cool.
- new adminusers; //Just a little variable for my /serverstats command.
- forward Encrypt(string[]); //Password encryption, taken from Godfather because it's so useful. (Don't know where GF got it)
- forward OnPlayerLogin(playerid,password[]); //Just a quick forward for Public OnPlayerLogin(playerid, password[])
- forward OnPlayerRegister(playerid,password[]); //Just a quick forward for Public OnPlayerRegister(playerid, password[])
- forward ini_GetKey( line[] ); //Used to get the encrypted password, and to check if it cooresponds with the user-file.
- forward ini_GetValue( line[] );
- forward ThreeSecondTimer(); //Saves the files every three seconds compared to using OnPlayerUpdate. (Credits to oncedead)
- forward AChat(color,const string[],level); //Just a little Administrator Chat function, broadcasts it to every online administrator.
- public OnGameModeInit()
- {
- SetGameModeText("LSDM"); //Sets the GameModeText, kind of self-explainatory.
- AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0); //Edit these to your liking.
- threesectimer = SetTimer("ThreeSecondTimer", 3000, 1); //Starts the 3 second timer, make sure this is on here!
- UsePlayerPedAnims(); //Makes you run like CJ does in single player whilst being in a Ped-Skin. (Anti-Gay-Run, I like to call it)
- return 1;
- }
- /* Commands */
- zcmd(admins, playerid, params[]) //Just a simple /admins command, this will print the name of every single administrator online.
- {
- new admin[MAX_PLAYER_NAME], string[128];
- format(string, sizeof(string), ">> Administrative Users Online: (TOTAL: %d)", adminusers); //Just counts up every administrator that's logged in.
- SendClientMessage(playerid, blue, string);
- for(new i = 0; i < MAX_PLAYERS; i++) //This means it scans every player online for the variable "pAdmin" and checks if it equals 1 or more.
- {
- if(SInfo[i][pAdmin] >= 1)
- {
- GetPlayerName(i, admin, sizeof(admin));
- format(string, sizeof(string), "> %s [Level: %d]", admin, SInfo[i][pAdmin]);
- SendClientMessage(playerid, white, string); //If it does equal 1 or more, it sends a message with their name and Administrator Level.
- }
- }
- return 1;
- }
- zcmd(kick, playerid, params[]) //Simple command to just boot the selected player out of the server. (Basically /rcon kick)
- {
- new player, kicked[MAX_PLAYER_NAME], reason[128], administrator[MAX_PLAYER_NAME], string[128]; //All the variables you're going to need.
- if(!sscanf(params, "us", player, reason)) //U = User, S = String; Basically you have to think of it this way: First, think of the syntax.. Okay, /kick [Player ID/Part of Name] [Reason]
- { //You will be needing a user variable because you are going to kick via ID/Name; (/kick 3 will kick ID 3), You will need a String Variable for the reason, meaning it's going to print the message you send after it.
- if(player != INVALID_PLAYER_ID) //Checks to see if the user you entered is even online..
- {
- if(SInfo[playerid][pAdmin] >= 1) //After that check is done, and the user IS online, it will check if you are an Administrator.
- {
- GetPlayerName(player, kicked, sizeof(kicked));
- GetPlayerName(playerid, administrator, sizeof(administrator));
- format(string, sizeof(string), "%s has been kicked by Administrator %s, Reason: %s", kicked, administrator, reason);
- SendClientMessageToAll(red, string);
- printf("[ADMIN]: %s has been kicked by Administrator %s, Reason: %s", kicked, administrator, reason);
- Kick(player); //Here's all the things you need (well, you don't NEED a reason, but it's useful) to make a simple /kick command.
- }
- else return SendClientMessage(playerid, red, "[ERROR]: You are not an Administrator."); //If you're not an Administrator, it will send you this client message.
- }
- else return SendClientMessage(playerid, red, "[ERROR]: That user ID is not connected."); //If the user you entered IS an INVALID_PLAYER_ID, it will sends you this client message.
- }
- else return SendClientMessage(playerid, lg, "[USAGE]: /Kick [Player ID/Part of Name] [Reason]"); //If you entered the wrong syntax, it will send you this, telling you the exact syntax.
- return 1;
- }
- zcmd(ban, playerid, params[]) //Simple command to ban the selected player out of the server. (Basically /rcon ban)
- {
- new player, reason[128], administrator[MAX_PLAYER_NAME], banned[MAX_PLAYER_NAME], string[128];
- if(!sscanf(params, "us", player, reason))
- {
- if(player != INVALID_PLAYER_ID)
- {
- if(SInfo[playerid][pAdmin] >= 2)
- {
- GetPlayerName(player, banned, sizeof(banned));
- GetPlayerName(playerid, administrator, sizeof(administrator));
- format(string, sizeof(string), "%s has been banned by Administrator %s, Reason: %s", banned, administrator, reason);
- SendClientMessageToAll(red, string);
- printf(string);
- Ban(player);
- }
- else return SendClientMessage(playerid, red, "[ERROR]: You are not an Administrator.");
- }
- else return SendClientMessage(playerid, red, "[ERROR]: That user ID is not connected.");
- }
- else return SendClientMessage(playerid, lg, "[USAGE]: /Ban [Player ID/Part of Name] [Reason]");
- return 1;
- }
- zcmd(sethp, playerid, params[]) //This time we'll be doing a simple /sethp command, Syntax: /SetHP [Player ID/Part of Name] [Amount].. Okay!
- { //Now, we will be needing a user variable for the Player ID, and a Integer variable for the amount.
- new player, health, string[128], administrator[MAX_PLAYER_NAME];
- if(!sscanf(params, "ui", player, health)) //U = User, I = Integer
- {
- if(player != INVALID_PLAYER_ID) //Checks to see if the selected player is online.
- {
- if(SInfo[playerid][pAdmin] >= 1) //Checks to see if you're an Administrator.
- {
- GetPlayerName(playerid, administrator, sizeof(administrator));
- SetPlayerHealth(player, health);
- format(string, sizeof(string), "[ADMIN]: Player ID %d's HP has been set to %d by %s.", player, health, administrator);
- AChat(blue, string, 1); //Broadcasts a message to every administrator.
- printf(string);
- }
- else return SendClientMessage(playerid, red, "[ERROR]: You are not an Administator."); //If you're not an Administrator it will send you this client message.
- }
- else return SendClientMessage(playerid, red, "[ERROR]: That user ID is not connected."); //If you entered an INVALID_PLAYER_ID, it will send you this client message.
- }
- else return SendClientMessage(playerid, lg, "[USAGE]: /SetHP [Player ID/Part of Name] [Amount]"); //If you entered the wrong syntax, it will send you this, telling you the exact syntax.
- return 1; //Always include a return 1; after the syntax, or you will get "SERVER: Unknown Command."
- }
- zcmd(setarmor, playerid, params[]) //This time we'll be doing a simple /setarmor command, Syntax: /SetArmor [Player ID/Part of Name] [Amount]
- { //We'll need the same variables as /SetHP, just change health to armor (or leave it, doesn't matter), all we need to change is one line, and that is "SetPlayerHealth(player, health);", with this, just change it to "SetPlayerArmour(player, armor);
- new player, armor, string[128], administrator[MAX_PLAYER_NAME];
- if(!sscanf(params, "ui", player, armor))
- {
- if(player != INVALID_PLAYER_ID)
- {
- if(SInfo[playerid][pAdmin] >= 1)
- {
- GetPlayerName(playerid, administrator, sizeof(administrator));
- SetPlayerArmour(player, armor);
- format(string, sizeof(string), "[ADMIN]: Player ID %d's Armor has been set to %d by %s.", player, armor, administrator);
- AChat(blue, string, 1);
- printf(string);
- }
- else return SendClientMessage(playerid, red, "[ERROR]: You are not an Administator.");
- }
- else return SendClientMessage(playerid, red, "[ERROR]: That user ID is not connected.");
- }
- else return SendClientMessage(playerid, lg, "[USAGE]: /SetArmor [Player ID/Part of Name] [Amount]");
- return 1;
- }
- zcmd(a, playerid, params[])
- {
- new administrator[MAX_PLAYER_NAME], string[128],chat;
- if(!sscanf(params, "s", chat)) //With this we only need an "S" variable, which stands for string.. Syntax: /A [Chat]
- { //This means all you will need to do is Administrator-only broadcast a string, which is shown below.
- if(SInfo[playerid][pAdmin] >= 1)
- {
- GetPlayerName(playerid, administrator, sizeof(administrator));
- format(string, sizeof(string), "[Admin %s]: %s", administrator, chat);
- AChat(blue, string, 1); //Simple administrator chat.
- }
- else return SendClientMessage(playerid, red, "[ERROR]: You are not an Administrator.");
- }
- else return SendClientMessage(playerid, lg, "[USAGE]: /A [Chat]");
- return 1;
- }
- zcmd(veh, playerid, params[]) //This just spawns a vehicle, and apparently invalid vehicle ids don't crash the server now, so i'm not restricting it.
- {
- new vehicle, color1, color2, string[128];
- if(!sscanf(params, "iii", vehicle, color1, color2)) //You will need three integers because of the syntax, "/Veh [Vehicle ID] [Color 1] [Color 2]"
- {
- if(SInfo[playerid][pAdmin] >= 3) //Checks if you're an administrator level 3.
- {
- new Float:x, Float:y, Float:z;
- GetPlayerPos(playerid, x, y, z);
- CreateVehicle(vehicle, x, y, z, 0.0, color1, color2, 60000);
- format(string, sizeof(string), "[ADMIN]: You have spawned a Vehicle ID %d at your position.", vehicle);
- SendClientMessage(playerid, blue, string);
- }
- else return SendClientMessage(playerid, red, "[ERROR]: You are not an Administrator.");
- }
- else return SendClientMessage(playerid, lg, "[USAGE]: /Veh [Model ID] [Color 1] [Color 2]"); //Prints the syntax.
- return 1;
- }
- zcmd(wep, playerid, params[])
- {
- new player,gun,ammo;
- if(!sscanf(params, "uii", player,gun, ammo)) //With this, we're going to need a User, and two integers because of the syntax.. "/Wep [PLAYER ID] [WEAPON ID] [AMMO]"
- {
- if (SInfo[playerid][pAdmin] >= 3) //Checks if you're an administrator.
- {
- if(player != INVALID_PLAYER_ID)
- {
- new string[128];
- new name[MAX_PLAYER_NAME];
- GetPlayerName(player, name, sizeof(name));
- GivePlayerWeapon(player, gun, ammo);
- format(string, sizeof(string), "[ADMIN]: %s has given you a Weapon ID %d with %d Ammo.", name, gun, ammo);
- SendClientMessage(player, blue, string);
- }
- else
- {
- SendClientMessage(playerid, red, "[ERROR]: That user ID is not connected.");
- }
- }
- else
- {
- SendClientMessage(playerid, red, ">> Error: Unreliable User Permissions.");
- }
- }
- else
- {
- SendClientMessage(playerid, white, "[USAGE]: /Wep [Player ID/Part of Name] [Weapon ID] [Ammo]");
- SendClientMessage(playerid, yellow, "* HINT: Don't know the Weapon ID? Don't guess, type \"/wepids\"."); //Sends you a syntax message.
- }
- return 1;
- }
- zcmd(wepids, playerid, params[]) //Really simple command, since there's no user-input involved, we don't need sscanf.
- {
- if(SInfo[playerid][pAdmin] >= 3)
- {
- SendClientMessage(playerid, white, " ");
- SendClientMessage(playerid, white, " ");
- SendClientMessage(playerid, blue, " * LIST OF SUPPORTED WEAPON IDS, LAST UPDATE: OCTOBER 05, 2009 *");
- SendClientMessage(playerid, white, ">> 1: Brass Knuckles, 2: Golf Club, 3: Night Stick, 4: Knife, 5: Baseball Bat");
- SendClientMessage(playerid, white, ">> 6: Shovel, 7: Pool Cue, 8: Katana, 9: Chainsaw, 10: Dildo, 11: Short Vibrator");
- SendClientMessage(playerid, white, ">> 12: Long Vibrator, 13: White Dildo, 14: Flowers, 15: Cane, 16: Grenades, 17: Tear Gas");
- SendClientMessage(playerid, white, ">> 18: Molotov, 22: 9mm, 23: SDPistol, 24: Desert Eagle, 25: Pump Shotgun, 26: Sawn-off Shotgun");
- SendClientMessage(playerid, white, ">> 27: SPAS-12 Shotgun, 28: Mac 10, 29: MP5, 30: AK-47, 31: M4 Carbine, 32: Tec9, 33: Rifle");
- SendClientMessage(playerid, white, ">> 34: Sniper Rifle, 35: Rocket Launcher, 36: Heat Seeking Rocket Launcher, 37: Flame-Thrower");
- SendClientMessage(playerid, white, ">> 38: Minigun, 39: Satchel Charges, 41: Spray Can, 42: Fire Extinguisher, 43: Camera, 46: Parachute");
- }
- else return SendClientMessage(playerid, red, "[ERROR]: You are not an Administrator.");
- return 1;
- }
- zcmd(slap, playerid, params[]) //Just a simple /slap command.
- {
- new player, distance, Float:x, Float:y, Float:z, string[128], admin[MAX_PLAYER_NAME], user[MAX_PLAYER_NAME];
- if(!sscanf(params, "ui", player, distance)) //We will be needing a user and an integer, because of the syntax: /Slap [PLAYER ID] [DISTANCE]
- {
- if(SInfo[playerid][pAdmin] >= 1)
- {
- if(player != INVALID_PLAYER_ID)
- {
- if(distance <= 20) //Limits the distance to 20 feet, anything over 20 will print "You cannot slap the user above 20 feet."
- {
- GetPlayerName(playerid, admin, sizeof(admin));
- GetPlayerName(player, user, sizeof(user));
- GetPlayerPos(player, x, y, z);
- SetPlayerPos(player, x, y, z+distance);
- format(string, sizeof(string), "[ADMIN]: You have been slapped %d feet in the air by Administrator %s.", distance, admin);
- SendClientMessage(player, blue, string);
- format(string, sizeof(string), "[ADMIN]: Player \"%s\" has been slapped %d feet.", user, distance);
- SendClientMessage(playerid, blue, string);
- }
- else return SendClientMessage(playerid, red, "[ERROR]: You cannot slap the user above 20 feet.");
- }
- else return SendClientMessage(playerid, red, "[ERROR]: That user ID is not connected.");
- }
- else return SendClientMessage(playerid, red, "[ERROR]: You are not an Administrator.");
- }
- else return SendClientMessage(playerid, white, "[USAGE]: /Slap [Player ID/Part of Name] [Distance]");
- return 1;
- }
- zcmd(goto, playerid, params[]) //Sends you to the selected user.
- {
- new player, admin[MAX_PLAYER_NAME], user[MAX_PLAYER_NAME], Float:x, Float:y, Float:z, string[128];
- if(!sscanf(params, "u", player))
- {
- if(SInfo[playerid][pAdmin] >= 1)
- {
- if(player != INVALID_PLAYER_ID)
- {
- GetPlayerName(player, user, sizeof(user));
- GetPlayerName(playerid, admin, sizeof(admin));
- GetPlayerPos(player, x, y, z);
- SetPlayerPos(playerid, x+1, y, z);
- format(string, sizeof(string), "[ADMIN]: You have been teleported to %s.", user);
- SendClientMessage(playerid, blue, string);
- format(string, sizeof(string), "[ADMIN]: Administrator %s has teleported to you.", admin);
- SendClientMessage(player, blue, string);
- }
- else return SendClientMessage(playerid, red, "[ERROR]: That user ID is not connected.");
- }
- else return SendClientMessage(playerid, red, "[ERROR]: You are not an Administrator.");
- }
- else return SendClientMessage(playerid, lg, "[USAGE]: /Goto [Player ID/Part of Name]");
- return 1;
- }
- zcmd(gethere, playerid, params[]) //Sends the selected user to you.
- {
- new player, string[128], user[MAX_PLAYER_NAME], admin[MAX_PLAYER_NAME], Float:x, Float:y, Float:z;
- if(!sscanf(params, "u", player))
- {
- if(SInfo[playerid][pAdmin] >= 1)
- {
- if(player != INVALID_PLAYER_ID)
- {
- GetPlayerName(playerid, admin, sizeof(admin));
- GetPlayerName(player, user, sizeof(user));
- GetPlayerPos(playerid, x, y, z);
- SetPlayerPos(player, x+1, y, z);
- format(string, sizeof(string), "[ADMIN]: You have teleported %s to you.", user);
- SendClientMessage(playerid, blue, string);
- format(string, sizeof(string), "[ADMIN]: Administrator %s has teleported you to them.", admin);
- SendClientMessage(player, blue, string);
- }
- else return SendClientMessage(playerid, red, "[ERROR]: That user ID is not connected.");
- }
- else return SendClientMessage(playerid, red, "[ERROR]: You are not an Administrator.");
- }
- else return SendClientMessage(playerid, lg, "[USAGE]: /Gethere [Player ID/Part of Name]");
- return 1;
- }
- zcmd(makeadministrator, playerid, params[]) //Yet again, a simple USER + INTEGER.
- {
- new player, adminlevel, string[128], admin[MAX_PLAYER_NAME], user[MAX_PLAYER_NAME];
- if(!sscanf(params, "ui", player, adminlevel))
- {
- if(SInfo[playerid][pAdmin] >= 5)
- {
- if(player != INVALID_PLAYER_ID)
- {
- if(adminlevel <= 4)
- {
- GetPlayerName(playerid, admin, sizeof(admin));
- GetPlayerName(player, user, sizeof(user));
- SInfo[player][pAdmin] = adminlevel;
- format(string, sizeof(string), "[ADMIN]: Lead Administrator %s has given you Level %d Administrator.", admin, adminlevel);
- SendClientMessage(player, blue, string);
- format(string, sizeof(string), "[ADMIN]: You have made %s a Level %d Administrator.", user, adminlevel);
- SendClientMessage(playerid, blue, string);
- }
- else return SendClientMessage(playerid, red, "[ERROR]: You cannot use this command to make them a Lead Administrator.");
- }
- else return SendClientMessage(playerid, red, "[ERROR]: That user ID is not connected.");
- }
- else return SendClientMessage(playerid, red, "[ERROR]: You are not an Administrator");
- }
- else return SendClientMessage(playerid, lg, "[USAGE]: /MakeAdministrator [Player ID/Part of Name] [Administrator Level]");
- return 1;
- }
- public OnGameModeExit()
- {
- KillTimer(threesectimer); //When the gamemode exits, i don't think the accounts need to be saving, do you? :P
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746); //Change these around, it's default at the moment.
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- new string[50];
- gPlayerLogged[playerid] = 0;
- new plname[MAX_PLAYER_NAME];
- GetPlayerName(playerid, plname, sizeof(plname));
- format(string, sizeof(string), "LSDM/users/%s.ini", plname); //make sure to change this, and make the folder you wish to have the users in before-hand.
- if(fexist(string))
- {
- ShowPlayerDialog(playerid, 100, DIALOG_STYLE_INPUT, "Please login", "Type your password into the box and click \"Login\".", "Login", "Quit");
- }
- else
- {
- ShowPlayerDialog(playerid, 200, DIALOG_STYLE_INPUT, "Please register", "Type your password into the box and click \"Register\".", "Register", "Quit");
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid==100)
- {
- if(response == 0)
- {
- Kick(playerid);
- }
- if(response == 1)
- {
- if(strlen(inputtext)==0) return ShowPlayerDialog(playerid, 100, DIALOG_STYLE_INPUT, "Please login", "Type your password into the box and click \"Login\".", "Login", "Quit");
- Encrypt(inputtext);
- OnPlayerLogin(playerid,inputtext);
- }
- }
- if(dialogid==200)
- {
- if(response == 0)
- {
- Kick(playerid);
- }
- if(response == 1)
- {
- if(strlen(inputtext)==0) return ShowPlayerDialog(playerid, 200, DIALOG_STYLE_INPUT, "Please register", "Type your password into the box and click \"Register\".", "Register", "Quit");
- Encrypt(inputtext);
- OnPlayerRegister(playerid,inputtext);
- }
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- return 1;
- }
- public OnRconCommand(cmd[])
- {
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- return 1;
- }
- public AChat(color,const string[],level)
- {
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- if (SInfo[i][pAdmin] >= level)
- {
- SendClientMessage(i, color, string);
- }
- }
- }
- return 1;
- }
- public Encrypt(string[])
- {
- for(new x=0; x < strlen(string); x++)
- {
- string[x] += (3^x) * (x % 15);
- if(string[x] > (0xff))
- {
- string[x] -= 256;
- }
- }
- return 1;
- }
- ini_GetKey( line[] )
- {
- new keyRes[64];
- keyRes[0] = 0;
- if ( strfind( line , "=" , true ) == -1 ) return keyRes;
- strmid( keyRes , line , 0 , strfind( line , "=" , true ) , sizeof( keyRes) );
- return keyRes;
- }
- ini_GetValue( line[] )
- {
- new valRes[64];
- valRes[0]=0;
- if ( strfind( line , "=" , true ) == -1 ) return valRes;
- strmid( valRes , line , strfind( line , "=" , true )+1 , strlen( line ) , sizeof( valRes ) );
- return valRes;
- }
- public OnPlayerRegister(playerid, password[])
- {
- new string3[50];
- new playername3[MAX_PLAYER_NAME];
- GetPlayerName(playerid, playername3, sizeof(playername3));
- format(string3, sizeof(string3), "LSDM/users/%s.ini", playername3); //Change this aswell to the same as above.
- new File: hFile = fopen(string3, io_write);
- if (hFile)
- {
- strmid(SInfo[playerid][pKey], password, 0, strlen(password), 128);
- new var[32];
- format(var, 32, "Key=%s\n", SInfo[playerid][pKey]);fwrite(hFile, var);
- format(var, 32, "AdminLevel=%d\n",SInfo[playerid][pAdmin]);fwrite(hFile, var);
- format(var, 32, "Registered=%d\n",SInfo[playerid][pReg]);fwrite(hFile, var);
- fclose(hFile);
- ShowPlayerDialog(playerid, 100, DIALOG_STYLE_INPUT, "Please login", "Type your password into the box and click \"Login\".", "Login", "Login");
- }
- return 1;
- }
- public OnPlayerLogin(playerid,password[])
- {
- new string2[50];
- new playername2[MAX_PLAYER_NAME];
- GetPlayerName(playerid, playername2, sizeof(playername2));
- format(string2, sizeof(string2), "LSDM/users/%s.ini", playername2); //Change this too.
- new File: UserFile = fopen(string2, io_read);
- if ( UserFile )
- {
- new PassData[64];
- new keytmp[64], valtmp[64];
- fread( UserFile , PassData , sizeof( PassData ) );
- keytmp = ini_GetKey( PassData );
- if( strcmp( keytmp , "Key" , true ) == 0 )
- {
- valtmp = ini_GetValue( PassData );
- strmid(SInfo[playerid][pKey], valtmp, 0, strlen(valtmp)-1, 128);
- }
- if(strcmp(SInfo[playerid][pKey],password, true ) == 0 )
- {
- new key[64],val[64];
- new Data[64];
- while ( fread( UserFile , Data , sizeof( Data ) ) )
- {
- key = ini_GetKey( Data );
- if( strcmp( key , "AdminLevel" , true ) == 0 ) { val = ini_GetValue( Data ); SInfo[playerid][pAdmin] = strval( val ); }
- if( strcmp( key , "Registered" , true ) == 0 ) { val = ini_GetValue( Data ); SInfo[playerid][pReg] = strval( val ); }
- }
- fclose(UserFile);
- if(SInfo[playerid][pReg] == 0)
- {
- SInfo[playerid][pReg] = 1;
- }
- format(string2, sizeof(string2), "(System): Welcome to our server, %s!",playername2);
- SendClientMessage(playerid, lg,string2);
- printf("%s has logged in.",playername2);
- if (SInfo[playerid][pAdmin] > 0)
- {
- format(string2, sizeof(string2), "(System): You have been logged in as a Level %d Administrator.",SInfo[playerid][pAdmin]);
- SendClientMessage(playerid, lg,string2);
- adminusers++;
- }
- else{}
- gPlayerLogged[playerid] = 1;
- }
- else
- {
- fclose(UserFile);
- ShowPlayerDialog(playerid, 100, DIALOG_STYLE_INPUT, "Please login", "Type your password into the box and click \"Login\".", "Login", "Login");
- return 1;
- }
- }
- return 1;
- }
- public ThreeSecondTimer()
- {
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(gPlayerLogged[i])
- {
- new string3[50];
- new playername3[MAX_PLAYER_NAME];
- GetPlayerName(i, playername3, sizeof(playername3));
- format(string3, sizeof(string3), "LSDM/users/%s.ini", playername3); //Change this too x2.
- new File: hFile = fopen(string3, io_write);
- if (hFile)
- {
- new var[50];
- format(var, 32, "Key=%s\n", SInfo[i][pKey]);fwrite(hFile, var);
- format(var, 32, "AdminLevel=%d\n",SInfo[i][pAdmin]);fwrite(hFile, var);
- format(var, 32, "Registered=%d\n",SInfo[i][pReg]);fwrite(hFile, var);
- fclose(hFile);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement