Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define FILTERSCRIPT
- /* Includes */
- #include <a_samp>
- #include <streamer>
- #include <sscanf2>
- #include <dini>
- #include <utils>
- #include <dutils>
- #include <zcmd>
- #define GM_NAME "Server Name"
- /* Dialogs */
- #define DIALOG_REGISTER 0
- #define DIALOG_REG_CONFIRM 1
- #define DIALOG_LOGIN 2
- #define DIALOG_RULES 3
- /* Max Defines */
- #define MAX_CLIENT_MSG_LENGTH 144
- /* Colours */
- #define COLOR_PURPLE2 0xC2A2DAFF
- #define COLOR_DARKRED 0xAA3333FF
- #define COLOR_GREY 0xAFAFAFFF
- #define COLOR_ASAY 0xFF0000FF
- #define COLOR_OSAY 0x007700FF
- #define COLOR_HSAY 0x1684CAFF
- #define COLOR_MSAY 0x1684CAFF
- #define COLOR_WHITE 0xFFFFFFFF
- #define COLOR_YELLOW 0xFFFF00FF
- #define COLOR_LIGHTGREEN 0xFF0000A
- #define COLOR_RED 0xFF0000FF
- #define RED 0xFF0000FF
- #define COLOR_LRED 0xFF4747FF
- #define COLOR_GREEN 0x00FF00FF
- #define COLOR_DARKMAUVE 0x623778FF
- #define COLOR_MAUVE 0x845F96FF
- #define COLOR_GREENYELLOW 0xADFF2FAA
- #define GREY \
- 0xAFAFAFAA
- #define GREEN \
- 0x9FFF00FF
- #define YELLOW \
- 0xFFFF00AA
- #define WHITE \
- 0xFFFFFFAA
- #define COLOR_BLUE 0x0000FFFF
- #define COLOR_LBLUE 0x99FFFFFF
- #define COLOR_LIGHTBLUE 0x99FFFFFF
- #define COLOR_ORANGE 0xFF9900FF
- #define COLOR_PURPLE 0xCC00DDFF
- #define COLOR_PEACH 0xFFCC66FF
- #define COLOR_SILVER 0xDDDDDDFF
- #define COLOR_WANTEDBLUE 0x0055CCFF
- #define COLOR_DARK_VIOLET 0x9400D3FF
- #define COLOR_VIP1 0x9400D3FF
- #define COLOR_HELP 0x00E5EEFF
- #define COLOR_ADMIN 0x0066FFFF
- #define COLOR_ADMIN2 0x008FD6FF
- #define COLOR_PLAYER 0xFFCC33FF
- #define COLOR_RP 0xFFFFFFFF
- #define COLOR_ULTRAADMIN 0x993300FF
- #define COLOR_EVENT 0x00CC66FF
- #define COLOR_VIP2 0xFF33CCFF
- #define COLOR_VIPCHAT 0xCC66CCFF
- #define COLOR_BROWNY 0xB32D00FF
- #define COLOR_PURPLE_1 0x993366FF
- #define COLOR_ERROR 0xAA3333AA
- #define COLOR_NOTIFICATION 0x33CCFFAA
- #define COL_WHITE "{FFFFFF}"
- #define COL_BLACK "{0E0101}"
- #define COL_GREY "{C3C3C3}"
- #define COL_GREEN "{6EF83C}"
- #define COL_RED "{F81414}"
- #define COL_YELLOW "{F3FF02}"
- #define COL_ORANGE "{FFAF00}"
- #define COL_LIME "{B7FF00}"
- #define COL_CYAN "{00FFEE}"
- #define COL_BLUE "{0049FF}"
- #define COL_MAGENTA "{F300FF}"
- #define COL_VIOLET "{B700FF}"
- #define COL_PINK "{FF00EA}"
- #define COL_MARONE "{A90202}"
- #define COL_VIP1 "{0x9400D3FF}"
- #define COL_VIP2 "{0xFF33CCFF}"
- #define COL_SILVER "{0xDDDDDDFF}"
- #define COL_PURPLE "{0xCC00DDFF}"
- #define COL_NICEGREEN "{6EF83C}"
- #define COL_NICERED "{FF0606}"
- #define COL_ORANGE "{FFAF00}"
- #define COL_EASY "{FFF1AF}"
- #define COL_WHITE "{FFFFFF}"
- #define COL_BLACK "{0E0101}"
- #define COL_YELLOW "{F3FF02}"
- #define COL_YELLOW2 "{DAE368}"
- #define COL_BYELLOW "{FFFF80}"
- #define COL_LIME "{B7FF00}"
- #define COL_CYAN "{00FFEE}"
- #define COL_LIGHTBLUE "{00C0FF}"
- #define COL_BLUE "{0049FF}"
- #define COL_MAGENTA "{F300FF}"
- #define COL_VIOLET "{B700FF}"
- #define COL_PINK "{FF00EA}"
- #define COL_MARONE "{A90202}"
- #define COL_CMD "{B8FF02}"
- #define COL_PARAM "{3FCD02}"
- #define COL_SERVER "{AFE7FF}"
- #define COL_VALUE "{A3E4FF}"
- #define COL_RULE "{F9E8B7}"
- #define COL_RULE2 "{FBDF89}"
- #define COL_RWHITE "{FFFFFF}"
- #define COL_LGREEN "{C9FFAB}"
- #define COL_LRED "{FFA1A1}"
- #define COL_LRED2 "{C77D87}"
- #define COL_LBLUE "{00A5FF}"
- #define COL_GRAD2 "{BFC0C2}"
- #define COL_REALRED "{FF0606}"
- #define COLOR_LIMEGREEN 0x32CD32AA
- /* Files */
- #define FILE_TOTALSTAT "totalstat"
- #define FILE_REC "records"
- #define FILE_ADMINS "alist"
- /* Folders */
- #define dir_datafiles "datafiles"
- #define dir_userfiles "userfiles"
- /* Class Position */
- #define SELECTION_X 1088.1422
- #define SELECTION_Y 1074.0307
- #define SELECTION_Z 10.8382
- /* Enumerators */
- enum PlayerInfo
- {
- pAdmin,
- pMoney,
- pScore,
- pIP,
- pYear,
- pMonth,
- pDay,
- pKills,
- pDeaths,
- pLogged,
- pDialog
- }
- new pInfo[MAX_PLAYERS][PlayerInfo];
- /* New Defines */
- new pConnected[MAX_PLAYERS];
- /* Defines */
- LoadPlayer(playerid)
- {
- new year, month, day, playerip[16], string[270];
- getdate(year, month, day);
- GetPlayerIp(playerid, playerip, 16);
- pInfo[playerid][pAdmin] = dini_Int(AddFile(dir_userfiles, RPN(playerid)), "pAdmin");
- pInfo[playerid][pKills] = dini_Int(AddFile(dir_userfiles, RPN(playerid)), "pKills");
- pInfo[playerid][pDeaths] = dini_Int(AddFile(dir_userfiles, RPN(playerid)), "pDeaths");
- pInfo[playerid][pMoney] = SetPlayerMoney(playerid, dini_Int(AddFile(dir_userfiles, RPN(playerid)), "pMoney"));
- pInfo[playerid][pScore] = SetPlayerScore(playerid, dini_Int(AddFile(dir_userfiles, RPN(playerid)), "pScore"));
- pInfo[playerid][pIP] = dini_Set(AddFile(dir_userfiles, RPN(playerid)), "pIP", playerip);
- pInfo[playerid][pYear] = dini_IntSet(AddFile(dir_userfiles, RPN(playerid)), "pYear", year);
- pInfo[playerid][pMonth] = dini_IntSet(AddFile(dir_userfiles, RPN(playerid)), "pMonth", month);
- pInfo[playerid][pDay] = dini_IntSet(AddFile(dir_userfiles, RPN(playerid)), "pDay", day);
- format(string, sizeof(string), "Server: Admin Level : %d", dini_Int(AddFile(dir_userfiles, RPN(playerid)), "pAdmin"));
- SendClientMessage(playerid, COLOR_YELLOW, string);
- }
- SavePlayer(playerid)
- {
- new year, month, day, playerip[16];
- getdate(year, month, day);
- GetPlayerIp(playerid, playerip, 16);
- dini_IntSet(AddFile(dir_userfiles, RPN(playerid)), "pMoney", GetPlayerMoney(playerid));
- dini_IntSet(AddFile(dir_userfiles, RPN(playerid)), "pScore", GetPlayerScore(playerid));
- dini_IntSet(AddFile(dir_userfiles, RPN(playerid)), "pAdmin", pInfo[playerid][pAdmin]);
- dini_IntSet(AddFile(dir_userfiles, RPN(playerid)), "pKills", pInfo[playerid][pKills]);
- dini_IntSet(AddFile(dir_userfiles, RPN(playerid)), "pDeaths", pInfo[playerid][pDeaths]);
- dini_Set(AddFile(dir_userfiles, RPN(playerid)), "pIP", playerip);
- dini_IntSet(AddFile(dir_userfiles, RPN(playerid)), "pYear", year);
- dini_IntSet(AddFile(dir_userfiles, RPN(playerid)), "pMonth", month);
- dini_IntSet(AddFile(dir_userfiles, RPN(playerid)), "pDay", day);
- }
- SaveAllPlayer()
- {
- new year, month, day, playerip[16];
- getdate(year, month, day);
- for(new i=0;i<MAX_PLAYERS;i++)
- {
- GetPlayerIp(i, playerip, 16);
- dini_IntSet(AddFile(dir_userfiles, RPN(i)), "pMoney", GetPlayerMoney(i));
- dini_IntSet(AddFile(dir_userfiles, RPN(i)), "pScore", GetPlayerScore(i));
- dini_IntSet(AddFile(dir_userfiles, RPN(i)), "pAdmin", pInfo[i][pAdmin]);
- dini_IntSet(AddFile(dir_userfiles, RPN(i)), "pKills", pInfo[i][pKills]);
- dini_IntSet(AddFile(dir_userfiles, RPN(i)), "pDeaths", pInfo[i][pDeaths]);
- dini_Set(AddFile(dir_userfiles, RPN(i)), "pIP", playerip);
- dini_IntSet(AddFile(dir_userfiles, RPN(i)), "pYear", year);
- dini_IntSet(AddFile(dir_userfiles, RPN(i)), "pMonth", month);
- dini_IntSet(AddFile(dir_userfiles, RPN(i)), "pDay", day);
- }
- }
- AddFile(directory[], filename[])
- {
- new newname[128];
- format(newname, sizeof(newname), "%s/%c/%s.ini", directory, filename[0] != '.' ? filename[0] : '#', filename);
- return newname;
- }
- SendClientMessageToClient(playerid, color, message[])
- {
- if (strlen(message) <= MAX_CLIENT_MSG_LENGTH)
- {
- SendClientMessage(playerid, color, message);
- }
- else
- {
- new string[MAX_CLIENT_MSG_LENGTH + 1];
- strmid(string, message, 0, MAX_CLIENT_MSG_LENGTH);
- SendClientMessage(playerid, color, string);
- }
- return 1;
- }
- SendClientMessageToPlayer(color, message[])
- {
- for (new i = 0; i < PLAYERS; i++)
- {
- if (IsPlayerConnected2(i)) SendClientMessageToClient(i, color, message);
- }
- return 1;
- }
- IsPlayerConnected2(playerid)
- {
- return IsPlayerNPC(playerid) == 0 && playerid < sizeof(pConnected) ? pConnected[playerid] : 0;
- }
- ShowPlayerDialog2(playerid, dialogid, style, caption[], info[], button1[], button2[])
- {
- ShowPlayerDialog(playerid, dialogid, style, caption, info, button1, button2);
- pInfo[playerid][pDialog] = dialogid;
- }
- HidePlayerDialog(playerid)
- {
- ShowPlayerDialog(playerid, -1, 0, " ", " ", "", "");
- pInfo[playerid][pDialog][playerid] = -1;
- }
- GetPlayerDialog(playerid)
- {
- return pInfo[playerid][pDialog][playerid];
- }
- SaveAccount(playerid, text[])
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- dini_Set(AddFile(dir_datafiles, FILE_REC), name, text);
- }
- SaveAccount2(text[], text2[])
- {
- dini_Set(AddFile(dir_datafiles, FILE_REC), text, text2);
- }
- SendPlayerFormattedText(playerid, color, str[], define1[], define2[])
- {
- new tstr[256];
- format(tstr, 256, str, define1, define2);
- SendClientMessageToClient(playerid, color, tstr);
- return 1;
- }
- SendAllFormattedText(color, str[], define1[], define2[])
- {
- new tstr[256];
- format(tstr, 256, str, define1, define2);
- SendClientMessageToPlayer(color, tstr);
- return 1;
- }
- RPN(playerid)
- {
- new name[25];
- GetPlayerName(playerid, name, sizeof(name));
- return name;
- }
- PlayerConnect(playerid)
- {
- new tmp3[50],pNames[MAX_PLAYER_NAME],string[128];
- GetPlayerName(playerid,pNames,MAX_PLAYER_NAME);
- GetPlayerIp(playerid,tmp3,50);
- if(strlen(dini_Get("checkrecords.cfg", tmp3)) == 0)
- dini_Set("checkrecords.cfg", tmp3, pNames);
- else
- {
- if( strfind( dini_Get("checkrecords.cfg", tmp3), pNames, true) == -1 )
- {
- format(string,sizeof(string),"%s,%s", dini_Get("checkrecords.cfg",tmp3), pNames);
- dini_Set("checkrecords.cfg", tmp3, string);
- }
- }
- new File: file = fopen("usernames.cfg", io_append);
- format(string,sizeof(string),"%s\r\n",pNames);
- fwrite(file,string);
- fclose(file);
- return 1;
- }
- SetPlayerAdmin(playerid, level)
- {
- pInfo[playerid][pAdmin] =level;
- dini_IntSet(AddFile(dir_userfiles, RPN(playerid)), "pAdmin", level);
- }
- SetPlayerKills(playerid, kills)
- {
- pInfo[playerid][pKills] =kills;
- dini_IntSet(AddFile(dir_userfiles, RPN(playerid)), "pKills", kills);
- }
- GivePlayerKills(playerid, kills)
- {
- pInfo[playerid][pKills] +=kills;
- dini_IntSet(AddFile(dir_userfiles, RPN(playerid)), "pKills", pInfo[playerid][pKills]+kills);
- }
- SetPlayerDeaths(playerid, deaths)
- {
- pInfo[playerid][pDeaths] =deaths;
- dini_IntSet(AddFile(dir_userfiles, RPN(playerid)), "pDeaths", deaths);
- }
- GivePlayerDeaths(playerid, deaths)
- {
- pInfo[playerid][pDeaths] +=deaths;
- dini_IntSet(AddFile(dir_userfiles, RPN(playerid)), "pDeaths", pInfo[playerid][pDeaths]+deaths);
- }
- GivePlayerScore(playerid, score)
- {
- pInfo[playerid][pAdmin] = SetPlayerScore(playerid, GetPlayerScore(playerid)+score);
- dini_IntSet(AddFile(dir_userfiles, RPN(playerid)), "pScore", SetPlayerScore(playerid, GetPlayerScore(playerid)+score));
- }
- public OnFilterScriptInit()
- {
- if (!dini_Exists(AddFile(dir_datafiles, FILE_TOTALSTAT)))
- {
- dini_Create(AddFile(dir_datafiles, FILE_TOTALSTAT));
- }
- if (!dini_Exists(AddFile(dir_datafiles, FILE_REC)))
- {
- dini_Create(AddFile(dir_datafiles, FILE_REC));
- }
- if (!dini_Exists(AddFile(dir_datafiles, FILE_ADMINS)))
- {
- dini_Create(AddFile(dir_datafiles, FILE_ADMINS));
- }
- if (!dini_Exists(AddFile(dir_datafiles, "None")))
- {
- dini_Create(AddFile(dir_userfiles, "None"));
- }
- if(!fexist("records.cfg"))return dini_Create("records.cfg");
- if(!fexist("accounts.cfg"))return dini_Create("accounts.cfg");
- for (new i = 1; i < 300; i++)
- {
- if (i == 74) continue;
- AddPlayerClass(i, SELECTION_X, SELECTION_Y, SELECTION_Z, 0.0, 0, 0, 0, 0, 0, 0);
- }
- SetTimer("SaveAllPlayers", 100, 1);
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- SetPlayerClassPosition(playerid, classid)
- {
- new Float:angle = (360.0 / 50) * (50 - classid);
- SetPlayerInterior(playerid, 0);
- SetPlayerFacingAngle(playerid, angle);
- SetPlayerPos(playerid, SELECTION_X, SELECTION_Y, SELECTION_Z);
- SetPlayerCameraPos(playerid, SELECTION_X + floatsin(-angle, degrees) * 4.0, SELECTION_Y + floatcos(-angle, degrees) * 4.0, SELECTION_Z + 1.0);
- SetPlayerCameraLookAt(playerid, SELECTION_X, SELECTION_Y, SELECTION_Z);
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- new playeridname[25], playername[MAX_PLAYER_NAME], str[270];
- GetPlayerName(playerid, playeridname, sizeof(playeridname));
- GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
- if (IsPlayerNPC(playerid)) return 1;
- SetPlayerColor(playerid, COLOR_YELLOW);
- if (pConnected[playerid] == 0)
- {
- pConnected[playerid] = 1;
- SetPlayerColor(playerid, COLOR_PLAYER);
- TogglePlayerSpectating(playerid, 1);
- SetPlayerVirtualWorld(playerid, 1);
- if (dini_Exists(AddFile(dir_userfiles, playername)))
- {
- format(str, sizeof(str), "{B35900}Welcome to {669900}%s.\n\n{FFFF00}Account:{FFFFFF} %s is already "COL_GREEN"registered\n\n"COL_WHITE"Please enter your password below:", GM_NAME, RPN(playerid));
- ShowPlayerDialog2(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login to your account", str, "Login", "Cancel");
- SendPlayerFormattedText(playerid, COLOR_WHITE, "Welcome back {00FF7F}%s"COL_WHITE",Login to your account to play.", playername, "");
- }
- else
- {
- format(str, sizeof(str), "{B35900}Welcome to {669900}%s.\n\n{FFFF00}Account:{FFFFFF} %s is not "COL_RED"registered\n\n"COL_WHITE"Register an account to play.\n\nPlease put the password below:", GM_NAME, RPN(playerid));
- ShowPlayerDialog2(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register an account", str, "Continue", "Cancel");
- SendPlayerFormattedText(playerid, COLOR_WHITE, "Account {00FF7F}%s "COL_WHITE"isn't registered. Register your account below to play.", playername, "");
- }
- return 0;
- }
- SetPlayerClassPosition(playerid, classid);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- pConnected[playerid] = 0;
- pInfo[playerid][pAdmin] = 0;
- pInfo[playerid][pKills] = 0;
- pInfo[playerid][pDeaths] = 0;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if(pInfo[playerid][pLogged] == 1)
- {
- SavePlayer(playerid);
- }
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- if (pInfo[playerid][pLogged] == 1)
- {
- dini_Unset((AddFile(dir_userfiles, RPN(playerid))), "firstspawn");
- }
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- pInfo[playerid][pKills] ++;
- pInfo[playerid][pDeaths] ++;
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- if (pInfo[playerid][pLogged] == 0) {
- printf("[Chats] [%s]: %s", RPN(playerid), text);
- if (dini_Exists(AddFile(dir_userfiles, RPN(playerid))))
- {
- SendClientMessageToClient(playerid, COLOR_WHITE, "You must login to play! Type /login to continue.");
- }
- else
- {
- SendClientMessageToClient(playerid, COLOR_WHITE, "You must register to play! Type /register to continue.");
- }
- return 0;
- }
- if (!IsPlayerConnected2(playerid)) return 0;
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/mycommand", cmdtext, true, 10) == 0)
- {
- // Do something here
- return 1;
- }
- return 0;
- }
- public OnPlayerCommandPerformed(playerid, cmdtext[], success)
- {
- if(!success) return 0;
- return 1;
- }
- public OnPlayerCommandReceived(playerid, cmdtext[])
- {
- if (!IsPlayerConnected2(playerid)) return 0;
- new playername[MAX_PLAYER_NAME], hidcmd;
- new cstring[100],playerids[MAX_PLAYER_NAME];
- GetPlayerName(playerid, playerids, sizeof(playerids));
- format(cstring, sizeof(cstring), "[Command] [%s]: %s", playerids, cmdtext);
- for(new i=0; i<PLAYERS; i++)
- {
- if(pInfo[i][pAdmin] >= 1)
- {
- if(pInfo[playerid][pAdmin] <= pInfo[i][pAdmin])
- {
- if(i != playerid && hidcmd == 1) SendClientMessage(i, -1, cstring);
- }
- }
- }
- if((strfind(cmdtext, "/register", true) != 0) && (strfind(cmdtext, "/login", true) != 0) && (strfind(cmdtext, "/areply", true) != 0))
- {
- if (pInfo[playerid][pLogged] == 0)
- {
- if (dini_Exists(AddFile(dir_userfiles, playername))) SendClientMessageToClient(playerid, COLOR_WHITE, "You must login to play! Type /login to continue.");
- else SendClientMessageToClient(playerid, COLOR_WHITE, "You must register to play! Type /register to continue.");
- return 0;
- }
- }
- return 1;
- }
- 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)
- {
- if (IsPlayerNPC(playerid)) return 1;
- if (pInfo[playerid][pLogged] == 0) return 0;
- if (dini_Isset(AddFile(dir_userfiles, RPN(playerid)), "firstspawn"))
- {
- TogglePlayerSpectating(playerid, 1);
- ShowPlayerDialog2(playerid, DIALOG_RULES, DIALOG_STYLE_MSGBOX, "Server Rules", "Welcome To "GM_NAME".\n\nYou must have to follow rules of the server.", "Accept", "Cancel");
- return 1;
- }
- 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 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 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[])
- {
- pInfo[playerid][pDialog] = -1;
- new tmp2[256], playername[MAX_PLAYER_NAME], tmp[256], temp1;
- GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
- if (dialogid == DIALOG_REGISTER)
- {
- if (response)
- {
- if (dini_Isset(AddFile(dir_datafiles, FILE_TOTALSTAT), "regdis"))
- return SendClientMessageToClient(playerid, COLOR_RED, ""COL_LIME"Server: "COL_RED"Registration is currently disabled. Please try again later.");
- temp1 = dini_Int(AddFile(dir_datafiles, FILE_TOTALSTAT), "users");
- if (temp1 == 99999999)
- return SendClientMessageToClient(playerid, COLOR_RED, ""COL_LIME"Server: "COL_RED"Max account limit reached.");
- if (strlen(inputtext) < 6 || strlen(inputtext) > 18) {
- ShowPlayerDialog2(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register an account", "You must register an account to play in this server.\n\nType a password below to register an account.\n\n{E60026}Password length must be between 6-18 chars.", "Continue", "Cancel");
- SendClientMessageToClient(playerid, COLOR_RED, ""COL_LIME"Server: "COL_RED"Your password must be between 6-18 characters.");
- return 1;
- }
- SetPVarInt(playerid, "confirmpass", num_hash(inputtext));
- ShowPlayerDialog2(playerid, DIALOG_REG_CONFIRM, DIALOG_STYLE_PASSWORD, "Register an account", "Please confirm your password.", "Register", "Cancel");
- }
- else {
- SendClientMessageToClient(playerid, COLOR_WHITE, "You must register to play! Type /register to continue.");
- }
- return 1;
- }
- if (dialogid == DIALOG_REG_CONFIRM)
- {
- if (response)
- {
- if (dini_Isset(AddFile(dir_datafiles, FILE_TOTALSTAT), "regdis"))
- return SendClientMessageToClient(playerid, COLOR_RED, ""COL_LIME"Server: "COL_RED""COL_LIME"Server: "COL_GREEN"Registration is currently disabled. Please try again later.");
- if (GetPVarInt(playerid, "confirmpass") != num_hash(inputtext)) {
- ShowPlayerDialog2(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register an account", "You must register an account to play in this server.\n\nType a password below to register an account.\n\n{E60026}The passwords you entered didn't match.", "Continue", "Cancel");
- SendClientMessage(playerid, COLOR_RED, ""COL_LIME"Server: "COL_RED"The passwords you entered didn't match.");
- return 1;
- }
- temp1 = dini_Int(AddFile(dir_datafiles, FILE_TOTALSTAT), "users");
- dini_IntSet(AddFile(dir_datafiles, FILE_TOTALSTAT), "users", temp1+1);
- dini_Create(AddFile(dir_userfiles, playername));
- dini_IntSet(AddFile(dir_userfiles, playername), "password", num_hash(inputtext));
- SaveAccount(playerid, inputtext);
- dini_IntSet(AddFile(dir_userfiles, playername), "account", temp1+1);
- SetPVarInt(playerid, "IsNew", 1);
- SetPlayerMoney(playerid, 10000);
- dini_IntSet(AddFile(dir_userfiles, RPN(playerid)), "pMoney", 10000);
- dini_IntSet(AddFile(dir_userfiles, RPN(playerid)), "firstspawn", 1);
- dini_Set(AddFile(dir_userfiles, playername), "ChatColor", "FFFFFF");
- pInfo[playerid][pLogged] = 1;
- TogglePlayerSpectating(playerid, 0);
- SendPlayerFormattedText(playerid, COLOR_YELLOW, ""COL_LIME"Server: "COL_YELLOW"Account '%s' created, you have been logged in automatically!", playername, "");
- SendAllFormattedText(COLOR_GREEN, ""COL_LIME"Server: "COL_GREEN"%s has registered a new account. Welcome to our server!", playername, "");
- printf("[Register] %s (Id%d) has registered a new account.", playername, playerid);
- }
- else {
- SendClientMessageToClient(playerid, COLOR_WHITE, "You must register to play! Type /register to continue.");
- }
- return 1;
- }
- if (dialogid == DIALOG_LOGIN)
- {
- if (response)
- {
- if (num_hash(inputtext) != dini_Int(AddFile(dir_userfiles, playername), "password")) {
- temp1 = GetPVarInt(playerid, "loginattempts")+1;
- if (temp1 == 3) {
- SendClientMessageToClient(playerid, COLOR_RED, ""COL_LIME"Server: "COL_RED"Bad password threshold reached. You have been kicked!");
- SetTimerEx("KickBanTimer", 50, 0, "dd", playerid, 1);
- }
- else {
- SetPVarInt(playerid, "loginattempts", temp1);
- format(tmp, 32, "Login to your account (%d/3)", temp1);
- format(tmp2, 280, "Type your password below to login to your account.\n\n{FFFF00}Account:{FFFFFF} %s\n\n{E60026}Password incorrect. Attempts remaining - %d.",RPN(playerid), 3 - temp1);
- ShowPlayerDialog2(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, tmp, tmp2, "Login", "Cancel");
- format(tmp2, 280, ""COL_LIME"Server: "COL_RED"Password incorrect. Attempts remaining - %d.", 3 - temp1);
- SendClientMessageToClient(playerid, COLOR_RED, tmp2);
- }
- return 1;
- }
- pInfo[playerid][pLogged] = 1;
- TogglePlayerSpectating(playerid, 0);
- LoadPlayer(playerid);
- SendClientMessageToClient(playerid, COLOR_WHITE, "Login successful, your status has been restored!");
- dini_Set(AddFile(dir_userfiles, playername), "ChatColor", "FFFFFF");
- printf("[Logged] %s (Id%d) has logged in.", playername, playerid);
- PlayerConnect(playerid);
- }
- else {
- SendClientMessageToClient(playerid, COLOR_WHITE, "You must login to play! Type /login to continue.");
- }
- return 1;
- }
- if(dialogid == DIALOG_RULES)
- {
- if(!response) Kick(playerid);
- {
- SendClientMessage(playerid, COLOR_LBLUE, "Thanks for joining the server.");
- TogglePlayerSpectating(playerid, 0);
- }
- }
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
- /* Commands */
- CMD:cmds(playerid, params[])
- {
- SendClientMessage(playerid, COLOR_YELLOW, "Server Commands");
- SendClientMessage(playerid, COLOR_WHITE, "/register, /login, /stats");
- return 1;
- }
- CMD:stats(playerid, params[])
- {
- new string[200];
- SendClientMessage(playerid, COLOR_LBLUE, "*Your Stats!");
- format(string, sizeof(string), "*Admin Level: %d", pInfo[playerid][pAdmin]);
- SendClientMessage(playerid, COLOR_YELLOW, string);
- format(string, sizeof(string), "*Scores: %d", pInfo[playerid][pScore]);
- SendClientMessage(playerid, COLOR_YELLOW, string);
- format(string, sizeof(string), "*Kills: %d", pInfo[playerid][pKills]);
- SendClientMessage(playerid, COLOR_YELLOW, string);
- format(string, sizeof(string), "*Deaths: %d", pInfo[playerid][pDeaths]);
- SendClientMessage(playerid, COLOR_YELLOW, string);
- format(string, sizeof(string), "*Kills/Deaths Ratio: %.2f", floatdiv(pInfo[playerid][pKills], pInfo[playerid][pDeaths]));
- SendClientMessage(playerid, COLOR_YELLOW, string);
- return 1;
- }
- /* Admin Script */
- CMD:acmds(playerid, params[])
- {
- if(!pInfo[playerid][pAdmin]) return 0;
- if(pInfo[playerid][pAdmin] == 1)
- {
- SendClientMessage(playerid, COLOR_YELLOW, "Admin Commands");
- SendClientMessage(playerid, COLOR_WHITE, "/Soon");
- }
- if(pInfo[playerid][pAdmin] == 2)
- {
- SendClientMessage(playerid, COLOR_YELLOW, "Admin Commands");
- SendClientMessage(playerid, COLOR_WHITE, "/Soon");
- }
- if(pInfo[playerid][pAdmin] == 3)
- {
- SendClientMessage(playerid, COLOR_YELLOW, "Admin Commands");
- SendClientMessage(playerid, COLOR_WHITE, "/Soon");
- }
- if(pInfo[playerid][pAdmin] == 4)
- {
- SendClientMessage(playerid, COLOR_YELLOW, "Admin Commands");
- SendClientMessage(playerid, COLOR_WHITE, "/Soon");
- }
- if(pInfo[playerid][pAdmin] == 5)
- {
- SendClientMessage(playerid, COLOR_YELLOW, "Admin Commands");
- SendClientMessage(playerid, COLOR_WHITE, "/Soon");
- }
- if(pInfo[playerid][pAdmin] == 6)
- {
- SendClientMessage(playerid, COLOR_YELLOW, "Admin Commands");
- SendClientMessage(playerid, COLOR_WHITE, "/setadmin, /setscore, /setkills, /setdeaths, /giveallscore, /givealldeaths, /giveallkills");
- }
- if(pInfo[playerid][pAdmin] == 7)
- {
- SendClientMessage(playerid, COLOR_YELLOW, "Admin Commands");
- SendClientMessage(playerid, COLOR_WHITE, "/setadmin, /setscore, /setkills, /setdeaths, /giveallscore, /givealldeaths, /giveallkills");
- }
- return 1;
- }
- CMD:setadmin(playerid, params[])
- {
- new id, level, string[200];
- if(pInfo[playerid][pAdmin] < 6 && !IsPlayerAdmin(playerid)) return 0;
- if(sscanf(params, "ud", id, level)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setadmin [playerid] [level]");
- if(!IsPlayerConnected2(id)) return SendClientMessage(playerid, COLOR_RED, "Server: That player is not connected.");
- if(level < 0 || level > 7) return SendClientMessage(playerid, COLOR_RED, "Server: please enter valid admin level [Level 1 - 7].");
- if (level == pInfo[id][pAdmin])
- {
- format(string, 64, "%s is already admin level %d.", RPN(id), level);
- SendClientMessageToClient(playerid, COLOR_WHITE, string);
- return 1;
- }
- if (level != 0)
- {
- dini_IntSet(AddFile(dir_userfiles, RPN(id)), "pAdmin", level);
- dini_IntSet(AddFile(dir_datafiles, FILE_ADMINS), RPN(id), level);
- }
- else
- {
- dini_Unset(AddFile(dir_userfiles, RPN(id)), "pAdmin");
- dini_Unset(AddFile(dir_datafiles, FILE_ADMINS), RPN(id));
- }
- pInfo[id][pAdmin] =level;
- format(string, sizeof(string), "Server: You have been set as admin level %d.", level);
- SendClientMessage(id, COLOR_YELLOW, string);
- format(string, sizeof(string), "Server: You have set %s as admin level %d.", RPN(id), level);
- SendClientMessage(playerid, COLOR_YELLOW, string);
- return 1;
- }
- CMD:setscore(playerid, params[])
- {
- new id, score, string[200];
- if(pInfo[playerid][pAdmin] < 6 && !IsPlayerAdmin(playerid)) return 0;
- if(sscanf(params, "ud", id, score)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setscore [playerid] [score]");
- if(!IsPlayerConnected2(id)) return SendClientMessage(playerid, COLOR_RED, "Server: That player is not connected.");
- if(score < 0 || score > cellmax) return SendClientMessage(playerid, COLOR_RED, "Server: please enter valid scores.");
- if (score == pInfo[id][pScore])
- {
- format(string, 64, "%s is already have score %d.", RPN(id), score);
- SendClientMessageToClient(playerid, COLOR_WHITE, string);
- return 1;
- }
- dini_IntSet(AddFile(dir_userfiles, RPN(id)), "pScore", score);
- pInfo[id][pScore] = score;
- SetPlayerScore(playerid, score);
- format(string, sizeof(string), "Server: Your score has been set to %d.", score);
- SendClientMessage(id, COLOR_YELLOW, string);
- format(string, sizeof(string), "Server: You have set %s's score to %d.", RPN(id), score);
- SendClientMessage(playerid, COLOR_YELLOW, string);
- return 1;
- }
- CMD:setkills(playerid, params[])
- {
- new id, kills, string[200];
- if(pInfo[playerid][pAdmin] < 6 && !IsPlayerAdmin(playerid)) return 0;
- if(sscanf(params, "ud", id, kills)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setkills [playerid] [kills]");
- if(!IsPlayerConnected2(id)) return SendClientMessage(playerid, COLOR_RED, "Server: That player is not connected.");
- if(kills < 0 || kills > cellmax) return SendClientMessage(playerid, COLOR_RED, "Server: please enter valid kills.");
- if (kills == pInfo[id][pKills])
- {
- format(string, 64, "%s is already have kills %d.", RPN(id), kills);
- SendClientMessageToClient(playerid, COLOR_WHITE, string);
- return 1;
- }
- SetPlayerKills(id, kills);
- format(string, sizeof(string), "Server: Your kills has been set to %d.", kills);
- SendClientMessage(id, COLOR_YELLOW, string);
- format(string, sizeof(string), "Server: You have set %s's kills to %d.", RPN(id), kills);
- SendClientMessage(playerid, COLOR_YELLOW, string);
- return 1;
- }
- CMD:setdeaths(playerid, params[])
- {
- new id, deaths, string[200];
- if(pInfo[playerid][pAdmin] < 6 && !IsPlayerAdmin(playerid)) return 0;
- if(sscanf(params, "ud", id, deaths)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setdeaths [playerid] [deaths]");
- if(!IsPlayerConnected2(id)) return SendClientMessage(playerid, COLOR_RED, "Server: That player is not connected.");
- if(deaths < 0 || deaths > cellmax) return SendClientMessage(playerid, COLOR_RED, "Server: please enter valid deaths.");
- if (deaths == pInfo[id][pDeaths])
- {
- format(string, 64, "%s is already have deaths %d.", RPN(id), deaths);
- SendClientMessageToClient(playerid, COLOR_WHITE, string);
- return 1;
- }
- SetPlayerDeaths(playerid, deaths);
- format(string, sizeof(string), "Server: Your deaths has been set to %d.", deaths);
- SendClientMessage(id, COLOR_YELLOW, string);
- format(string, sizeof(string), "Server: You have set %s's deaths to %d.", RPN(id), deaths);
- SendClientMessage(playerid, COLOR_YELLOW, string);
- return 1;
- }
- CMD:giveallscore(playerid, params[])
- {
- new amount, string[270];
- if(!IsPlayerAdmin(playerid) && pInfo[playerid][pAdmin] < 6) return 0;
- if(sscanf(params, "d", amount)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /giveallscore [score]");
- if(amount < 0 || amount > cellmax) return SendClientMessage(playerid, COLOR_RED, "Server: invalid amount please enter valid amount.");
- for(new i=0;i<MAX_PLAYERS;i++)
- {
- GivePlayerScore(i, amount);
- }
- format(string, sizeof(string), "%s gave you %d score.", RPN(playerid), amount);
- SendClientMessageToAll(COLOR_YELLOW, string);
- return 1;
- }
- CMD:giveallkills(playerid, params[])
- {
- new amount, string[270];
- if(!IsPlayerAdmin(playerid) && pInfo[playerid][pAdmin] < 6) return 0;
- if(sscanf(params, "d", amount)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /giveallkills [kills]");
- if(amount < 0 || amount > cellmax) return SendClientMessage(playerid, COLOR_RED, "Server: invalid amount please enter valid amount.");
- for(new i=0;i<MAX_PLAYERS;i++)
- {
- GivePlayerKills(i, amount);
- }
- format(string, sizeof(string), "%s gave you %d kills.", RPN(playerid), amount);
- SendClientMessageToAll(COLOR_YELLOW, string);
- return 1;
- }
- CMD:givealldeaths(playerid, params[])
- {
- new amount, string[270];
- if(!IsPlayerAdmin(playerid) && pInfo[playerid][pAdmin] < 6) return 0;
- if(sscanf(params, "d", amount)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givealldeaths [deaths]");
- if(amount < 0 || amount > cellmax) return SendClientMessage(playerid, COLOR_RED, "Server: invalid amount please enter valid amount.");
- for(new i=0;i<MAX_PLAYERS;i++)
- {
- GivePlayerDeaths(i, amount);
- }
- format(string, sizeof(string), "%s gave you %d kills.", RPN(playerid), amount);
- SendClientMessageToAll(COLOR_YELLOW, string);
- return 1;
- }
- /* Timers */
- forward SaveAllPlayers();
- public SaveAllPlayers()
- {
- SaveAllPlayer();
- }
Add Comment
Please, Sign In to add comment