Advertisement
ricop522

[GM] Base para Roleplay em Mysql

Oct 12th, 2011
3,031
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 23.51 KB | None | 0 0
  1. /*
  2.  
  3.  
  4.                         Por RICOP522
  5.  
  6.               Features:
  7.                 login/registro
  8.                 comandos em scmd [credits [s]trong]
  9.  
  10. */
  11.  
  12. #include <a_samp>
  13. #include <a_mysql>
  14. #include <ricop>
  15.  
  16. native sscanf(const data[], const format[], {Float,_}:...);
  17. native unformat(const data[], const format[], {Float,_}:...) = sscanf;
  18.  
  19. #undef MAX_PLAYERS
  20. #define MAX_PLAYERS                                                             (50)
  21.  
  22. #define SERVER_NOME                                                             " Meu servidor "
  23. #define SERVER_MAPA                                                             "LS/SF"
  24.  
  25. #define COLOR_PINK                                                              0xFFC0CBFF
  26. #define COLOR_RED                                                               0xFF0000FF
  27. #define COLOR_GREEN                                                             0x008000FF
  28. #define COLOR_DARKBLUE                                                          0x00008BFF
  29. #define COLOR_CADETBLUE                                                         0x5F9EA0FF
  30. #define COLOR_LIGHTBLUE                                                         0xADD8E6FF
  31. #define COLOR_YELLOW                                                            0xECD400F6
  32. #define COLOR_LIGHTGREEN                                                        0x90EE90FF
  33. #define COLOR_PEACHPUFF                                                         0xFFDAB9FF
  34. #define LIGHTBLUE2                                                              0xF6BB0AA
  35. #define COLOR_GREY                                                              0x808080FF
  36. #define COLOR_ORANGE                                                            0xFFA500FF
  37. #define COLOR_BISQUE                                                            0xFFE4C4FF
  38. #define COLOR_BLANCHEDALMOND                                                    0xFFEBCDFF
  39. #define COLOR_GRAD1                                                             0xB4B5B7FF
  40. #define COLOR_GRAD2                                                             0xBFC0C2FF
  41. #define COLOR_GRAD3                                                             0xCBCCCEFF
  42. #define COLOR_GRAD4                                                             0xD8D8D8FF
  43. #define COLOR_GRAD5                                                             0xE3E3E3FF
  44.  
  45. #define CYELLOW                                                                 "{9DBD1E}"
  46. #define CORANGE                                                                 "{E68C0E}"
  47. #define CBLUE                                                                   "{39AACC}"
  48. #define CLGREEN                                                                 "{30DB52}"
  49. #define CDGREEN                                                                 "{6FA828}"
  50. #define CWHITE                                                                  "{FFFFFF}"
  51. #define CREDISH                                                                 "{CF0C43}"
  52. #define CRED                                                                    "{FF0000}"
  53. #define CLBLUE                                                                  "{55C2CF}"
  54. #define CCADET                                                                  "{5F9EA0}"
  55. #define CPINK                                                                   "{FC08CB}"
  56. #define CDBLUE                                                                  "{1500FF}"
  57. #define CAQUA                                                                   "{5CFFE9}"
  58. #define CGREY                                                                   "{7D8584}"
  59. #define CMAROON                                                                 "{912514}"
  60. #define CCORAL                                                                  "{FF7F50}"
  61. #define CRACE                                                                   "{F2DDC4}"
  62. #define CRACE2                                                                  "{2CC900}"
  63. #define CGAME1                                                                  "{E8DB20}"
  64. #define CGAME2                                                                  "{BA80BA}"
  65. #define CMINIG1                                                                 "{648832}"
  66. #define CMINIG2                                                                 "{4F927F}"
  67.  
  68. //-------------                          Dados do MYSQL                         -----------
  69. #define SQL_HOST                                                                "localhost"
  70. #define SQL_USER                                                                "root"
  71. #define SQL_PASS                                                                ""
  72. #define SQL_DB                                                                  "minhadb"
  73. #define mysql_fetch_row(%1)                                                     mysql_fetch_row_format(%1,"|")
  74.  
  75. #if !defined FALSE
  76.     stock bool:FALSE = false;
  77. #endif
  78.  
  79. // Dialog IDS
  80. #define LOGIN                                                                   (1)
  81. #define REGISTER                                                                (2)
  82. #define isnull(%1) %1[0] == '\1'
  83. #define scmd(%1,%2,%3) _%1(%2, %3); public _%1(%2,%3)
  84.  
  85. // Outros
  86. enum rick_p
  87. {
  88.     pLayaName[24],
  89.     pPassword[35],
  90.     pMatou,
  91.     pMorreu,
  92.     pDinheiro,
  93.     pAdmin,
  94.     Float:pPosX,
  95.     Float:pPosY,
  96.     Float:pPosZ,
  97.     pInt,
  98.     pSkin,
  99.     pBanco,
  100.     pLevel,
  101.     pTut
  102. }
  103. new PlayerInfo[MAX_PLAYERS][rick_p];
  104. new Query[700]; //Global Query :D
  105. new msg[128];
  106. new id, motivo;
  107. new VehicleNames[212][] =
  108. {
  109.     "400 - Landstalker",        "401 - Bravura",            "402 - Buffalo",    "403 - Linerunner",         "404 - Pereniel",       "405 - Sentinel",       "406 - Dumper",             "407 - Firetruck",      "408 - Trashmaster",    "409 - Stretch",
  110.     "410 - Manana",             "411 - Infernus",           "412 - Voodoo",     "413 - Pony",               "414 - Mule",           "415 - Cheetah",        "416 - Ambulance",          "417 - Leviathan",      "418 - Moonbeam",       "419 - Esperanto",          "420 - Taxi",
  111.     "421 - Washington",         "422 - Bobcat",             "423 - Mr Whoopee", "424 - BF Injection",       "425 - Hunter",         "426 - Premier",        "427 - Enforcer",           "428 - Securicar",      "429 - Banshee",        "430 - Predator",
  112.     "431 - Bus",                "432 - Rhino",              "433 - Barracks",   "434 - Hotknife",           "435 - Trailer",        "436 - Previon",        "437 - Coach",              "438 - Cabbie",         "439 - Stallion",       "440 - Rumpo",              "441 - RC Bandit",      "442 - Romero",
  113.     "443 - Packer",             "444 - Monster",            "445 - Admiral",    "446 - Squalo",             "447 - Seasparrow",     "448 - Pizzaboy",       "449 - Tram",               "450 - Trailer",        "451 - Turismo",        "452 - Speeder",            "453 - Reefer",         "454 - Tropic",         "455 - Flatbed",
  114.     "456 - Yankee",             "457 - Caddy",              "458 - Solair",     "459 - Berkley's RC Van",   "460 - Skimmer",        "461 - PCJ-600",        "462 - Faggio",             "463 - Freeway",        "464 - RC Baron",       "465 - RC Raider",
  115.     "466 - Glendale",           "467 - Oceanic",            "468 - Sanchez",    "469 - Sparrow",            "470 - Patriot",        "471 - Quad",           "472 - Coastguard",         "473 - Dinghy",         "474 - Hermes",         "475 - Sabre",              "476 - Rustler",
  116.     "477 - ZR350",              "478 - Walton",             "479 - Regina",     "480 - Comet",              "481 - BMX",            "482 - Burrito",        "483 - Camper",             "484 - Marquis",        "485 - Baggage",        "486 - Dozer",              "487 - Maverick",       "488 - News Chopper",
  117.     "489 - Rancher",            "490 - FBI Rancher",        "491 - Virgo",      "492 - Greenwood",          "493 - Jetmax",         "494 - Hotring",        "495 - Sandking",           "496 - Blista Compact", "497 - Police Maverick",
  118.     "498 - Boxville",           "499 - Benson",             "500 - Mesa",       "501 - RC Goblin",          "502 - Hotring Racer""503 - Hotring Racer""504 - Bloodring Banger",   "505 - Rancher",        "506 - Super GT",
  119.     "507 - Elegant",            "508 - Journey",            "509 - Bike",       "510 - Mountain Bike",      "511 - Beagle",         "512 - Cropdust",       "513 - Stunt",              "514 - Tanker",         "515 - RoadTrain",      "516 - Nebula",             "517 - Majestic",
  120.     "518 - Buccaneer",          "519 - Shamal",             "520 - Hydra",      "521 - FCR-900",            "522 - NRG-500",        "523 - HPV1000",        "524 - Cement Truck",       "525 - Tow Truck",      "526 - Fortune",        "527 - Cadrona",            "528 - FBI Truck",
  121.     "529 - Willard",            "530 - Forklift",           "531 - Tractor",    "532 - Combine",            "533 - Feltzer",        "534 - Remington",      "535 - Slamvan",            "536 - Blade",          "537 - Freight",        "538 - Streak",             "539 - Vortex",         "540 - Vincent",
  122.     "541 - Bullet",             "542 - Clover",             "543 - Sadler",     "544 - Firetruck",          "545 - Hustler",        "546 - Intruder",       "547 - Primo",              "548 - Cargobob",       "549 - Tampa",          "550 - Sunrise",            "551 - Merit",          "552 - Utility",
  123.     "553 - Nevada",             "554 - Yosemite",           "555 - Windsor",    "556 - Monster",            "557 - Monster",        "558 - Uranus",         "559 - Jester",             "560 - Sultan",         "561 - Stratum",        "562 - Elegy",              "563 - Raindance",      "564 - RC Tiger",
  124.     "565 - Flash",              "566 - Tahoma",             "567 - Savanna",    "568 - Bandito",            "569 - Freight",        "570 - Trailer",        "571 - Kart",               "572 - Mower",          "573 - Duneride",       "574 - Sweeper",            "575 - Broadway",
  125.     "576 - Tornado",            "577 - AT-400",             "578 - DFT-30",     "579 - Huntley",            "580 - Stafford",       "581 - BF-400",         "582 - Newsvan",            "583 - Tug",            "584 - Trailer",        "585 - Emperor",            "586 - Wayfarer",
  126.     "587 - Euros",              "588 - Hotdog",             "589 - Club",       "590 - Trailer",            "591 - Trailer",        "592 - Andromada",      "593 - Dodo",               "594 - RC Cam",         "595 - Launch",         "596 - Police Car (LSPD)",   "597 - Police Car (SFPD)",
  127.     "598 - Police Car (LVPD)",   "599 - Police Ranger",     "600 - Picador",    "601 - S.W.A.T. Van",       "602 - Alpha",          "603 - Phoenix",        "604 - Glendale",           "605 - Sadler",         "606 - Luggage Trailer A",
  128.     "607 - Luggage Trailer B",   "608 - Stair Trailer",     "609 - Boxville",   "610 - Farm Plow",          "611 - Utility Trailer"
  129. };
  130.  
  131. main()
  132. {
  133.     print("----------------------------------------------------");
  134.     print("                       Gamemode por Ricop522        ");
  135.     print("                       carregado com sucesso !      ");
  136.     print("----------------------------------------------------");
  137. }
  138.  
  139. public OnGameModeInit()
  140. {
  141.     new stuff[128];
  142.  
  143.     for(new x = 0; x < 3; x++)
  144.     {
  145.         if(!mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS)) printf("MySQL connection attempt %d failed!", x);
  146.         else break;
  147.     }
  148.     mysql_debug(1);
  149.     mysql_query("CREATE TABLE IF NOT EXISTS playerinfo(user VARCHAR(24) NOT NULL, password VARCHAR(40) NOT NULL, matou INT(20) NOT NULL, morreu INT(20) NOT NULL, dinheiro INT(20) NOT NULL, admin INT(20) NOT NULL, posx INT(20) NOT NULL, posy INT(20) NOT NULL, posz INT(20) NOT NULL, interior INT(20) NOT NULL, skin INT(20) NOT NULL, banco INT(20) NOT NULL, level INT(20) NOT NULL, tutorial INT(20) NOT NULL)");
  150.  
  151.     SetGameModeText("MySQL 0.3");
  152.     format(stuff, 128, "hostname %s", SERVER_NOME);
  153.     SendRconCommand(stuff);
  154.     format(stuff, 128, "mapname %s", SERVER_MAPA);
  155.     SendRconCommand(stuff);
  156.     return 1;
  157. }
  158.  
  159. public OnGameModeExit()
  160. {
  161.     mysql_close();
  162.     return 1;
  163. }
  164.  
  165. public OnPlayerConnect(playerid)
  166. {
  167.     resetarVariaveis(playerid);
  168.     iniciarConexao(playerid);
  169.     return 1;
  170. }
  171.  
  172. public OnPlayerDisconnect(playerid, reason)
  173. {
  174.     salvarPlayer(playerid);
  175.     return 1;
  176. }
  177.  
  178. public OnPlayerSpawn(playerid)
  179. {
  180.     SetPlayerSpawn(playerid);
  181.     return 1;
  182. }
  183.  
  184. forward SetPlayerSpawn(playerid);
  185. public SetPlayerSpawn(playerid)
  186. {
  187.     SetPlayerInterior(playerid, PlayerInfo[playerid][pInt]);
  188.     SetPlayerPos(playerid, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY],PlayerInfo[playerid][pPosZ]); // Warp the player
  189.     SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
  190.     return 1;
  191. }
  192. public OnPlayerDeath(playerid, killerid, reason)
  193. {
  194.     if(killerid != INVALID_PLAYER_ID) PlayerInfo[playerid][pMatou] += 1;
  195.     PlayerInfo[playerid][pMorreu] += 1;
  196.     return 1;
  197. }
  198.  
  199. public OnPlayerText(playerid, text[])
  200. {
  201.     format(msg, 128, "%s (%i): %s", pName(playerid), playerid, text);
  202.     SendClientMessageToAll(-1, msg);
  203.     SetPlayerChatBubble(playerid, msg, COLOR_PINK, 100.0, 10000);
  204.     return 0;
  205. }
  206.  
  207. //------------------------------------------------- Comandos da administração by Ricop522
  208. scmd(v, playerid, params[])
  209. {
  210.     if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "* Saia desse carro!");
  211.     if(PlayerInfo[playerid][pAdmin] < 1336) return SendClientMessage(playerid, COLOR_RED, "Você não é admin.");
  212.     new sCar, VehicleID, Float:X, Float:Y, Float:Z, Float:Ang, Int;
  213.     if(unformat(params, "s[20]", params)) return SendClientMessage(playerid, COLOR_RED, ""#CRED"USE: "#CORANGE"/v [id/modelo]");
  214.     sCar = GetVehicleModelIDFromName(params);
  215.     if(sCar < 400 || sCar > 611) return SendClientMessage(playerid, COLOR_RED, "* modelo inválido!");
  216.     GetPlayerPos(playerid,X, Y, Z);
  217.     GetPlayerFacingAngle(playerid, Ang);
  218.     Int = GetPlayerInterior(playerid);
  219.     VehicleID = CreateVehicle(sCar, X, Y, Z, Ang, -1, -1, -1);
  220.     SetVehicleVirtualWorld(VehicleID, GetPlayerVirtualWorld(playerid));
  221.     PutPlayerInVehicle(playerid, VehicleID, 0);
  222.     LinkVehicleToInterior(VehicleID, Int);
  223.     SendFMessage(playerid, -1, ""#CORANGE"Criou um: "#CBLUE"%s "#CWHITE"- "#CBLUE"%d", VehicleNames[sCar - 400], sCar);
  224.     return 1;
  225. }
  226. scmd(ban, playerid, params[])
  227. {
  228.     if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, -1, "Você não é admin 1+!");
  229.     if(sscanf(params, "us", id, motivo)) return SendClientMessage(playerid, COLOR_RED, "USE: /ban [id] [motivo]");
  230.     if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "Jogador em questão está offline.");
  231.     SendFMessageToAll(COLOR_RED, "[ADMIN] %s baniu %s motivo %s", pName(playerid), pName(id), motivo);
  232.     format(msg, 128, "%s", motivo); BanEx(id, msg);
  233.     return 1;
  234. }
  235. scmd(kick, playerid, params[])
  236. {
  237.     if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, -1, "Você não é admin 1+!");
  238.     if(sscanf(params, "us", id, motivo)) return SendClientMessage(playerid, COLOR_RED, "USE: /kick [id] [motivo]");
  239.     if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "Jogador em questão está offline.");
  240.     SendFMessageToAll(COLOR_RED, "[ADMIN] %s kickou %s motivo %s", pName(playerid), pName(id), motivo);
  241.     Kick(id);
  242.     return 1;
  243. }
  244. scmd(a, playerid, params[]) {
  245.     if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_RED, "Você não é admin 1+");
  246.     if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "/adminchat [txt]");
  247.     format(msg, sizeof(msg), "[%i] %s(%i): %s", PlayerInfo[playerid][pAdmin], pName(playerid), playerid, params);
  248.     adminMensagem(msg, 0x0080C0AA);
  249.     //adminLog(msg);
  250.     return 1;
  251. }
  252. scmd(aviso, playerid, params[]) {
  253.     if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_RED, "Você não é admin 2+");
  254.     if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "/aviso [msg]");
  255.     SendFMessageToAll(COLOR_YELLOW, "[Administração]: %s: %s", pName(playerid), params);
  256.     return 1;
  257. }
  258.  
  259. scmd(ajudaadmin, playerid, params[])
  260. {
  261.     if(!PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid, COLOR_RED, "Você não é admin !");
  262.     if(PlayerInfo[playerid][pAdmin] >= 1) {
  263.         SendClientMessage(playerid, -1, "Level 1: kick, ban, a[chat]");
  264.     }
  265.     if(PlayerInfo[playerid][pAdmin] >= 2) {
  266.         SendClientMessage(playerid, -1, "Level 2: aviso");
  267.     }
  268.     if(PlayerInfo[playerid][pAdmin] >= 3) {
  269.         SendClientMessage(playerid, -1, "Level 3: ");
  270.     }
  271.     if(PlayerInfo[playerid][pAdmin] >= 4) {
  272.         SendClientMessage(playerid, -1, "Level 4: ");
  273.     }
  274.     if(PlayerInfo[playerid][pAdmin] >= 5) {
  275.         SendClientMessage(playerid, -1, "Level 5: ");
  276.     }
  277.     if(PlayerInfo[playerid][pAdmin] >= 6) {
  278.         SendClientMessage(playerid, -1, "Level 6: ");
  279.     }
  280.     if(PlayerInfo[playerid][pAdmin] >= 1336) {
  281.         SendClientMessage(playerid, -1, "Level 1336: v");
  282.     }
  283.     return 1;
  284. }
  285. //---------------------------------------------------------------------------------------------
  286. scmd(creditos, playerid, params[]) return SendClientMessage(playerid, -1, "Créditos: Ricop522");
  287. scmd(viraradmin, playerid, params[])
  288.     return PlayerInfo[playerid][pAdmin] = 1338;
  289. scmd(ajuda, playerid, params[]) {
  290.     SendClientMessage(playerid, -1, "[COMANDOS]: viraradmin, ajudaadmin");
  291.     SendClientMessage(playerid, -1, "[COMANDOS]: admins");
  292.     return 1;
  293. }
  294. scmd(admins, playerid, params[]) {
  295.     new bool:adminOnline;
  296.     for(new i = 0; i < MAX_PLAYERS; ++i) {
  297.         if(PlayerInfo[i][pAdmin] > 0) {
  298.             adminOnline = true;
  299.             SendClientMessage(playerid, -1, " Admins online: ");
  300.             SendFMessage(playerid, COLOR_GRAD1, "[%i] %s", PlayerInfo[i][pAdmin], pName(i));
  301.         }
  302.     }
  303.     if(adminOnline == false) SendClientMessage(playerid, COLOR_RED, " Sem administradores online. ");
  304.     return 1;
  305. }
  306. //----------------------------------------------------------------------------------------------------
  307.  
  308. public OnPlayerCommandText(playerid, cmdtext[])
  309. {
  310.     new
  311.                 i = 1,
  312.             cmdcall[26 char];
  313.  
  314.     cmdcall{0} = 95;
  315.     do
  316.     {
  317.         cmdcall{i} = tolower(cmdtext[i]);
  318.         }
  319.         while(cmdtext[++i] > 32);
  320.     return CallLocalFunction("OnPlayerExecuteCommand", "dsi", playerid, cmdtext, strlen(cmdtext) <= i + 1 ? CallLocalFunction(cmdcall, "ds", playerid, "\1") : CallLocalFunction(cmdcall, "ds", playerid, cmdtext[i + 1]));
  321. }
  322.  
  323. forward OnPlayerExecuteCommand(playerid, cmdtext[], bool:sucess);
  324. public OnPlayerExecuteCommand(playerid, cmdtext[], bool:sucess)
  325. {
  326.     if(!sucess)
  327.         return SendClientMessage(playerid, COLOR_RED, "Comando incorreto ! use /ajuda para ver os comandos.");
  328.     return true;
  329. }
  330. //
  331.  
  332. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  333. {
  334.     switch(dialogid)
  335.     {
  336.         case REGISTER:
  337.         {
  338.             if(!response)
  339.             {
  340.                 SendClientMessage(playerid, COLOR_GREY, "Você saiu.");
  341.                 Kick(playerid);
  342.             }
  343.             else
  344.             {
  345.                 if(!strlen(inputtext)) DialogInput(playerid, REGISTER, ""#CCADET"[Conta - Registro]", ""CYELLOW"Digite uma senha abaixo para registrar-se!", "Registrar", "Sair");
  346.  
  347.                 new EscPass[30],
  348.                     EscName[MAX_PLAYER_NAME];
  349.  
  350.                 mysql_real_escape_string(pName(playerid), EscName);
  351.                 mysql_real_escape_string(inputtext, EscPass);
  352.  
  353.                 format(Query, sizeof(Query), "INSERT INTO `playerinfo` (`user`, `password`) VALUES ('%s', md5('%s'))", EscName, EscPass);
  354.                 mysql_query(Query);
  355.  
  356.  
  357.                 SendClientMessage(playerid, COLOR_CADETBLUE, "Registrado com sucesso na nossa database.");
  358.                 GivePlayerMoney(playerid, 5000);
  359.                
  360.                 SetPVarInt(playerid, "LoggedIN", 1);
  361.                 PlayerInfo[playerid][pPosX] = 1612.324;
  362.                 PlayerInfo[playerid][pPosY] = -2330.167;
  363.                 PlayerInfo[playerid][pPosZ] = 13.5469;
  364.                 PlayerInfo[playerid][pTut] = 0;
  365.                 carregarPlayer(playerid);
  366.             }
  367.         }
  368.         case LOGIN:
  369.         {
  370.             if(!response)
  371.             {
  372.                 SendClientMessage(playerid, COLOR_GREY, "Você saiu!");
  373.                 Kick(playerid);
  374.             }
  375.             else
  376.             {
  377.                 if(!strlen(inputtext)) DialogInput(playerid, LOGIN, ""#CCADET"[Conta - Login]", ""#CYELLOW"Digite a senha da conta para registrar!", "Logar", "Sair");
  378.  
  379.                 new
  380.                     EscPass[38];
  381.  
  382.  
  383.                 mysql_real_escape_string(inputtext, EscPass);
  384.  
  385.                 format(Query, sizeof(Query), "SELECT * FROM `playerinfo` WHERE `user` = '%s' AND `password` = md5('%s')", pName(playerid), EscPass);
  386.  
  387.                 mysql_query(Query);
  388.                 mysql_store_result();
  389.  
  390.                 if(mysql_num_rows() > 0)
  391.                 {
  392.                     carregarPlayer(playerid);
  393.                     SetPVarInt(playerid, "LoggedIN", 1);
  394.                 }
  395.                 else
  396.                 {
  397.                     SendClientMessage(playerid, COLOR_RED, "Ops, senha incorreta!");
  398.                     DialogInput(playerid, LOGIN, ""#CCADET"[Conta - Login]", ""#CYELLOW"Você tem 3 chances antes de levar KICK automático..", "Logar", "Sair");
  399.                 }
  400.             }
  401.         }
  402.     }
  403.     return 1;
  404. }
  405.  
  406. stock carregarPlayer(playerid)
  407. {
  408.     //Carregar
  409.     if(mysql_fetch_row(Query))
  410.     {
  411.         sscanf(Query, "e<p<|>s[24]s[35]ddddfffddddd>", PlayerInfo[playerid]);
  412.         mysql_free_result();
  413.     }
  414.     //Fim
  415.     SendClientMessage(playerid, -1, "------------------------------------------------");
  416.     SendClientMessage(playerid, 0xEEEEEEAA, "Versão: MySQL 0.3");
  417.     SendClientMessage(playerid, 0xEEEEEEAA, "Criador: Ricop522");
  418.     SendClientMessage(playerid, -1, "------------------------------------------------");
  419.     SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ], 1.0, 0, 0, 0, 0, 0, 0);
  420.     SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
  421.     SpawnPlayer(playerid);
  422.     if(PlayerInfo[playerid][pTut] == 0)
  423.     {
  424.         SendClientMessage(playerid, -1, "Tutorial não iniciado !");
  425.     }
  426.     return 1;
  427. }
  428.  
  429. stock salvarPlayer(playerid)
  430. {
  431.     new sQuery[500];
  432.     if(GetPVarInt(playerid, "LoggedIN") == 1)
  433.     {
  434.         GetPlayerPos(playerid, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ]);
  435.         format(sQuery, sizeof(sQuery), "UPDATE `playerinfo` SET `matou` = %d, `morreu` = %d, `dinheiro` = %d, `admin` = %d, `posx` = %f, `posy` = %f, `posz` = %f, `interior` = %d, `skin` = %d, `banco` = %d, `level` = %d, tutorial = %d WHERE `user` = '%s'",
  436.         PlayerInfo[playerid][pMatou],
  437.         PlayerInfo[playerid][pMorreu],
  438.         GetPlayerMoney(playerid),
  439.         PlayerInfo[playerid][pAdmin],
  440.         PlayerInfo[playerid][pPosX],
  441.         PlayerInfo[playerid][pPosY],
  442.         PlayerInfo[playerid][pPosZ],
  443.         GetPlayerInterior(playerid),
  444.         PlayerInfo[playerid][pSkin],
  445.         PlayerInfo[playerid][pBanco],
  446.         PlayerInfo[playerid][pLevel],
  447.         PlayerInfo[playerid][pTut],
  448.         pName(playerid));
  449.         mysql_query(sQuery);
  450.         mysql_free_result();
  451.         return 1;
  452.     }
  453.     else return 0;
  454. }
  455.  
  456. stock iniciarConexao(playerid)
  457. {
  458.     new EscName[MAX_PLAYER_NAME];
  459.  
  460.     mysql_real_escape_string(pName(playerid), EscName);
  461.  
  462.     format(Query, sizeof(Query), "SELECT * FROM `playerinfo` WHERE `user` = '%s'", EscName);
  463.  
  464.     mysql_query(Query);
  465.     mysql_store_result();
  466.  
  467.     if(mysql_num_rows() != 0)
  468.     {
  469.         format(msg, sizeof(msg), "Bem vindo de volta %s\n\n\nInsira a senha da sua conta para continuar :", pName(playerid), playerid);
  470.         DialogInput(playerid, LOGIN, "[Conta - Login]", msg, "Logar", "Sair");
  471.     }
  472.     else
  473.     {
  474.         format(msg, sizeof(msg), "Bem vindo: %s(%d)\nEssa conta não está registrada, digite a senha para registra-lá abaixo :", pName(playerid), playerid);
  475.         DialogInput(playerid, REGISTER, "[Conta - Registro]", msg, "Registrar", "Sair");
  476.     }
  477.     mysql_free_result();
  478. }
  479.  
  480. stock resetarVariaveis(playerid)
  481. {
  482.     PlayerInfo[playerid][pAdmin] = 0;
  483.     PlayerInfo[playerid][pMatou] = 0;
  484.     PlayerInfo[playerid][pMorreu] = 0;
  485.     PlayerInfo[playerid][pDinheiro] = 0;
  486.     PlayerInfo[playerid][pPosX] = 0.0;
  487.     PlayerInfo[playerid][pPosY] = 0.0;
  488.     PlayerInfo[playerid][pPosZ] = 0.0;
  489.     PlayerInfo[playerid][pInt] = 0;
  490. }
  491.  
  492. GetVehicleModelIDFromName(vname[])
  493. {
  494.     for(new i = 0; i < 211; i++)
  495.     {
  496.         if (strfind(VehicleNames[i], vname, true) != -1)
  497.         return i + 400;
  498.     }
  499.     return -1;
  500. }
  501.  
  502. stock pName(playerid)
  503. {
  504.     new escname[24], Pname[24];
  505.     GetPlayerName(playerid, Pname, 24);
  506.     mysql_real_escape_string(Pname, escname);
  507.     return escname;
  508. }
  509. stock adminMensagem(mensagem[], cor)
  510. {
  511.     for(new i = 0; i < MAX_PLAYERS; ++i) {
  512.         if(PlayerInfo[i][pAdmin] > 0) {
  513.             SendClientMessage(i, cor, mensagem);
  514.         }
  515.     }
  516.     return 1;
  517. }
  518. stock adminLog(string[]) {
  519.     new Str1[200], Str2[128];
  520.     new d,m,a, dstr[10];
  521.     getdate(d,m,a);
  522.     mysql_query("CREATE TABLE IF NOT EXISTS adminlog(texto VARCHAR(128) NOT NULL, data INT(10))");
  523.     mysql_real_escape_string(string, Str2);
  524.     format(dstr, 10, "%d/%d/%d", d,m,a);
  525.     format(Str1, 200, "INSERT INTO adminlog (texto, data) VALUES('%s', '%d')", Str2, dstr);
  526.     mysql_query(Str1);
  527.     return 1;
  528. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement