Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <xml>
- #include <zcmd>
- #define SCRIPT_VERSION "1.0.0"
- #define SCRIPT_AUTHOR "Stewie"
- #define function%0(%1) forward%0(%1); public%0(%1)
- main() {
- printf(" >> MapDev loading");
- }
- /*
- * Data structure and Data
- */
- #define COLOR_RED_I 0xFF8585FF
- #define COLOR_RED_S "{FF8585}"
- #define COLOR_GREEN_I 0xA6FFA7FF
- #define COLOR_GREEN_S "{A6FFA7}"
- #define COLOR_BLUE_I 0xA9A6FFFF
- #define COLOR_BLUE_S "{A9A6FF}"
- #define COLOR_YELLOW_I 0xFFF3A6FF
- #define COLOR_YELLOW_S "{FFF3A6}"
- #define
- new const
- playerCredentials[][][] = {
- {"Stewie", "mapdevpass"},
- {"Los", "stewiesnotalone"}
- };
- enum PlayerStatus {
- PLAYER_STATUS_DISCONNECTED,
- PLAYER_STATUS_LOGIN,
- PLAYER_STATUS_SELECTION
- }
- enum PlayerInfo {
- PlayerStatus:playerStatus,
- playerName[MAX_PLAYER_NAME]
- } new playerInfo[MAX_PLAYERS][PlayerInfo];
- new XMLPointer:mapSets[255] = {XMLPointer:-1, ...};
- /*
- * Scripting
- */
- function pushPointer(XMLPointer:pointer) {
- for(new i; i < sizeof(mapSets), i++) {
- if(mapSets[i] == XMLPointer:-1) {
- mapSets[i] = pointer;
- return 1;
- }
- }
- return 0;
- }
- /*
- * Public Functions
- */
- public OnGameModeInit() {
- printf(" >> MapDev " SCRIPT_VERSION " by " SCRIPT_AUTHOR);
- new XMLFile:listing = xml_open("maps\\listing.xml");
- if(_:listing) {
- new XMLPointer:node = xml_pointer(listing), mapsetcount;
- xml_pointer_childnode(node);
- if(xml_pointer_childnode(node, "mapset")) {
- do {
- mapsetcount++;
- new XMLPointer:attr = xml_clonepointer(node);
- if(xml_pointer_childattr(attr, "path")) {
- new path[64];
- xml_pointer_getvalue(attr, path, sizeof(path);
- strins(path, "maps\\", 0);
- new XMLFile:mapset = xml_open(path);
- if(_:mapset) {
- pushPointer(xml_pointer(mapset));
- }
- }
- } while(xml_pointer_nextnode(node, "mapset"));
- }
- new tmp[80];
- format(tmp, sizeof(tmp), " >> %d mapsets loaded.", mapsetcount);
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- gPlayerInfo[playerid][playerStatus] = PLAYER_STATUS_LOGIN;
- TogglePlayerSpectating(playerid, 1);
- SendClientMessage(playerid, COLOR_RED_I, "Este servidor está restrito aos usuários com credenciais predefinidas.");
- SendClientMessage(playerid, -1, "Informe-a ou " COLOR_RED_S " vá embora.");
- SendClientMessage(playerid, COLOR_YELLOW_I, "Faça login com /login [password]");
- GetPlayerName(playerid, gPlayerInfo[playerid][playerName], sizeof(playerName));
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason) {
- gPlayerInfo[playerid][playerStatus] = PLAYER_STATUS_DISCONNECTED;
- return 1;
- }
- /*
- * Commands
- */
- CMD:login(playerid, params[]) {
- if(gPlayerInfo[playerid][playerStatus] != PLAYER_STATUS_LOGIN) {
- return 1;
- }
- for(new i; i < sizeof(playerCredentials); i++) {
- if(!strcmp(gPlayerInfo[playerid][playerName], playerCredentials[i][0]) && !strcmp(params, playerCredentials[i][1])) {
- gPlayerInfo[playerid][playerStatus] = PLAYER_STATUS_SELECTION;
- SendClientMessage(playerid, COLOR_GREEN_I, "Você autenticou-se. {FFFFFF}Prossiga com a edição de algum mapa");
- return 1;
- }
- }
- SendClientMessage(playerid, COLOR_RED_I, "Você errou. {FFFFFF}Tente novamente.");
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement