Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ___
- | . \ _ _ ___ ___ ___ _ _ ___ ___ ___ ___ ___ ___ _ _
- | _/| '_>/ ._>|___|| . \| '_>/ . \/ | '/ ._><_-<<_-</ . \| '_>
- |_| |_| \___. | _/|_| \___/\_|_.\___./__//__/\___/|_|
- |_|
- _ _ _
- _| |_ | |_ <_>._ _ ___ ___
- | | | . || || ' |/ . |<_-<
- |_| |_|_||_||_|_|\_. |/__/
- <___'
- */
- /*--------------------------------------Librarys--------------------------------------------*/
- #include <a_samp>
- #include <djson>
- #include <dutils>
- /*--------------------------------------Macros----------------------------------------------*/
- #define DIALOG_REGISTER 0
- #define DIALOG_LOGIN 1
- #define DIALOG_ADMIN_MENU 2
- #define DIALOG_ADMIN_SET 4
- #define DIALOG_BAN_CONFIRM 5
- #define DIALOG_DEL_ACCOUNT_CONFIRM 6
- #define DIALOG_DEL_ACCOUNT_DONE 7
- #define DIALOG_UNBAN_INPUT 8
- #define DIALOG_UNBAN_DONE 9
- #define MEMBER 0
- #define MODO 1
- #define ADMIN 2
- #define COLOR_YELLOW 0xFFD200FF
- /*
- _____ _ _ _ _ _ _
- | __ \ | | | | | | | | | (_)
- | | \/ | ___ | |__ __ _| | | |_| |__ _ _ __ __ _ ___
- | | __| |/ _ \| '_ \ / _` | | | __| '_ \| | '_ \ / _` / __|
- | |_\ \ | (_) | |_) | (_| | | | |_| | | | | | | | (_| \__ \
- \____/_|\___/|_.__/ \__,_|_| \__|_| |_|_|_| |_|\__, |___/
- __/ |
- |___/
- */
- /*--------------------------------------Variables------------------------------------*/
- new gMaxPlayersConnected;
- /*--------------------------------------Enumerations---------------------------------*/
- enum E_PLAYERINFO
- {
- logued,
- staffRank,
- playerClicked
- }
- /*--------------------------------------Arrays---------------------------------------*/
- new pInfo[MAX_PLAYERS][E_PLAYERINFO];
- /*
- ______ _ _
- | ___| | | (_)
- | |_ _ _ _ __ ___ | |_ _ ___ _ __ ___
- | _|| | | || '_ \ / __|| __|| | / _ \ | '_ \ / __|
- | | | |_| || | | || (__ | |_ | || (_) || | | |\__ \
- \_| \__,_||_| |_| \___| \__||_| \___/ |_| |_||___/
- _____ _ _
- |_ _|| | (_)
- | | | |__ _ _ __ __ _ ___
- | | | '_ \ | || '_ \ / _` |/ __|
- | | | | | || || | | || (_| |\__ \
- \_/ |_| |_||_||_| |_| \__, ||___/
- __/ |
- |___/
- */
- /*--------------------------------------------Functions-------------------------------------*/
- stock strs(string1[], string2[])//Strings Sames (strs)
- {
- if(!strcmp(string1, string2) && strlen(string1) == strlen(string2) && strlen(string1) > 1)
- {return true;}
- else
- {return false; }
- }
- stock GivePlayerName(playerid)//Return the name of the given playerid
- {
- new pName[MAX_PLAYER_NAME+1];
- GetPlayerName(playerid, pName, sizeof(pName));
- return pName;
- }
- stock GetPlayerAccountFile(playerid)//Return the user file path
- {
- new pName[MAX_PLAYER_NAME+1], filePath[50];
- pName = GivePlayerName(playerid);
- format(filePath, sizeof(filePath), "/Accounts/%s.json", pName);
- return filePath;
- }
- stock IsPlayerRegistered(playerid)
- {
- if(fexist(GetPlayerAccountFile(playerid))) { return true; }//If the user-file for the nick exists
- else{ return false; }
- }
- stock RemovePlayerAccount(playerid)
- {
- if(IsPlayerRegistered(playerid)) { djRemoveFile(GetPlayerAccountFile(playerid)); }
- }
- stock TryLogin(playerid, string[])//Return: 0 if sucefully logued in; 1 if password is bad; 2 if user is not registered
- {
- if(IsPlayerRegistered(playerid))
- {
- new password[MAX_STRING];
- password = dj(GetPlayerAccountFile(playerid), "GlobalInfo/Password");
- if(strs(hash(string), password))
- { pInfo[playerid][logued] = true; LoadPlayerData(playerid); return 0; }
- else
- { return 1; }
- }
- else
- { return 2; }
- }
- stock Register(playerid, password[], bool:force)
- {
- if(force)
- {
- RemovePlayerAccount(playerid);
- pInfo[playerid][logued] = false;
- pInfo[playerid][staffRank] = MEMBER;
- Register(playerid, password, false);
- return true;
- }
- else if(!IsPlayerRegistered(playerid))
- {
- new pName[MAX_PLAYER_NAME+1], filePath[50];
- pName = GivePlayerName(playerid);
- filePath = GetPlayerAccountFile(playerid);
- djCreateFile(filePath);
- djSet(filePath, "GlobalInfo/password", hash(password));
- return true;
- }
- else
- { return false; }
- }
- stock GetAdminRank(playerid)
- {
- if(IsPlayerRegistered(playerid))
- { return pInfo[playerid][staffRank]; }
- else
- { return -1; }
- }
- stock IsPlayerLoguedIn(playerid)
- {
- if(pInfo[playerid][logued])
- { return true; }
- else
- { return false; }
- }
- stock SetPlayerAdmin(playerid, rank)
- {
- if(IsPlayerLoguedIn(playerid))
- { pInfo[playerid][staffRank] = rank; }
- }
- stock IsPlayerBanned(playerid)
- {
- if(djInt(GetPlayerAccountFile(playerid), "Moderation/ban"))
- { return true;}
- else
- { return false; }
- }
- stock LoadPlayerData(playerid)
- {
- if(IsPlayerLoguedIn(playerid))
- {
- new filePath[50];
- filePath = GetPlayerAccountFile(playerid);
- pInfo[playerid][staffRank] = djInt(filePath, "GlobalInfo/staffRank");
- }
- }
- stock SavePlayerData(playerid)
- {
- if(IsPlayerLoguedIn(playerid))
- {
- new filePath[50];
- filePath = GetPlayerAccountFile(playerid);
- djSetInt(filePath, "GlobalInfo/staffRank", pInfo[playerid][staffRank]);
- }
- }
- stock IsPlayerNearPlayer(player, playerpoint)
- {
- new Float:x, Float:y, Float:z;
- GetPlayerPos(playerpoint, x, y, z);
- if(IsPlayerInRangeOfPoint(player, 10.0, x, y, z))
- { return true;}
- else
- { return false; }
- }
- stock SpeakToNearPlayers(playerid, message[])
- {
- for(new i = 0; i < gMaxPlayersConnected; i++)
- {
- if(IsPlayerNearPlayer(playerid, i))
- { SendPlayerMessageToPlayer(i, playerid, message); }
- }
- }
- /*--------------------------------------------Forwards--------------------------------------*/
- /*
- _____ _ _ _ _
- / __ \ | || || | | |
- | / \/ __ _ | || || |__ __ _ ___ | | __ ___
- | | / _` || || || '_ \ / _` | / __|| |/ // __|
- | \__/\| (_| || || || |_) || (_| || (__ | < \__ \
- \____/ \__,_||_||_||_.__/ \__,_| \___||_|\_\|___/
- */
- main()
- {
- print("\n----------------------------------");
- print(" Basic GM by Jujuv");
- print("----------------------------------\n");
- }
- public OnGameModeInit()
- {
- djson_GameModeInit();
- djAutocommit(true);
- SetGameModeText("Blank Script");
- AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- return 1;
- }
- public OnGameModeExit()
- {
- djson_GameModeExit();
- 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);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- if(gMaxPlayersConnected < playerid)
- { gMaxPlayersConnected = playerid; }
- if(IsPlayerRegistered(playerid))
- { ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Please register", "Good to see you back, bro' !\n Enter your password to log-in and HAVE FUN !", "Ok", "Cancel (Kick"); }
- else
- { ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Please register", "Hello !\n Your account isn't registered yet but we will fix it right now !\n Choose a password for your new account", "Ok", "Cancel (Kick)"); }
- if(IsPlayerBanned(playerid))
- { Kick(playerid); }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- SavePlayerData(playerid);
- if(playerid == gMaxPlayersConnected)
- {
- for(new i = gMaxPlayersConnected-1; i >= 0; i--)
- {
- if(IsPlayerConnected(i))
- {gMaxPlayersConnected = i; break;}
- }
- }
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- SpeakToNearPlayers(playerid, text);
- return 0;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerEnterRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnRconCommand(cmd[])
- {
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- return 1;
- }
- public OnPlayerObjectMoved(playerid, objectid)
- {
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- return 1;
- }
- public OnVehicleMod(playerid, vehicleid, componentid)
- {
- return 1;
- }
- public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
- {
- return 1;
- }
- public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
- {
- return 1;
- }
- public OnVehicleRespray(playerid, vehicleid, color1, color2)
- {
- return 1;
- }
- public OnPlayerSelectedMenuRow(playerid, row)
- {
- return 1;
- }
- public OnPlayerExitedMenu(playerid)
- {
- return 1;
- }
- public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
- {
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- return 1;
- }
- public OnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat)
- {
- return 1;
- }
- public OnVehicleDamageStatusUpdate(vehicleid, playerid)
- {
- return 1;
- }
- public OnRconLoginAttempt(ip[], password[], success)
- {
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- return 1;
- }
- public OnPlayerStreamIn(playerid, forplayerid)
- {
- return 1;
- }
- public OnPlayerStreamOut(playerid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamIn(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamOut(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch(dialogid)
- {
- case DIALOG_REGISTER:
- {
- if(!response)
- { Kick(playerid); }
- else if(strlen(inputtext) >= 7 && strlen(inputtext) <= 24)
- { Register(playerid, inputtext, false); ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Please register", "You must enter your password to enjoy the server!\n The one you entered is bad\n Please enter your password", "Ok", "Cancel (Kick)");}
- else
- { ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Please register", "Your password is too short or too long (min 6; max 24)", "Ok", "Cancel (Kick)"); }
- }
- case DIALOG_LOGIN:
- {
- if(!response)
- { Kick(playerid); }
- else
- {
- new anwser = TryLogin(playerid, inputtext);
- if(anwser == 1)
- { ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Please register", "You must enter your password to enjoy the server!\n The one you entered is bad\n Please enter your password", "Ok", "Cancel (Kick)"); }
- }
- }
- case DIALOG_ADMIN_MENU://Copy-Paste from another of my OWNS public scripts !
- {
- switch(listitem)
- {
- case 0://Set admin
- {
- if((GetAdminRank(playerid) >= ADMIN && GetAdminRank(pInfo[playerid][playerClicked]) < ADMIN) || IsPlayerAdmin(playerid))
- {
- ShowPlayerDialog(playerid, DIALOG_ADMIN_SET, DIALOG_STYLE_LIST, "Choisisez:", "Membre\r\nModerateur\r\nAdministrateur\r\n", "Valider", "Annuler");
- }
- }
- case 1://Kick
- {
- if(GetAdminRank(pInfo[playerid][playerClicked]) == MEMBER)
- {
- new msg[MAX_STRING];
- format(msg, sizeof(msg), "[Moderation]%s has been kicked from the server", GivePlayerName(playerid));
- SendClientMessageToAll(COLOR_YELLOW, msg);
- Kick(pInfo[playerid][playerClicked]);
- }
- }
- case 2://Ban
- {
- if(GetAdminRank(pInfo[playerid][playerClicked]) == MEMBER)
- {
- ShowPlayerDialog(playerid, DIALOG_BAN_CONFIRM, DIALOG_STYLE_MSGBOX, "Confirmation", "Are you sure ?", "Yes", "No");
- }
- }
- case 3://Remove player account
- {
- ShowPlayerDialog(playerid, DIALOG_DEL_ACCOUNT_CONFIRM, DIALOG_STYLE_MSGBOX, "Confirmation", "EAre you sure ?", "Yes", "No");
- }
- case 4://TP
- {
- new Float:x, Float:y, Float:z;
- GetPlayerPos(pInfo[playerid][playerClicked], x, y, z);
- SetPlayerPosFindZ(playerid, x+random(20), y+random(20), z);
- }
- case 5://Spec
- {
- if(IsPlayerLoguedIn(pInfo[playerid][playerClicked]))
- {
- if(playerid == pInfo[playerid][playerClicked])
- {
- TogglePlayerSpectating(playerid, 0);
- }
- else
- {
- TogglePlayerSpectating(playerid, 1);
- PlayerSpectatePlayer(playerid, pInfo[playerid][playerClicked]);
- }
- }
- }
- }
- }
- case DIALOG_ADMIN_SET:
- {
- switch(listitem)
- {
- case 0://member
- {
- SetPlayerAdmin(pInfo[playerid][playerClicked], MEMBER);
- }
- case 1://modo
- {
- SetPlayerAdmin(pInfo[playerid][playerClicked], MODO);
- }
- case 2://admin
- {
- SetPlayerAdmin(pInfo[playerid][playerClicked], ADMIN);
- }
- }
- }
- case DIALOG_BAN_CONFIRM:
- {
- if(response)
- {
- new msg[MAX_STRING];
- format(msg, sizeof(msg), "[Moderation] %s has been banned from the server", GivePlayerName(pInfo[playerid][playerClicked]));
- djSetInt(GetPlayerAccountFile(pInfo[playerid][playerClicked]),"Moderation/ban", 1);
- SendClientMessageToAll(COLOR_YELLOW, msg);
- Kick(playerid);
- }
- }
- case DIALOG_DEL_ACCOUNT_CONFIRM:
- {
- if(response && !GetAdminRank(pInfo[playerid][playerClicked]))
- {
- RemovePlayerAccount(pInfo[playerid][playerClicked]);
- if(IsPlayerConnected(pInfo[playerid][playerClicked]))
- { Kick(pInfo[playerid][playerClicked]); }
- ShowPlayerDialog(playerid, DIALOG_DEL_ACCOUNT_DONE, DIALOG_STYLE_MSGBOX, "Done", "Account sucefully removed", "Ok", "");
- }
- }
- case DIALOG_UNBAN_INPUT:
- {
- if(response)
- {
- new filePath[50];
- format(filePath, sizeof(filePath), "/Accounts/%s.json", inputtext);
- if(fexist(filePath))
- {
- if(djInt(filePath, "Moderation/ban"))
- { djSetInt(filePath, "Moderation/ban", 0); SendClientMessage(playerid, COLOR_YELLOW, "Player has been sucefully unbanned"); }
- else
- { SendClientMessage(playerid, COLOR_YELLOW, "This player isn't banned"); }
- }
- else
- { SendClientMessage(playerid, COLOR_YELLOW, "This username isn't registered"); }
- }
- }
- }
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- pInfo[playerid][playerClicked] = clickedplayerid;
- if(GetAdminRank(playerid) > MEMBER)
- { ShowPlayerDialog(playerid, DIALOG_ADMIN_MENU, DIALOG_STYLE_LIST, "Administration", "Set Admin\r\nKick\r\nBan\r\nRempve Account\r\nTeleport to player\r\nSpec player\r\n", "Ok", "Cancel"); }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (!strcmp("/unban", cmdtext, true, 10))
- {
- if(GetAdminRank(playerid) == ADMIN)
- { ShowPlayerDialog(playerid, DIALOG_UNBAN_INPUT, DIALOG_STYLE_INPUT, "Unban", "Enter the name of the player wich you want to unban", "Unban", "Cancel"); }
- else
- { SendClientMessage(playerid, COLOR_YELLOW, "You must be an andmin to do that"); }
- return 1;
- }
- return 0;
- }
- public OnEnterExitModShop(playerid, enterexit, interiorid)
- {
- return 1;
- }
- public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
- {
- return 1;
- }
- public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
- {
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement