Advertisement
luisgustavomiki

MyRPG - 0

Mar 18th, 2012
925
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 42.77 KB | None | 0 0
  1. #include <a_samp>
  2. #include <a_mysql>
  3. #include <dns>
  4. #include <streamer>
  5. #include <zcmd>
  6. #include <CTime>
  7.  
  8. native WP_Hash(buffer[], len, const str[]);
  9. native sscanf(const sting[], const pattern[], {Float,_}:...);
  10.  
  11. main() {
  12.     printf("MyRPG: Compilação 1 (0.1) por Stewie`\n \
  13.             \t Luís Gustavo Miki");
  14.     return 1;
  15. }
  16.  
  17. #if defined MAX_PLAYERS
  18.     #undef MAX_PLAYERS
  19. #endif
  20.  
  21. // // // // // // // // // // // // // // // // // // //
  22. //   MyRPG é o nome do gamemode RPG 100% brasileiro   //
  23. //   codado totalmente do 0, para criar um novo       //
  24. //   [i]conceito[/i] de RPG, sendo as coisas mais     //
  25. //   simples mais realístico possivel, apenas com    //
  26. //   restrição de script, fazendo com que o mode    //
  27. //   dê a vontade de tentar tudo.                    //
  28. // // // // // // // // // // // // // // // // // // //
  29. //
  30. //  Creditos iniciais a:
  31. //      + Stewie`   (Luís Gustavo Miki)
  32. //      + BlueX     (Gonçalo Rebelo)
  33. //      + Viih      (Victor Ferraresi)  
  34. //         
  35. //          - Apenas essas pessoas tem os direitos
  36. //            para com o script.
  37. //         
  38. //
  39. //
  40. //
  41. //
  42.  
  43. //
  44. //
  45. //
  46. //
  47. //
  48.  
  49. //
  50. // ESSE GAMEMODE FOI FEITO DO 0 POR LUÍS GUSTAVO MIKI
  51. // POR INTEIRO. TUDO CONTINDO NESSE GAMEMODE E PROPRIEDADE
  52. // DE LUIS GUSTAVO MIKI.
  53. //
  54. // (Partes de outros autores serão mencionados ao decorrer do script)
  55.  
  56.  
  57. // Começo do script:
  58.  
  59. // Constantes importantes
  60.  
  61. new const
  62.     SCRIPT_VERSION[] = "0.1 (Rev 0)",
  63.     SERVER_NAME[] = "RioRPG",
  64.     MAX_PLAYERS = 800,
  65.    
  66.     DB_HOSTNAME[] = "localhost",
  67.     DB_USER[] = "root",
  68.     DB_DB [] = "myrpg",
  69.     DB_PASS[] = "";
  70.    
  71. enum
  72. {
  73.     PLAYER_STAT_JUST_CONNECTED,
  74.     PLAYER_STAT_LOGGING,
  75.     PLAYER_STAT_REGISTER_PROCESS,
  76.     PLAYER_STAT_LOADING,
  77.     PLAYER_STAT_PLAYING,
  78.     PLAYER_STAT_AJAIL
  79. }
  80.  
  81. enum
  82. {
  83.     PLAYER_ATTRIB_CONFIRMED     = 0b1,
  84.     PLAYER_ATTRIB_TRUSTED       = 0b10,
  85.     PLAYER_ATTRIB_VIP_BRONZE    = 0b100,
  86.     PLAYER_ATTRIB_VIP_SILVER    = 0b1000,
  87.     PLAYER_ATTRIB_VIP_GOLD      = 0b10000,
  88.    
  89.     PLAYER_ATTRIB_SEMI_ADMIN    = 0b100000,
  90.     PLAYER_ATTRIB_ADMIM         = 0b1000000,
  91.     PLAYER_ATTRIB_LEAD_ADMIN    = 0b10000000,
  92.     PLAYER_ATTRIB_DEV           = 0b100000000,
  93.     PLAYER_ATTRIB_OWNER         = 0b1000000000
  94. }
  95.  
  96.  
  97. new Float:cDefaultPos[4] = {
  98.     1731.6230,-1276.0973,13.5610,117.5404  
  99. };
  100.  
  101. // Estruturas de dados (enum)
  102. enum E_PLAYER_INFO {
  103.     // Identificação
  104.     gPlayerID,
  105.     gPlayerName[MAX_PLAYER_NAME],
  106.     gPlayerIP[16],
  107.     gPlayerHost[256],
  108.     // Estática (para usar pra carregar dados
  109.     gPlayerReg_Pass[32],
  110.     gPlayerLogin_Tries,
  111.     // Variaveis (SCRIPT/aka OOC)
  112.     gPlayerStat,
  113.     gPlayerAttributes,
  114.     // Variaveis (GAME/ aka IC)
  115.     gPlayerSkin,
  116.     gPlayerLevel,
  117.     gPlayerExp,
  118.     gPlayerCash,
  119.     gPlayerMoney,
  120.     gPlayerPayCheck,
  121.     gPlayerSavings,
  122.     // Familias/Grupos
  123.     gPlayerFamily,
  124.     gPlayerFamilyRank,
  125.     gPlayerFamilyJoin,
  126.     gPlayerJob,
  127.     gPlayerJobRank,
  128.     gPlayerJobTime,
  129.     gPlayerSpawn,
  130.     // PROPERTY_SYSTEM
  131.     gPlayerInside,
  132.     gPlayerPorch
  133. }
  134.  
  135. enum RCAMERA_INFO
  136. {
  137.     Float:rcam_Pos[3],
  138.     Float:rcam_LookAt[3]
  139. }
  140. //
  141.  
  142. // Declarações de variaveis globais
  143. new gPlayerInfo[800][E_PLAYER_INFO];
  144.  
  145. new
  146.     //Language:g_lPortuguese,
  147.     g_dbConnection,
  148.     gstring[1024],
  149.     Text:g_tdStat;
  150.    
  151. new rcamInfo[][RCAMERA_INFO] = {
  152.     {{719.8196, -1984.5413, 0.8574   }, {719.7933,  -1983.5378, 0.7499  }},
  153.     {{842.0169, -1772.2430, 365.1170 }, {841.0131,  -1772.2399, 362.0245}},
  154.     {{1085.8168, -1507.1821, 32.6435 }, {1086.4247, -1506.3833, 32.2360 }},
  155.     {{1138.8068, -1400.2664, 22.4200 }, {1139.8031, -1400.1439, 22.3171 }},
  156.     {{1532.3412, -1361.0857, 341.1450}, {1532.7753, -1361.9911, 339.6769}},
  157.     {{1518.8756, -1628.3341, 18.7397 }, {1519.3651, -1629.2109, 18.6616 }},
  158.     {{1834.7419, -1303.5442, 120.2275}, {1835.5393, -1304.1547, 119.9244}},
  159.     {{1935.7708, -1395.2288, 342.9268}, {1935.7756, -1394.2245, 341.1788}},
  160.     {{2200.1458, -1106.1829, 107.0125}, {2200.9858, -1105.6324, 106.6644}},
  161.     {{2571.9436, -1278.1204, 131.3794}, {2572.5393, -1278.9288, 130.8064}}
  162.                                      
  163. };
  164.  
  165. enum
  166. {
  167.     PROPERTY_ATTRIB_ACTIVE = 0b1,
  168.     PROPERTY_ATTRIB_BUYABLE = 0b10,
  169.     PROPERTY_ATTRIB_SELLABLE = 0b100,
  170.     PROPERTY_ATTRIB_ENTERABLE = 0b1000,
  171.     PROPERTY_ATTRIB_EXITABLE   = 0b10000,
  172.    
  173.     //
  174.     // Static means if the property belongs to
  175.     // a faction, instead of some player.
  176.     // Faction members would have access to
  177.     // the property.
  178.     PROPERTY_ATTRIB_STATIC      = 0b100000 
  179. }
  180. enum
  181. {
  182.     PROPERTY_TYPE_INT = 0,
  183.     PROPERTY_TYPE_HOUSE = 1,
  184.     PROPERTY_TYPE_BUSINESS = 100,
  185.     PROPERTY_TYPE_BUSINESS_GROCERY,
  186.     PROPERTY_TYPE_BUSINESS_BANK,
  187.     PROPERTY_TYPE_BUSINESS_GAS,
  188.     PROPERTY_TYPE_BUSINESS_CASINO,
  189.     PROPERTY_TYPE_BUSINESS_WEAPON
  190. }
  191.  
  192. enum PROPERTY_INFO
  193. {
  194.     bool:prop_Loaded,
  195.     prop_Attrib,
  196.     prop_Type,
  197.     prop_Level,
  198.     prop_Price,
  199.     Float:prop_ExtPos[3],
  200.     prop_ExtProp,
  201.     Float:prop_IntPos[3],
  202.     prop_IntInt,
  203.     prop_Owner,
  204.     prop_Locked,
  205.     prop_Name[32],
  206.     // --------- //
  207.     prop_AreaExt,
  208.     prop_AreaInt,
  209.     prop_PickupExt,
  210.     prop_PickupInt
  211. }
  212. #define MAX_PROPERTIES 1000
  213. new gPropertyInfo[MAX_PROPERTIES][PROPERTY_INFO];
  214.  
  215. new const
  216.     sz_PropertyDump[] = {
  217.         "CREATE TABLE IF NOT EXISTS `familyinfo` ( \
  218.             `id` int(10) NOT NULL AUTO_INCREMENT, \
  219.             `name` varchar(50) NOT NULL, \
  220.             `rank1` varchar(50) NOT NULL, \
  221.             `rank2` varchar(50) NOT NULL, \
  222.             `rank3` varchar(50) NOT NULL, \
  223.             `rank4` varchar(50) NOT NULL, \
  224.             `rank5` varchar(50) NOT NULL, \
  225.             `rank6` varchar(50) NOT NULL, \
  226.             `drogas` int(11) NOT NULL, \
  227.             `materiais` int(11) NOT NULL, \
  228.             `x` double NOT NULL, \
  229.             `y` double NOT NULL, \
  230.             `z` double NOT NULL, \
  231.             PRIMARY KEY (`id`) )" };
  232.  
  233. // Funções Públicas (SA:MP)
  234. //
  235. //
  236.  
  237. public OnGameModeInit()
  238. {
  239.     g_dbConnection = Server_dbConnect();
  240.    
  241.     g_tdStat = TextDrawCreate(319.000000, 435.000000, "  ");
  242.     TextDrawAlignment(g_tdStat, 2);
  243.     TextDrawBackgroundColor(g_tdStat, -256);
  244.     TextDrawFont(g_tdStat, 1);
  245.     TextDrawLetterSize(g_tdStat, 0.300000, 1.200000);
  246.     TextDrawColor(g_tdStat, -1);
  247.     TextDrawSetOutline(g_tdStat, 1);
  248.     TextDrawSetProportional(g_tdStat, 1);
  249.    
  250.     Property_LoadAll();
  251.    
  252.     return 1;
  253. }
  254.  
  255. public OnPlayerConnect(playerid)
  256. {
  257.     TogglePlayerSpectating(playerid, true);
  258.     SetPlayerColor(playerid, -1);
  259.     Player_Init(playerid);
  260.     gPlayerInfo[playerid][gPlayerStat] = PLAYER_STAT_JUST_CONNECTED;
  261.     SendClientMessageFormatted(playerid, -1, "Olá, %s. Bem-vindo ao {FF7F50}%s{/}.",
  262.         gPlayerInfo[playerid][gPlayerName],
  263.         SERVER_NAME
  264.     );
  265.     SendClientMessageFormatted(playerid, -1, "Esse servidor usa o script {FF7F50}MyRPG{FFFFFF} versão {FF7F50}%s.", SCRIPT_VERSION);
  266.     SendClientMessage(playerid, -1, "Creditos para {FF7F50}Stewie{FFFFFF}`, {FF7F50}BlueX{FFFFFF} e {FF7F50}Viih{FFFFFF}.");
  267.  
  268.     return 1;
  269. }
  270.  
  271. public OnReverseDNS(ip[], host[], extra)
  272.     format(gPlayerInfo[extra][gPlayerHost], 256, host);
  273.  
  274.    
  275. enum
  276. {
  277.     DIALOG_NONE,
  278.     DIALOG_REGISTER_1,
  279.     DIALOG_REGISTER_1_CONF,
  280.     DIALOG_REGISTER_1_ERR,
  281.     DIALOG_REGISTER_2,
  282.     DIALOG_EMAIL_YESNO,
  283.     DIALOG_EMAIL_INPUT,
  284.     DIALOG_LOGIN,
  285.     DIALOG_INVENT
  286. }
  287.  
  288. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  289. {
  290.     switch  (dialogid)
  291.     {
  292.         case
  293.             DIALOG_REGISTER_1:
  294.         {
  295.             if(response)
  296.             {
  297.                 if(4 <= strlen(inputtext) < 32)
  298.                 {
  299.                     format(gPlayerInfo[playerid][gPlayerReg_Pass], 32, "%s", inputtext);
  300.                     ShowPlayerDialog(playerid, DIALOG_REGISTER_2, DIALOG_STYLE_PASSWORD, "Passo 2 de 4:", "Digite novamente a senha para confirmar:", "OK", "Voltar");
  301.                 }
  302.                 else
  303.                 {
  304.                     ShowPlayerDialog(playerid, DIALOG_REGISTER_1_ERR, DIALOG_STYLE_MSGBOX, "Erro:", "A sua senha deve ter de 4 a 32 caracteres!", "OK", "");
  305.                 }
  306.             }
  307.             else
  308.             {
  309.                 ShowPlayerDialog
  310.                     (playerid, DIALOG_REGISTER_1_CONF, DIALOG_STYLE_MSGBOX, "Confirmação", "Você deseja mesmo cancelar?\nSe sim, será obrigado a sair do servidor!", "Sim", "Não");
  311.             }
  312.         }
  313.  
  314.         case
  315.             DIALOG_REGISTER_1_CONF:
  316.         {
  317.             if(response)
  318.             {
  319.                 ShowPlayerDialog
  320.                     (playerid, DIALOG_NONE, DIALOG_STYLE_MSGBOX, "Adeus!", "Volte sempre!", "Fechar", "");
  321.                 Kick(playerid);
  322.             }
  323.             else
  324.             {
  325.                 ShowPlayerDialog
  326.                     (playerid, DIALOG_REGISTER_1, DIALOG_STYLE_PASSWORD, "Passo 1 de 4:", "Olá e bem-vindo ao processo de\nimigração para o nosso servidor!\n\tDigite sua senha para próximos logins:", "OK", "Cancelar");
  327.                 SendClientMessage(playerid, -1, "{FF7F50}(( {FFFFFF}Digite abaixo a senha para o seu novo personagem.{FF7F50} ))");
  328.             }
  329.         }
  330.         //break;
  331.         case
  332.             DIALOG_REGISTER_1_ERR:
  333.         {
  334.             ShowPlayerDialog
  335.                 (playerid, DIALOG_REGISTER_1, DIALOG_STYLE_PASSWORD, "Passo 1 de 4:", "Olá e bem-vindo ao processo de\nimigração para o nosso servidor!\n\tDigite sua senha para próximos logins:", "OK", "Cancelar");
  336.         }
  337.         //break;
  338.         case
  339.             DIALOG_REGISTER_2:
  340.         {
  341.             if(response)
  342.             {
  343.                 //printf("inputtext: %s | gPlayerReg_Pass: %s", inputtext, gPlayerInfo[playerid][gPlayerReg_Pass]);
  344.                 if(strcmp(inputtext, gPlayerInfo[playerid][gPlayerReg_Pass], false))
  345.                 {
  346.                     ShowPlayerDialog(playerid, DIALOG_REGISTER_1_ERR, DIALOG_STYLE_MSGBOX, "Erro:", "A senha que você digitou é diferente da confirmação.", "OK", "");
  347.                 }
  348.                 else
  349.                 {
  350.                     ShowPlayerDialog(playerid, DIALOG_EMAIL_YESNO, DIALOG_STYLE_MSGBOX, "Confirmação de e-mail.", "Você deseja inserir um e-mail para confirmação?\nConfirmando um e-mail você tem:\n\t- Um rank de 'usuário confirmado' \
  351.         ingame.\n\t- Vantagens no jogo, como carros exclusivos, propriedades, etc.\n\t- Mais chances de entrar na staff e\n\t- Receber updates sobre a nossa comunidade.\n\nDeseja inserir um e-mail?", "Sim", "Não");
  352.                 }
  353.             }
  354.             else
  355.             {
  356.                 ShowPlayerDialog
  357.                     (playerid, DIALOG_REGISTER_1, DIALOG_STYLE_PASSWORD, "Passo 1 de 4:", "Olá e bem-vindo ao processo de\nimigração para o nosso servidor!\n\tDigite sua senha para próximos logins:", "OK", "Cancelar");
  358.             }
  359.         }
  360.         //break;
  361.         case
  362.             DIALOG_EMAIL_YESNO:
  363.         {
  364.             const bool:enabled = false;
  365.             if(response && enabled)
  366.             {
  367.                 SendClientMessage(playerid, -1, "{FF7F50}(( {FFFFFF}Certo. Você vai registrar o seu e-mail. {FF7F50} ))");
  368.                 ShowPlayerDialog(playerid, DIALOG_EMAIL_INPUT, DIALOG_STYLE_INPUT, "Passo 3 de 4:", "Agora digite o seu e-mail!", "OK", "Cancelar");
  369.             }
  370.             else
  371.             {
  372.                 ShowPlayerDialog(playerid, DIALOG_NONE, DIALOG_STYLE_MSGBOX, "Processando...", "Aguarde enquanto a sua conta é criada\ne você é levado para o mundo...", "", "");
  373.                
  374.                 WP_Hash(gstring, 129, gPlayerInfo[playerid][gPlayerReg_Pass]);
  375.                 mysql_format(g_dbConnection, gstring,
  376.                     "INSERT INTO `player_info` (`name`, `password`) VALUES ('%s', '%s');", gPlayerInfo[playerid][gPlayerName], gstring);
  377.                 mysql_function_query(g_dbConnection, gstring, false, "r@Player_Register", "is", playerid, gPlayerInfo[playerid][gPlayerReg_Pass]);
  378.             }
  379.         }
  380.         case
  381.             DIALOG_LOGIN:
  382.         {
  383.             mysql_format(g_dbConnection, gstring, "SELECT `password` FROM `player_info` WHERE name='%s'", gPlayerInfo[playerid][gPlayerName]);
  384.             mysql_function_query(g_dbConnection, gstring, true, "r@Player_Login", "is", playerid, inputtext);
  385.         }
  386.         //break;
  387.        
  388.        
  389.        
  390.         /* --------------
  391.          * ITEM ---------
  392.         */
  393.         case
  394.             DIALOG_INVENT:
  395.         {
  396.            
  397.         }
  398.     }
  399.     return 1;
  400. }
  401.  
  402. public OnPlayerText(playerid, text[])
  403. {
  404.     if(text[0] == '!')
  405.     {
  406.         strmid(gstring, text, 1, strlen(text));
  407.         format(gstring, sizeof gstring, "/a %s", gstring);
  408.         CallLocalFunction("OnPlayerCommandText", "is", playerid, gstring);
  409.         return 1;
  410.     }
  411.  
  412.     // Use this to prevent SAMP Server to broadcast the text
  413.     return 0;
  414. }
  415.  
  416. public OnPlayerEnterDynamicArea(playerid, areaid)
  417. {
  418.     new index = -1;
  419.     while(++index < MAX_PROPERTIES)
  420.     {
  421.         //
  422.         // This was supposed to be a pointer to the array (lol)
  423.         // Just keep an eye out for silly mistakes
  424.         #define _prp gPropertyInfo[index]
  425.        
  426.         // In the case the current property exterior dynarea
  427.         // matches with the current areaid
  428.         // The same with the other statement down there :)
  429.         if(_prp[prop_AreaExt] == areaid)
  430.         {
  431.             gPlayerInfo[playerid][gPlayerPorch] = index;
  432.             if(Player_IsAdmin(playerid))
  433.                 Property_DisplayData(playerid, index);
  434.             // If the property the player is trying to enter
  435.             // Is actually active
  436.             if(_prp[prop_Attrib] & PROPERTY_ATTRIB_ACTIVE)
  437.             {
  438.                 // If the property has an owner
  439.                 if(_prp[prop_Owner])
  440.                 {
  441.                     Property_SendDoorMessage(playerid, index);
  442.                 }
  443.                 // Else case...
  444.                 else
  445.                 {
  446.                     // If buying the house is allowed
  447.                     // So, summing:
  448.                     // If the player can buy such prop
  449.                     if(_prp[prop_Attrib] & PROPERTY_ATTRIB_BUYABLE)
  450.                     {
  451.                         // If the player has enough level to buy the house
  452.                         if(gPlayerInfo[playerid][gPlayerLevel] >= _prp[prop_Level])
  453.                         {
  454.                             SendClientMessage(playerid, -1, "Esta casa está à {0EAB00}venda{FFFFFF}!");
  455.                             format(gstring, sizeof gstring,
  456.                                 "Preço: {0EAB00}R${FFFFFF}%d,00 / Nível mínimo: {0006AB}%d", _prp[prop_Price], _prp[prop_Level]);
  457.                             SendClientMessage(playerid, -1, gstring);  
  458.                             SendClientMessage(playerid, -1, "    - Para opções, digite {2DD2F7}/prop(riedade){FFFFFF}.");
  459.                         }
  460.                         else
  461.                         {
  462.                             SendClientMessage(playerid, -1, "Esta casa está à {0EAB00}venda{FFFFFF}!");
  463.                             format(gstring, sizeof gstring,
  464.                                 "Preço: {0EAB00}R${FFFFFF}%d,00 / Nível mínimo: {0006AB}%d", _prp[prop_Price], _prp[prop_Level]);
  465.                             SendClientMessage(playerid, -1, gstring);  
  466.                             SendClientMessage(playerid, -1, "    - Infelizmente você não pode comprar esta propriedade...");
  467.                         }
  468.                     }
  469.                     // If the house buying is currently disabled
  470.                     else
  471.                     {
  472.                         SendClientMessage(playerid, -1, "{DE2F4F}(( {FFFFFF}A compra desta propriedade está desabilitada. {DE2F4F}))");
  473.                     }
  474.                 }
  475.             }
  476.             // Else case, let's advise the player :D
  477.             else
  478.             {
  479.                 SendClientMessage(playerid, -1, "{DE2F4F}(( {FFFFFF}Esta propriedade está atualmente desativada. {DE2F4F} ))");
  480.             }
  481.             return 1;
  482.         }
  483.         if(_prp[prop_AreaInt] == areaid)
  484.         {
  485.             return 1;
  486.         }
  487.         #undef _prp
  488.     }
  489.     return 1;
  490. }
  491. public OnPlayerLeaveDynamicArea(playerid, areaid)
  492. {
  493.     if(gPropertyInfo
  494.         [gPlayerInfo[playerid][gPlayerPorch]]
  495.         [prop_AreaInt]  == areaid ||
  496.        gPropertyInfo
  497.         [gPlayerInfo[playerid][gPlayerPorch]]
  498.         [prop_AreaExt]  == areaid ) {
  499.         gPlayerInfo[playerid][gPlayerPorch] = 0;
  500.     }
  501.     return 1;
  502. }
  503.  
  504. // Funções Públicas (Script)
  505. //
  506. //
  507.  
  508. // Server:
  509.     forward Server_dbConnect();
  510.    
  511.    
  512. public Server_dbConnect()
  513. {
  514.     new conn;
  515.     conn = mysql_connect(DB_HOSTNAME, DB_USER, DB_DB, DB_PASS);
  516.    
  517.     if(!conn)
  518.     {
  519.         printf("Failure on Server_dbConnect(), shutting down...");
  520.         SendRconCommand("exit");
  521.         return 0;
  522.     }
  523.     printf("(!) Database connection has succeded!\ng_dbConnection = %d", conn);
  524.     return conn;
  525. }
  526.  
  527. // Player:
  528.     forward Player_Init(playerid);
  529.         forward r@Player_Init(playerid);
  530.     forward Player_Load(playerid);
  531.         forward r@Player_Load(playerid);
  532.     forward Player_BanCheck(playerid);
  533.         forward r@Player_BanCheck(playerid);
  534.     forward Player_Spawn(playerid);
  535.         forward r@Player_Register(playerid, password[]);
  536.         forward r@Player_Login(playerid, password[]);
  537.     stock Player_SetStatLabel(playerid, text[]);
  538.        
  539.    
  540.    
  541. public Player_Init(playerid)
  542. {
  543.     Player_SetStatLabel(playerid, "Obtendo dados do cliente...");
  544.     GetPlayerName(playerid, gPlayerInfo[playerid][gPlayerName], MAX_PLAYER_NAME);
  545.     GetPlayerIp(playerid, gPlayerInfo[playerid][gPlayerIP], 16);
  546.     rdns(gPlayerInfo[playerid][gPlayerIP], playerid);
  547.    
  548.     Player_SetStatLabel(playerid, "Limpando variaveis da sessão anterior...");
  549.     gPlayerInfo[playerid][gPlayerLogin_Tries] = 0;
  550.    
  551.     Player_SetStatLabel(playerid, "Verificando a existencia da conta...");
  552.     mysql_format(g_dbConnection, gstring, "SELECT `id` FROM `player_info` WHERE `name`='%e'", gPlayerInfo[playerid][gPlayerName]);
  553.     mysql_function_query(g_dbConnection, gstring, true, "r@Player_Init", "i", playerid);
  554.     return 1;
  555. }
  556. public r@Player_Init(playerid)
  557. {
  558.     Player_SetStatLabel(playerid, "Dados obtidos, processando...");
  559.     new fields, rows;
  560.     cache_get_data(rows, fields, g_dbConnection);
  561.    
  562.     if(!rows)
  563.     {
  564.         Player_SetStatLabel(playerid, "Conta inexistente!");
  565.         gPlayerInfo[playerid][gPlayerStat] = PLAYER_STAT_REGISTER_PROCESS;
  566.         SendClientMessageFormatted(playerid, -1, "Senhor {FF7F50}%s{FFFFFF}. Parece que é a sua primeira visita aqui, não?",
  567.             gPlayerInfo[playerid][gPlayerName]);
  568.         SendClientMessage(playerid, -1, "Por favor, siga com os próximos passos para obter {FF7F50}visto{FFFFFF} em nosso servidor!");
  569.        
  570.         Player_SetStatLabel(playerid, "Passo 1 de 4");
  571.         ShowPlayerDialog(playerid, DIALOG_REGISTER_1, DIALOG_STYLE_PASSWORD, "Passo 1 de 4:", "Olá e bem-vindo ao processo de\nimigração para o nosso servidor!\n\tDigite sua senha para próximos logins:", "OK", "Cancelar");
  572.         SendClientMessage(playerid, -1, "{FF7F50}(( {FFFFFF}Digite abaixo a senha para o seu novo personagem.{FF7F50} ))");
  573.         return 1;
  574.     }
  575.    
  576.     Player_SetStatLabel(playerid, "Prossiga com o login:");
  577.     gPlayerInfo[playerid][gPlayerStat] = PLAYER_STAT_LOGGING;
  578.     ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login no RioRPG:", "Para efetuar o login no nosso servidor,\ndigite a sua senha abaixo.", "Login", "");
  579.  
  580.     SendClientMessageFormatted(playerid, -1, "Olá denovo, %s. Se deseja fazer o login, digite logo abaixo a sua senha!",
  581.         gPlayerInfo[playerid][gPlayerName]
  582.     );
  583.     return 1;
  584.    
  585. }
  586. public Player_Load(playerid)
  587. {
  588.     Player_SetStatLabel(playerid, "Preparando para carregar...");
  589.     gPlayerInfo[playerid][gPlayerStat] = PLAYER_STAT_LOADING;
  590.     format(gstring, sizeof gstring, "SELECT * FROM `player_info` WHERE `name`='%s'", gPlayerInfo[playerid][gPlayerName]);
  591.     mysql_function_query(g_dbConnection, gstring, true, "r@Player_Load", "i", playerid);
  592.     return 1;
  593. }
  594. public r@Player_Load(playerid)
  595. {
  596.     Player_SetStatLabel(playerid, "Processando dados...");
  597.     new rows, fields;
  598.     cache_get_data(rows, fields);
  599.  
  600.     new buffer[32];
  601.     cache_get_field_content(0, "id",        buffer, g_dbConnection);
  602.     gPlayerInfo[playerid][gPlayerID] = strval(buffer);
  603.     cache_get_field_content(0, "attrib",        buffer, g_dbConnection);
  604.     gPlayerInfo[playerid][gPlayerAttributes] = strval(buffer);
  605.     cache_get_field_content(0, "level",         buffer, g_dbConnection);
  606.     gPlayerInfo[playerid][gPlayerLevel] =       strval(buffer);
  607.     cache_get_field_content(0, "exp",           buffer, g_dbConnection);
  608.     gPlayerInfo[playerid][gPlayerExp] =         strval(buffer);
  609.     cache_get_field_content(0, "cash",          buffer, g_dbConnection);
  610.     gPlayerInfo[playerid][gPlayerCash] =        strval(buffer);
  611.     cache_get_field_content(0, "money",         buffer, g_dbConnection);
  612.     gPlayerInfo[playerid][gPlayerMoney] =       strval(buffer);
  613.     cache_get_field_content(0, "paycheck",      buffer, g_dbConnection);
  614.     gPlayerInfo[playerid][gPlayerPayCheck] =    strval(buffer);
  615.     cache_get_field_content(0, "savings",       buffer, g_dbConnection);
  616.     gPlayerInfo[playerid][gPlayerSavings] =     strval(buffer);
  617.     cache_get_field_content(0, "family",        buffer, g_dbConnection);
  618.     gPlayerInfo[playerid][gPlayerFamily] =      strval(buffer);
  619.     cache_get_field_content(0, "familyrank",    buffer, g_dbConnection);
  620.     gPlayerInfo[playerid][gPlayerFamilyRank] =  strval(buffer);
  621.     cache_get_field_content(0, "familyjoin",    buffer, g_dbConnection);
  622.     gPlayerInfo[playerid][gPlayerFamilyJoin] =  strval(buffer);
  623.     cache_get_field_content(0, "job",           buffer, g_dbConnection);
  624.     gPlayerInfo[playerid][gPlayerJob] =         strval(buffer);
  625.     cache_get_field_content(0, "jobrank",       buffer, g_dbConnection);
  626.     gPlayerInfo[playerid][gPlayerJobRank] =     strval(buffer);
  627.     cache_get_field_content(0, "jobtime",       buffer, g_dbConnection);
  628.     gPlayerInfo[playerid][gPlayerJobTime] =     strval(buffer);
  629.     cache_get_field_content(0, "spawn",         buffer, g_dbConnection);
  630.     gPlayerInfo[playerid][gPlayerSpawn] =       strval(buffer);
  631.     cache_get_field_content(0, "skin",      buffer, g_dbConnection);
  632.     gPlayerInfo[playerid][gPlayerSkin] =        strval(buffer);
  633.    
  634.     Player_SetStatLabel(playerid, "Verificando bans...");
  635.     Player_BanCheck(playerid);
  636.     return 1;
  637. }
  638.  
  639. enum
  640. {
  641.     RECORD_TYPE_COMMENT,
  642.     RECORD_TYPE_BAN,
  643.     RECORD_TYPE_KICK,
  644.     RECORD_TYPE_AJAIL
  645. }
  646. public Player_BanCheck(playerid)
  647. {
  648.     format(gstring, sizeof gstring, "SELECT `record_info`.*, `player_info`.`name` AS adminname FROM `record_info` INNER JOIN `player_info` ON `record_info`.`admin` = `player_info`.`id` WHERE `record_info`.`lifted`=0 AND `record_info`.`type`=1 AND (`record_info`.`stamp`+`record_info`.`time` < UNIX_TIMESTAMP() OR `record_info`.`time`=-1) AND `record_info`.`pid`=%d", gPlayerInfo[playerid][gPlayerID]);
  649.     mysql_function_query(g_dbConnection, gstring, true, "r@Player_BanCheck", "i", playerid);
  650.     return 1;
  651. }
  652.  
  653. public r@Player_BanCheck(playerid)
  654. {
  655.     new rows, fields;
  656.     cache_get_data(rows, fields, g_dbConnection);
  657.  
  658.     if(rows)
  659.     { // Vish. Sujou pros irmão :P
  660.         SendClientMessage(playerid, -1, " ");
  661.         SendClientMessage(playerid, -1, " ");
  662.         SendClientMessage(playerid, -1, "Você tem os seguintes bans (não expirados/eternos) adicionados a você:");
  663.  
  664.         new index = -1;
  665.         while(++index < rows)
  666.         {
  667.             enum RI_RESULT_INFO
  668.             {
  669.                 _ri_id,
  670.                 _ri_pid,
  671.                 _ri_type,
  672.                 _ri_stamp,
  673.                 _ri_reason[255],
  674.                 _ri_time,
  675.                 _ri_admin,
  676.                 _ri_lifted,
  677.                 _ri_liftadmin,
  678.                 _ri_liftreason[255],
  679.                 _ri_adminname[MAX_PLAYER_NAME]
  680.             }
  681.             new result[RI_RESULT_INFO],
  682.                 buffer[64];
  683.  
  684.             cache_get_field_content(index, "id", buffer, g_dbConnection);
  685.             result[_ri_id] = strval(buffer);
  686.             cache_get_field_content(index, "pid", buffer, g_dbConnection);
  687.             result[_ri_pid] = strval(buffer);
  688.             cache_get_field_content(index, "type", buffer, g_dbConnection);
  689.             result[_ri_type] = strval(buffer);
  690.             cache_get_field_content(index, "stamp", buffer, g_dbConnection);
  691.             result[_ri_stamp] = strval(buffer);
  692.             cache_get_field_content(index, "reason", result[_ri_reason], g_dbConnection);
  693.             cache_get_field_content(index, "time", buffer, g_dbConnection);
  694.             result[_ri_time] = strval(buffer);
  695.             cache_get_field_content(index, "admin", buffer, g_dbConnection);
  696.             result[_ri_admin] = strval(buffer);
  697.             cache_get_field_content(index, "lifted", buffer, g_dbConnection);
  698.             result[_ri_lifted] = strval(buffer);
  699.             cache_get_field_content(index, "liftadmin", buffer, g_dbConnection);
  700.             result[_ri_liftadmin] = strval(buffer);
  701.             cache_get_field_content(index, "liftreason", result[_ri_liftreason], g_dbConnection);
  702.             cache_get_field_content(index, "adminname", result[_ri_adminname], g_dbConnection);
  703.  
  704.             new
  705.                 tm<tmTime>;
  706.             localtime(Time:result[_ri_stamp], tmTime);
  707.             strftime(buffer, sizeof buffer, "%A, %d de %B de %Y (%X)", tmTime);
  708.  
  709.             format(gstring, sizeof gstring, " - {C0C0C0}%s, {FFFFFF}pelo administrador {C0C0C0}%s:", buffer, result[_ri_adminname]);
  710.             SendClientMessage(playerid, -1, gstring);
  711.             format(gstring, sizeof gstring, "   {C0C0C0}Motivo: {FFFFFF}%s", result[_ri_reason]);
  712.             SendClientMessage(playerid, -1, gstring);
  713.  
  714.             buffer[0] = 0;
  715.             strcat(buffer, "Nunca");
  716.             if(result[_ri_time] != -1)
  717.             {
  718.                 localtime(Time:result[_ri_stamp] + Time:result[_ri_time], tmTime);
  719.                 strftime(buffer, sizeof buffer, "%A, %d de %B de %Y (%X)", tmTime);
  720.             }
  721.             format(gstring, sizeof gstring, "   {C0C0C0}Expira em: {FFFFFF}%s", buffer);
  722.             SendClientMessage(playerid, -1, gstring);
  723.  
  724.  
  725.  
  726.  
  727.         }
  728.         Kick(playerid);
  729.         return 1;
  730.     }
  731.  
  732.     Player_SetStatLabel(playerid, "Feito! Voce está sendo levado ao mundo!");
  733.     Player_Spawn(playerid);
  734.     return 1;
  735. }
  736.  
  737.  
  738. public r@Player_Register(playerid, password[])
  739. {
  740.     SendClientMessageFormatted(playerid, -1, "Senhor {2ADFE8}%s{FFFFFF}. Você foi autorizado com sucesso em nossa cidade.", gPlayerInfo[playerid][gPlayerName]);
  741.     SendClientMessage(playerid, -1, "Deseja que eu te guie numa pequena volta na nossa cidade?");
  742.     SendClientMessage(playerid, -1, "{2A6DE8}(( {FFFFFF}Lembrando que você pode ver o tutorial quando você quiser, digitando /tutorial{2A6DE8} ))");
  743.     SendClientMessageFormatted(playerid, -1, "(( {WHITE}Sua senha é %s. Se você registrou seu e-mail, uma cópia foi mandada para o mesmo.{/} ))",
  744.         password
  745.     );
  746.    
  747.     mysql_store_result(g_dbConnection);
  748.     new insert = mysql_insert_id(g_dbConnection);
  749.     mysql_free_result(g_dbConnection);
  750.  
  751.     SendClientMessageFormatted(playerid, -1, "Você se registrou como {1E90FF}%q{FFFFFF}.", gPlayerInfo[playerid][gPlayerName]);
  752.     SendClientMessageFormatted(playerid, -1, "Você pode ter suporte mais rápido fornecendo o seu número a um administrador, que no caso é {C0C0C0}%d{FFFFFF}.", insert);
  753.  
  754.     SendClientMessage(playerid, -1, "     - Para obter informações gerais sobre você e o servidor, digite {C0C0C0}/info{FFFFFF}.");
  755.     SendClientMessage(playerid, -1, "     - Para verificar seus documentos, digite {C0C0C0}/inventário{FFFFFF} (Serve também para outros itens).");
  756.     SendClientMessage(playerid, -1, "{C0C0C0}Se perder sua Identidade, você pode tirar uma cópia em uma delegacia local...");
  757.     SendClientMessage(playerid, -1, "Não exite em procurar por uma administrador para obter ajuda! Para informações gerais, novamente, digite {C0C0C0}/info{FFFFFF}");
  758.     Player_Load(playerid);
  759.     return 1;
  760. }
  761.  
  762. public r@Player_Login(playerid, password[])
  763. {
  764.     new
  765.         hash_pass[129];
  766.     WP_Hash(hash_pass, sizeof hash_pass, password);
  767.     cache_get_field_content(0, "password", gstring, g_dbConnection);
  768.    
  769.     new result = strcmp(hash_pass, gstring, true);
  770.    
  771.    
  772.    
  773.     if(!result)
  774.     {
  775.         SendClientMessage(playerid, -1, "{FF7F50}(( {FFFFFF}Aguarde enquanto você é carregado e levado ao mundo...{FF7F50} ))");
  776.         Player_SetStatLabel(playerid, "Carregando!");
  777.         Player_Load(playerid);
  778.     }
  779.     else
  780.     {
  781.         if(gPlayerInfo[playerid][gPlayerLogin_Tries] == 3)
  782.         {
  783.             SendClientMessage(playerid, -1, "Você foi {E01B35}despejado{FFFFFF} por exceder as tentativas máximas de login!");
  784.             Kick(playerid);
  785.         }
  786.         else
  787.         {
  788.             gPlayerInfo[playerid][gPlayerLogin_Tries] ++;
  789.             ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login no RioRPG:", "\tSenha errada!\nPara efetuar o login no nosso servidor,\ndigite a sua senha abaixo.", "Login", "");
  790.         }
  791.     }
  792.     return 1;
  793. }
  794.  
  795. public Player_Spawn(playerid)
  796. {
  797.     if(!gPlayerInfo[playerid][gPlayerSpawn])
  798.         SetSpawnInfo(playerid, 0, gPlayerInfo[playerid][gPlayerSkin], cDefaultPos[0], cDefaultPos[1], cDefaultPos[2], cDefaultPos[3], 0, 0, 0, 0, 0, 0);
  799.     else
  800.     {
  801.         //
  802.     }
  803.     TogglePlayerSpectating(playerid, false);
  804.     gPlayerInfo[playerid][gPlayerStat] = PLAYER_STAT_PLAYING;
  805.     SpawnPlayer(playerid);
  806.     Player_SetStatLabel(playerid, "  ");
  807.     return 1;
  808. }
  809.  
  810. stock Player_SetStatLabel(playerid, text[])
  811. {
  812.     TextDrawSetString(g_tdStat, text);
  813.     TextDrawShowForPlayer(playerid, g_tdStat);
  814.     return 1;
  815. }
  816.  
  817.  
  818.  
  819.  
  820.  
  821.  
  822.  
  823.  
  824. /* Item System */
  825. enum ITEM_INFO
  826. {
  827.     gItemName[64],
  828.     gItemType,
  829.     Float:gItemExtra
  830. }
  831.  
  832. enum
  833. {
  834.     ITEM_TYPE_ID,
  835.     ITEM_TYPE_CASH
  836. }
  837.  
  838. new const
  839.     gItemInfo[][ITEM_INFO] = {
  840.         {"Identidade", ITEM_TYPE_ID, 0.0},
  841.         {"Dinheiro", ITEM_TYPE_CASH, 0.0}
  842.     };
  843.  
  844. /* PLAYER INVENT */
  845. #define MAX_ITEMS_PER_PAGE 10
  846. forward Invent_Show(playerid); //
  847. forward r@Invent_Show(playerid);
  848.  
  849. CMD:inventario(playerid, params[], help)
  850. {
  851.     #pragma unused params
  852.     #pragma unused help
  853.     if(gPlayerInfo[playerid][gPlayerStat] != PLAYER_STAT_PLAYING)
  854.     {
  855.         return 1;
  856.     }
  857.     Invent_Show(playerid);
  858.     return 1;
  859. }
  860.  
  861. public Invent_Show(playerid)
  862. {
  863.     if(gPlayerInfo[playerid][gPlayerStat] < PLAYER_STAT_PLAYING)
  864.         return 1;
  865.    
  866.     format(gstring, sizeof gstring, "SELECT * FROM `inventory_info` WHERE `pid`=%d", gPlayerInfo[playerid][gPlayerID]);
  867.     mysql_function_query(g_dbConnection, gstring, true, "r@Invent_Show", "i", playerid);
  868.     return 1;
  869. }
  870.  
  871. public r@Invent_Show(playerid)
  872. {
  873.     new rows, fields;
  874.     cache_get_data(rows, fields, g_dbConnection);
  875.    
  876.     gstring[0] = 0;
  877.     new temp[64], title[64];
  878.     format(title, sizeof title, "Inventário (%s):", gPlayerInfo[playerid][gPlayerName]);
  879.    
  880.     //declare gstring[];
  881.     for(new i; i < rows; i++)
  882.     {
  883.         new
  884.             item;
  885.         cache_get_field_content(i, "item", temp, g_dbConnection);
  886.         item = strval(temp);
  887.        
  888.         format(temp, sizeof temp, "[%d] - %s\n", i, gItemInfo[item][gItemName]);
  889.         strcat(gstring, temp);
  890.     }
  891.     ShowPlayerDialog(playerid, DIALOG_INVENT, DIALOG_STYLE_LIST, title, gstring, "Selecionar", "Sair");
  892.     return 1;
  893. }
  894.  
  895.  
  896. //
  897. //
  898. //
  899. // PROPERTY SYSTEM
  900. //
  901. forward Property_LoadAll();
  902.     forward r@Property_LoadAll();
  903. forward Property_SetAll();
  904.  
  905. public Property_LoadAll()
  906. {
  907.     static block;  
  908.     if(block)
  909.         return 1;
  910.     block = 1;
  911.    
  912.     printf("Preparando para carregar as propriedades...");
  913.    
  914.     mysql_function_query(g_dbConnection, "SELECT * FROM `property_info`", true, "r@Property_LoadAll", "");
  915.     return 1;
  916. }
  917.  
  918. public r@Property_LoadAll()
  919. {
  920.     new rows, fields, index = -1;
  921.     cache_get_data(rows, fields, g_dbConnection);
  922.    
  923.     while(++index < rows)
  924.     {
  925.         new buffer[32], id;
  926.         cache_get_field_content(index, "id", buffer, g_dbConnection);
  927.         id = strval(buffer);
  928.        
  929.         if(id >= MAX_PROPERTIES)
  930.             continue;
  931.        
  932.         // General Info
  933.         cache_get_field_content(index, "attrib", buffer, g_dbConnection);
  934.         gPropertyInfo[id][prop_Attrib] = strval(buffer);
  935.         cache_get_field_content(index, "type", buffer, g_dbConnection);
  936.         gPropertyInfo[id][prop_Type] = strval(buffer);
  937.         cache_get_field_content(index, "level", buffer, g_dbConnection);
  938.         gPropertyInfo[id][prop_Level] = strval(buffer);
  939.         cache_get_field_content(index, "price", buffer, g_dbConnection);
  940.         gPropertyInfo[id][prop_Price] = strval(buffer);
  941.        
  942.         // Position Info
  943.         //
  944.         // ext_
  945.         cache_get_field_content(index, "ext_x", buffer, g_dbConnection);
  946.         gPropertyInfo[id][prop_ExtPos][0] = floatstr(buffer);
  947.         cache_get_field_content(index, "ext_y", buffer, g_dbConnection);
  948.         gPropertyInfo[id][prop_ExtPos][1] = floatstr(buffer);
  949.         cache_get_field_content(index, "ext_z", buffer, g_dbConnection);
  950.         gPropertyInfo[id][prop_ExtPos][2] = floatstr(buffer);
  951.         cache_get_field_content(index, "ext_prop", buffer, g_dbConnection);
  952.         gPropertyInfo[id][prop_ExtProp] = strval(buffer);
  953.        
  954.         //
  955.         // int_
  956.         cache_get_field_content(index, "int_x", buffer, g_dbConnection);
  957.         gPropertyInfo[id][prop_IntPos][0] = floatstr(buffer);
  958.         cache_get_field_content(index, "int_y", buffer, g_dbConnection);
  959.         gPropertyInfo[id][prop_IntPos][1] = floatstr(buffer);
  960.         cache_get_field_content(index, "int_z", buffer, g_dbConnection);
  961.         gPropertyInfo[id][prop_IntPos][2] = floatstr(buffer);
  962.         cache_get_field_content(index, "int_int", buffer, g_dbConnection);
  963.         gPropertyInfo[id][prop_IntInt] = strval(buffer);
  964.        
  965.         //
  966.         // Game Info
  967.         cache_get_field_content(index, "owner", buffer, g_dbConnection);
  968.         gPropertyInfo[id][prop_Owner] = strval(buffer);
  969.         cache_get_field_content(index, "locked", buffer, g_dbConnection);
  970.         gPropertyInfo[id][prop_Locked] = strval(buffer);
  971.         cache_get_field_content(index, "name", gPropertyInfo[id][prop_Name], g_dbConnection);
  972.        
  973.         gPropertyInfo[id][prop_Loaded] = true;
  974.        
  975.         printf("-- PROP: %d CARREGADA: ex: %.2f | ey: %.2f | ez %.2f", id, gPropertyInfo[id][prop_ExtPos][0], gPropertyInfo[id][prop_ExtPos][1], gPropertyInfo[id][prop_ExtPos][2]);
  976.     }
  977.     Property_SetAll();
  978.     return 1;
  979. }
  980.  
  981. public Property_SetAll()
  982. {
  983.     static block;  
  984.     if(block)
  985.         return 1;
  986.     block = 1;
  987.    
  988.     new index = -1;
  989.     while(++index < MAX_PROPERTIES)
  990.         if(gPropertyInfo[index][prop_Loaded])
  991.         {
  992.             if(gPropertyInfo[index][prop_Attrib] & PROPERTY_ATTRIB_ENTERABLE)
  993.             {
  994.                 printf("PROP %d ENTERABLE!", index);
  995.                 gPropertyInfo[index][prop_AreaExt] = CreateDynamicSphere(gPropertyInfo[index][prop_ExtPos][0], gPropertyInfo[index][prop_ExtPos][1], gPropertyInfo[index][prop_ExtPos][2], 2.0, gPropertyInfo[index][prop_ExtProp], gPropertyInfo[gPropertyInfo[index][prop_ExtProp]][prop_IntInt]);
  996.                 gPropertyInfo[index][prop_PickupExt] = CreateDynamicPickup(1318, 1, gPropertyInfo[index][prop_ExtPos][0], gPropertyInfo[index][prop_ExtPos][1], gPropertyInfo[index][prop_ExtPos][2], gPropertyInfo[index][prop_ExtProp], gPropertyInfo[gPropertyInfo[index][prop_ExtProp]][prop_IntInt]);
  997.             }
  998.             if(gPropertyInfo[index][prop_Attrib] & PROPERTY_ATTRIB_EXITABLE)
  999.             {
  1000.                 gPropertyInfo[index][prop_AreaInt] = CreateDynamicSphere(gPropertyInfo[index][prop_IntPos][0], gPropertyInfo[index][prop_IntPos][1], gPropertyInfo[index][prop_IntPos][2], 2.0, index, gPropertyInfo[index][prop_IntInt]);
  1001.                 gPropertyInfo[index][prop_PickupInt] = CreateDynamicPickup(1318, 1, gPropertyInfo[index][prop_IntPos][0], gPropertyInfo[index][prop_IntPos][1], gPropertyInfo[index][prop_IntPos][2], index, gPropertyInfo[index][prop_IntInt]);
  1002.             }
  1003.         }
  1004.     return 1;
  1005. }
  1006.  
  1007. //
  1008. //
  1009. //
  1010. // FACTION SYSTEM
  1011. //
  1012. //
  1013. enum {
  1014.     MAX_FACTIONS = 25
  1015. }
  1016. enum FACTION_RANK_INFO
  1017. {
  1018.     fact_Rank1[32],
  1019.     fact_Rank2[32],
  1020.     fact_Rank3[32],
  1021.     fact_Rank4[32],
  1022.     fact_Rank5[32],
  1023.     fact_Rank6[32],
  1024.     fact_Rank7[32],
  1025.     fact_Rank8[32],
  1026.     fact_Rank9[32],
  1027.     fact_Rank10[32]
  1028. }
  1029. enum FACTION_INFO
  1030. {
  1031.     fact_Name[32],
  1032.     fact_Type,
  1033.     Float:fact_Pos[3],
  1034.     fact_Ranks[FACTION_RANK_INFO]
  1035. }
  1036. new gFactionInfo[MAX_FACTIONS][FACTION_INFO];
  1037.  
  1038. forward Faction_LoadAll();
  1039.     forward r@Faction_LoadAll();
  1040.  
  1041. public Faction_LoadAll()
  1042.     return mysql_function_query(g_dbConnection, "SELECT * FROM `faction_info`", true, "r@Faction_LoadAll", "");
  1043. public r@Faction_LoadAll()
  1044. {
  1045.     new rows, fields;
  1046.     cache_get_data(rows, fields, g_dbConnection);
  1047.  
  1048.     new index = -1;
  1049.     while(++index < rows)
  1050.     {
  1051.         new buffer[32], id;
  1052.  
  1053.         cache_get_field_content(index, "id", buffer, g_dbConnection);
  1054.         id = strval(buffer);
  1055.  
  1056.         if((id + 1) >= MAX_FACTIONS)
  1057.             continue;
  1058.  
  1059.         cache_get_field_content(index, "name", gFactionInfo[id][fact_Name], g_dbConnection);
  1060.         cache_get_field_content(index, "type", buffer, g_dbConnection);
  1061.         gFactionInfo[id][fact_Type] = strval(buffer);
  1062.  
  1063.         cache_get_field_content(index, "x", buffer, g_dbConnection);
  1064.         gFactionInfo[id][fact_Pos][0] = floatstr(buffer);
  1065.         cache_get_field_content(index, "y", buffer, g_dbConnection);
  1066.         gFactionInfo[id][fact_Pos][1] = floatstr(buffer);
  1067.         cache_get_field_content(index, "z", buffer, g_dbConnection);
  1068.         gFactionInfo[id][fact_Pos][2] = floatstr(buffer);
  1069.  
  1070.         cache_get_field_content(index, "rank1", gFactionInfo[id][fact_Ranks][fact_Rank1], g_dbConnection);
  1071.         cache_get_field_content(index, "rank2", gFactionInfo[id][fact_Ranks][fact_Rank2], g_dbConnection);
  1072.         cache_get_field_content(index, "rank3", gFactionInfo[id][fact_Ranks][fact_Rank3], g_dbConnection);
  1073.         cache_get_field_content(index, "rank4", gFactionInfo[id][fact_Ranks][fact_Rank4], g_dbConnection);
  1074.         cache_get_field_content(index, "rank5", gFactionInfo[id][fact_Ranks][fact_Rank5], g_dbConnection);
  1075.         cache_get_field_content(index, "rank6", gFactionInfo[id][fact_Ranks][fact_Rank6], g_dbConnection);
  1076.         cache_get_field_content(index, "rank7", gFactionInfo[id][fact_Ranks][fact_Rank7], g_dbConnection);
  1077.         cache_get_field_content(index, "rank8", gFactionInfo[id][fact_Ranks][fact_Rank8], g_dbConnection);
  1078.         cache_get_field_content(index, "rank9", gFactionInfo[id][fact_Ranks][fact_Rank9], g_dbConnection);
  1079.         cache_get_field_content(index, "rank10", gFactionInfo[id][fact_Ranks][fact_Rank10], g_dbConnection);
  1080.     }
  1081.     return 1;
  1082. }
  1083.  
  1084. CMD:faction(playerid, params[])
  1085.     cmd_faccao(playerid, params);
  1086. CMD:faccao(playerid, params[])
  1087. {
  1088.     if(gPlayerInfo[playerid][gPlayerStat] < PLAYER_STAT_PLAYING)
  1089.         return 1;
  1090.     if(gPlayerInfo[playerid][gPlayerFamily] == 0)
  1091.         return 1;
  1092.  
  1093.     SendClientMessage(playerid, 0xC0C0C0AA, "Membros Conectados:");
  1094.     new index = -1, buffer[64];
  1095.     while(++index < MAX_PLAYERS)
  1096.         if(gPlayerInfo[index][gPlayerStat] >= PLAYER_STAT_PLAYING)
  1097.             if(gPlayerInfo[playerid][gPlayerFamily] == gPlayerInfo[index][gPlayerFamily])
  1098.             {
  1099.                 //new realrank = gPlayerInfo[index][gPlayerFamilyRank] - 1;
  1100.                 format(buffer, sizeof buffer, "(ID: %d) {C0C0C0}%s %s.",
  1101.                     index,
  1102.                     gPlayerInfo[index][gPlayerName],
  1103.                     GetPlayerRank(playerid)
  1104.                 );
  1105.                 SendClientMessage(playerid, 0x008000AA, buffer);
  1106.             }
  1107.     return 1;
  1108. }
  1109.  
  1110. CMD:f(playerid, params[])
  1111. {
  1112.     if(gPlayerInfo[playerid][gPlayerStat] < PLAYER_STAT_PLAYING)
  1113.         return 1;
  1114.     if(gPlayerInfo[playerid][gPlayerFamily] == 0)
  1115.         return 1;
  1116.     if(!params[0])
  1117.     {
  1118.         SendClientMessage(playerid, 0x00CAC5AA,
  1119.             "FamilyCmd: {FFFFFF}/f(amilia) [texto] {C0C0C0}- Manda uma mensagem para a sua família."
  1120.         );
  1121.         return 1;
  1122.     }
  1123.  
  1124.     format(gstring, sizeof gstring,
  1125.         "(( %s %s: {FFFFFF}%s {00CAC5} ))",
  1126.         GetPlayerRank(playerid),
  1127.         gPlayerInfo[playerid][gPlayerName],
  1128.         params
  1129.     );
  1130.  
  1131.     new index = -1;
  1132.     while(++index < MAX_PLAYERS)
  1133.     {
  1134.         if(gPlayerInfo[index][gPlayerFamily] == gPlayerInfo[playerid][gPlayerFamily])
  1135.             SendClientMessage(playerid, 0x00CAC5FF, gstring);
  1136.     }
  1137.     return 1;
  1138. }
  1139. GetPlayerRank(playerid)
  1140. {
  1141.     new
  1142.         rank[32] = "Civil",
  1143.         pr       = gPlayerInfo[playerid][gPlayerFamilyRank];
  1144.     if(!gPlayerInfo[playerid][gPlayerFamily])
  1145.         return rank;
  1146.     if(!(0 < pr < 16))
  1147.         return rank;
  1148.  
  1149.     pr -= 1;
  1150.  
  1151.     format(rank, 32, "%s",
  1152.         gFactionInfo[gPlayerInfo[playerid][gPlayerFamily]][fact_Ranks][FACTION_RANK_INFO:pr]);
  1153.     return rank;
  1154. }
  1155.  
  1156. //
  1157. //
  1158. // Admin System
  1159. //
  1160. //
  1161. forward r@Admin_Ban(playerid, targetid, days, reason[]);
  1162. CMD:ban(playerid, params[])
  1163. {
  1164.     if(!Player_IsAdmin(playerid))
  1165.         return 0;
  1166.  
  1167.     new targetid,
  1168.         reason[120],
  1169.         days;
  1170.  
  1171.     if(sscanf(params, "rs[120]I(-1)", targetid, reason, days))
  1172.     {
  1173.         SendClientMessage(playerid, 0xFF6F6FAA, "AdmCmd: {FFFFFF}/ban [playerid] [motivo] [dias (= -1)] -{C0C0C0} Bane um player.");
  1174.         SendClientMessage(playerid, 0xC0C0C0FF, "          Para banir um jogador temporariamente, digite os dias. Para banir permanentemente, digite \"-1\" ou deixe em branco.");
  1175.         return 1;
  1176.     }
  1177.  
  1178.     if(gPlayerInfo[playerid][gPlayerStat] < PLAYER_STAT_PLAYING)
  1179.         return SendClientMessage(playerid, 0xFF6F6FAA, "AdmCmd: {FFFFFF}/ban {C0C0C0}- O player não está logado!");
  1180.  
  1181.     if(Player_IsAdmin(targetid))
  1182.     {
  1183.         if(!(gPlayerInfo[playerid][gPlayerAttributes] & PLAYER_ATTRIB_LEAD_ADMIN))
  1184.         {
  1185.             SendClientMessage(playerid, 0xFF6F6FAA, "AdmCmd: {FFFFFF}/ban {C0C0C0}- Bans em admins só podem ser adicionados por Lead-Admins!");
  1186.             return 1;
  1187.         }
  1188.     }
  1189.  
  1190.     format(gstring, sizeof gstring,
  1191.         "INSERT INTO `record_info` (`pid`,`type`,`stamp`,`reason`,`time`,`admin`) VALUES(%d,%d,UNIX_TIMESTAMP(),'%s',%d,%d)",
  1192.         gPlayerInfo[targetid][gPlayerID], RECORD_TYPE_BAN, reason, days * 24 * 60 * 60, gPlayerInfo[playerid][gPlayerID]);
  1193.     mysql_function_query(g_dbConnection, gstring, false, "r@Admin_Ban", "iiis", playerid, targetid, days, reason);
  1194.     SendClientMessage(playerid, -1, "Processndo, aguarde...");
  1195.     return 1;
  1196. }
  1197. public r@Admin_Ban(playerid, targetid, days, reason[])
  1198. {
  1199.     mysql_store_result(g_dbConnection); new id = mysql_insert_id(g_dbConnection); mysql_free_result(g_dbConnection);
  1200.     if(days != -1)
  1201.         format(gstring, sizeof gstring, "AdmCmd: %s foi banido por %s. Motivo: %s", gPlayerInfo[targetid][gPlayerName], gPlayerInfo[playerid][gPlayerName], reason);
  1202.     else
  1203.         format(gstring, sizeof gstring, "AdmCmd: %s foi banido temporariamente por %s. Motivo: %s", gPlayerInfo[targetid][gPlayerName], gPlayerInfo[playerid][gPlayerName], reason);
  1204.     SendClientMessageToAll(0xFF6F6FAA, gstring);
  1205.  
  1206.     format(gstring, sizeof gstring,
  1207.         "Você adicionou com sucesso um ban a %s (PID:%d) - Para consultas futuras, a ID do ban é: {C0C0C0}%d.",
  1208.         gPlayerInfo[playerid][gPlayerName], gPlayerInfo[playerid][gPlayerID], id);
  1209.     SendClientMessage(playerid, -1, gstring);
  1210.  
  1211.     Kick(targetid);
  1212.  
  1213.     return 1;
  1214. }
  1215.  
  1216.  
  1217.  
  1218.  
  1219. //
  1220. //
  1221. // Local Functions
  1222. //
  1223. #define prquick%0(%1) forward%0(%1);public%0(%1)
  1224. Property_DisplayData(playerid, propertyid)
  1225. {
  1226.     if(!gPropertyInfo[propertyid][prop_Loaded])
  1227.         return SendClientMessage(playerid, -1, "{44436E}DEV_ERR: {FFFFFF}Propriedade não-carregada.");
  1228.    
  1229.     #define _prp gPropertyInfo[propertyid]
  1230.     format(gstring, sizeof gstring, "PROPRIEDADE: %d [Nome: %s] | Dono: (PID)%d | Type: %d | Level: %d | Preço: %d",
  1231.         propertyid, _prp[prop_Name], _prp[prop_Owner], _prp[prop_Type], _prp[prop_Level], _prp[prop_Price]);
  1232.     SendClientMessage(playerid, 0x9F9DD1FF, gstring);
  1233.     format(gstring, sizeof gstring, " -- ATRIBUTOS: Ativa: %d | Comprável: %d | Vendivel: %d | Entrável: %d | Saível: %d",
  1234.         _prp[prop_Attrib]&PROPERTY_ATTRIB_ACTIVE,
  1235.         _prp[prop_Attrib]&PROPERTY_ATTRIB_BUYABLE,
  1236.         _prp[prop_Attrib]&PROPERTY_ATTRIB_SELLABLE,
  1237.         _prp[prop_Attrib]&PROPERTY_ATTRIB_ENTERABLE,
  1238.         _prp[prop_Attrib]&PROPERTY_ATTRIB_EXITABLE);
  1239.     SendClientMessage(playerid, 0x9F9DD1FF, gstring);
  1240.     #undef _prp
  1241.     return 1;
  1242. }
  1243. Property_SendDoorMessage(playerid, propertyid)
  1244. {
  1245.     if(gPropertyInfo[propertyid][prop_Attrib] & PROPERTY_ATTRIB_STATIC)
  1246.     {
  1247.         //Property_SendDoorMessage_s(playerid, propertyid, gFactionInfo[gPropertyInfo[propertyid][prop_Owner]][fact_Name]);
  1248.     }
  1249.     else
  1250.     {
  1251.         format(gstring, sizeof gstring, "SELECT `name` FROM `player_info` WHERE `id`=%d", gPlayerInfo[playerid][gPlayerID]);
  1252.         mysql_function_query(g_dbConnection, gstring, true, "r@Property_SendDoorMessage", "ii", playerid, propertyid);
  1253.     }
  1254.     return 1;
  1255. }
  1256.  
  1257. prquick r@Property_SendDoorMessage(playerid, propertyid)
  1258. {
  1259.     new buff[32];
  1260.     cache_get_field_content(0, "name", buff, g_dbConnection);
  1261.     Property_SendDoorMessage_s(playerid, propertyid, buff);
  1262.     return 1;
  1263. }
  1264.  
  1265. Property_SendDoorMessage_s(playerid, propertyid, owner[])
  1266. {
  1267.     format(gstring, sizeof gstring, "Bem-vindo {FFEA00}%s{FFFFFF} de {D6D6D6}%s{FFFFFF}", Property_GetTypeName(gPropertyInfo[propertyid][prop_Type]), owner);
  1268.     SendClientMessage(playerid, -1, gstring);
  1269.     SendClientMessage(playerid, -1, "     Digite {2DD2F7}/entrar{FFFFFF} ou pressione {2DD2F7}~k~~VEHICLE_ENTER_EXIT~{FFFFFF} para entrar.");
  1270.     return 1;
  1271. }
  1272.  
  1273. Property_GetTypeName(propertytype)
  1274. {
  1275.     new buff[32];
  1276.     switch(propertytype) {
  1277.         case PROPERTY_TYPE_INT:
  1278.             format(buff, sizeof buff, "ao lugar");
  1279.         case PROPERTY_TYPE_HOUSE:
  1280.             format(buff, sizeof buff, "à casa");
  1281.         default:
  1282.             format(buff, sizeof buff, "PREGUIÇA E FODA");
  1283.     }
  1284.     return buff;
  1285. }
  1286.  
  1287. //
  1288. //
  1289. //
  1290. // Local Functions/Stocks
  1291. //
  1292. //
  1293.  
  1294. //
  1295. // Admins:
  1296. Player_IsAdmin(playerid)
  1297. {
  1298.     if(gPlayerInfo[playerid][gPlayerStat] >= PLAYER_STAT_PLAYING)
  1299.     {  
  1300.         return (gPlayerInfo[playerid][gPlayerAttributes] & PLAYER_ATTRIB_ADMIM) || (gPlayerInfo[playerid][gPlayerAttributes] & PLAYER_ATTRIB_DEV) || (gPlayerInfo[playerid][gPlayerAttributes] & PLAYER_ATTRIB_LEAD_ADMIN) || (gPlayerInfo[playerid][gPlayerAttributes] & PLAYER_ATTRIB_SEMI_ADMIN);
  1301.     }
  1302.     return 0;
  1303. }
  1304.  
  1305. // Y_Less / // // // /
  1306. SendClientMessageFormatted(playerid, color, fstring[], {Float, _}:...)
  1307. {
  1308.   new n = numargs() * 4;
  1309.  
  1310.   if (n == 3 * 4)
  1311.   {
  1312.         return SendClientMessage(playerid, color, fstring);
  1313.   }
  1314.   else
  1315.   {
  1316.         new message[128];
  1317.         new arg_start;
  1318.         new arg_end;
  1319.         new i = 0;
  1320.  
  1321.         #emit CONST.pri  fstring
  1322.         #emit ADD.C    0x4
  1323.         #emit STOR.S.pri arg_start // first parameters's offset
  1324.  
  1325.         #emit LOAD.S.pri n
  1326.         #emit ADD.C    0x8
  1327.         #emit STOR.S.pri arg_end  // last parameters's offset
  1328.  
  1329.         // pushing variable arguments
  1330.         for (i = arg_end; i >= arg_start; i -= 4)
  1331.         {
  1332.             #emit LCTRL    5
  1333.             #emit LOAD.S.alt i
  1334.             #emit ADD
  1335.             #emit LOAD.I
  1336.             #emit PUSH.pri
  1337.         }
  1338.         // pushing normal arguments
  1339.         #emit PUSH.S  fstring // format string
  1340.         #emit PUSH.C  128   // sizeof(message)
  1341.         #emit PUSH.ADR message // the string which format() will write in
  1342.         #emit PUSH.S  n    // number of arguments * 4, always must be passed for natives
  1343.         #emit SYSREQ.C format
  1344.  
  1345.         // clearing the stack
  1346.         i = n / 4 + 1;
  1347.         while (--i >= 0)
  1348.         {
  1349.             #emit STACK 0x4
  1350.         }
  1351.  
  1352.         return SendClientMessage(playerid, color, message);
  1353.   }
  1354. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement