ricop522

[GM] Gamemode em MySQL

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