daily pastebin goal
34%
SHARE
TWEET

Untitled

a guest Apr 12th, 2013 94 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. #include <a_samp>
  2. #include <xml>
  3. #include <zcmd>
  4.  
  5. #define SCRIPT_VERSION "1.0.0"
  6. #define SCRIPT_AUTHOR "Stewie"
  7.  
  8. #define function%0(%1) forward%0(%1); public%0(%1)
  9.  
  10. main() {
  11.     printf(" >> MapDev loading");
  12. }
  13.  
  14. /*
  15.  * Data structure and Data
  16.  */
  17.  
  18. #define COLOR_RED_I 0xFF8585FF
  19. #define COLOR_RED_S "{FF8585}"
  20.  
  21. #define COLOR_GREEN_I 0xA6FFA7FF
  22. #define COLOR_GREEN_S "{A6FFA7}"
  23.  
  24. #define COLOR_BLUE_I 0xA9A6FFFF
  25. #define COLOR_BLUE_S "{A9A6FF}"
  26.  
  27. #define COLOR_YELLOW_I 0xFFF3A6FF
  28. #define COLOR_YELLOW_S "{FFF3A6}"
  29.  
  30. #define
  31.  
  32. new const
  33.     playerCredentials[][][] = {
  34.     {"Stewie", "mapdevpass"},
  35.     {"Los", "stewiesnotalone"}
  36. };
  37.  
  38. enum PlayerStatus {
  39.     PLAYER_STATUS_DISCONNECTED,
  40.     PLAYER_STATUS_LOGIN,
  41.     PLAYER_STATUS_SELECTION
  42. }
  43.  
  44. enum PlayerInfo {
  45.     PlayerStatus:playerStatus,
  46.     playerName[MAX_PLAYER_NAME]
  47. } new playerInfo[MAX_PLAYERS][PlayerInfo];
  48.  
  49. new XMLPointer:mapSets[255] = {XMLPointer:-1, ...};
  50.  
  51. /*
  52.  * Scripting
  53.  */
  54.  
  55. function pushPointer(XMLPointer:pointer) {
  56.     for(new i; i < sizeof(mapSets), i++) {
  57.         if(mapSets[i] == XMLPointer:-1) {
  58.             mapSets[i] = pointer;
  59.             return 1;
  60.         }
  61.     }
  62.     return 0;
  63. }
  64.  
  65.  
  66. /*
  67.  * Public Functions
  68.  */
  69.  
  70. public OnGameModeInit() {
  71.     printf(" >> MapDev " SCRIPT_VERSION " by " SCRIPT_AUTHOR);
  72.  
  73.     new XMLFile:listing = xml_open("maps\\listing.xml");
  74.     if(_:listing) {
  75.         new XMLPointer:node = xml_pointer(listing), mapsetcount;
  76.         xml_pointer_childnode(node);
  77.  
  78.         if(xml_pointer_childnode(node, "mapset")) {
  79.             do {
  80.                 mapsetcount++;
  81.                 new XMLPointer:attr = xml_clonepointer(node);
  82.  
  83.                 if(xml_pointer_childattr(attr, "path")) {
  84.                     new path[64];
  85.                     xml_pointer_getvalue(attr, path, sizeof(path);
  86.                     strins(path, "maps\\", 0);
  87.  
  88.                     new XMLFile:mapset = xml_open(path);
  89.                     if(_:mapset) {
  90.                         pushPointer(xml_pointer(mapset));
  91.                     }
  92.                 }
  93.             } while(xml_pointer_nextnode(node, "mapset"));
  94.         }
  95.  
  96.         new tmp[80];
  97.         format(tmp, sizeof(tmp), " >> %d mapsets loaded.", mapsetcount);
  98.     }
  99.     return 1;
  100. }
  101.  
  102. public OnPlayerConnect(playerid)
  103.     gPlayerInfo[playerid][playerStatus] = PLAYER_STATUS_LOGIN;
  104.  
  105.     TogglePlayerSpectating(playerid, 1);
  106.     SendClientMessage(playerid, COLOR_RED_I, "Este servidor está restrito aos usuários com credenciais predefinidas.");
  107.     SendClientMessage(playerid, -1, "Informe-a ou " COLOR_RED_S " vá embora.");
  108.     SendClientMessage(playerid, COLOR_YELLOW_I, "Faça login com /login [password]");
  109.  
  110.     GetPlayerName(playerid, gPlayerInfo[playerid][playerName], sizeof(playerName));
  111.     return 1;
  112. }
  113.  
  114. public OnPlayerDisconnect(playerid, reason) {
  115.     gPlayerInfo[playerid][playerStatus] = PLAYER_STATUS_DISCONNECTED;
  116.     return 1;
  117. }
  118.  
  119. /*
  120.  * Commands
  121.  */
  122.  
  123. CMD:login(playerid, params[]) {
  124.     if(gPlayerInfo[playerid][playerStatus] != PLAYER_STATUS_LOGIN) {
  125.         return 1;
  126.     }
  127.  
  128.     for(new i; i < sizeof(playerCredentials); i++) {
  129.         if(!strcmp(gPlayerInfo[playerid][playerName], playerCredentials[i][0]) && !strcmp(params, playerCredentials[i][1])) {
  130.             gPlayerInfo[playerid][playerStatus] = PLAYER_STATUS_SELECTION;
  131.             SendClientMessage(playerid, COLOR_GREEN_I, "Você autenticou-se. {FFFFFF}Prossiga com a edição de algum mapa");
  132.            
  133.             return 1;
  134.         }
  135.     }
  136.  
  137.     SendClientMessage(playerid, COLOR_RED_I, "Você errou. {FFFFFF}Tente novamente.");
  138.     return 1;
  139. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top