Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============Defines===================//
- #define FILTERSCRIPT
- #if defined FILTERSCRIPT
- #define Dialog_Top10 1
- #define Dialog_NA 2
- #define Dialog_Registro 3
- #define Dialog_Login 4
- #define Host "localhost"
- #define Usuario "root"
- #define Senha ""
- #define Database "HeadShot"
- //============Includes==================//
- #include a_samp
- #include a_mysql
- #include izcmd
- enum Info
- {
- DHeadShots,
- DHsTomados,
- DKills,
- mID
- }
- new Dados[MAX_PLAYERS][Info];
- new MySQL:ConexaoBDD, Query[300];
- new Text:TDEditor_TD[6];
- public OnFilterScriptInit()
- {
- print("--------------------------------------");
- print("Sistema de DHeadShots Carregado by: DelK");
- print("--------------------------------------");
- ConexaoBDD = mysql_connect(Host, Usuario, Senha, Database);
- if(mysql_errno(ConexaoBDD) != 0) printf("Falha na conexao com o banco de dados MySQL [error %d]", mysql_errno(ConexaoBDD));
- else print("Conexao com o banco de dados MySQL estabelecida com sucesso");
- mysql_query(ConexaoBDD, "CREATE TABLE IF NOT EXISTS Ranking(ID int AUTO_INCREMENT PRIMARY KEY, Nick varchar(24) NOT NULL, DHeadShots int NOT NULL, DHSTomados int NOT NULL, DKills int NOT NULL)", false);
- TDEditor_TD[0] = TextDrawCreate(254.939559, 106.649986, "__HeadShot~n~____~n~~n~");
- TextDrawLetterSize(TDEditor_TD[0], 0.703526, 2.539165);
- TextDrawTextSize(TDEditor_TD[0], 416.000000, 0.000000);
- TextDrawAlignment(TDEditor_TD[0], 1);
- TextDrawColor(TDEditor_TD[0], -1);
- TextDrawUseBox(TDEditor_TD[0], 1);
- TextDrawBoxColor(TDEditor_TD[0], 370546326);
- TextDrawSetShadow(TDEditor_TD[0], 0);
- TextDrawSetOutline(TDEditor_TD[0], 1);
- TextDrawBackgroundColor(TDEditor_TD[0], -16776961);
- TextDrawFont(TDEditor_TD[0], 1);
- TextDrawSetProportional(TDEditor_TD[0], 1);
- TDEditor_TD[1] = TextDrawCreate(292.774566, 128.435012, "Detalhes_de_sua_morte");
- TextDrawLetterSize(TDEditor_TD[1], 0.230114, 0.888329);
- TextDrawAlignment(TDEditor_TD[1], 1);
- TextDrawColor(TDEditor_TD[1], -16776961);
- TextDrawSetShadow(TDEditor_TD[1], 0);
- TextDrawSetOutline(TDEditor_TD[1], 0);
- TextDrawBackgroundColor(TDEditor_TD[1], 370546198);
- TextDrawFont(TDEditor_TD[1], 1);
- TextDrawSetProportional(TDEditor_TD[1], 1);
- TDEditor_TD[2] = TextDrawCreate(253.770202, 138.534988, "Arma:_%s");
- TextDrawLetterSize(TDEditor_TD[2], 0.230114, 0.888329);
- TextDrawAlignment(TDEditor_TD[2], 1);
- TextDrawColor(TDEditor_TD[2], -1378294017);
- TextDrawSetShadow(TDEditor_TD[2], 0);
- TextDrawSetOutline(TDEditor_TD[2], 1);
- TextDrawBackgroundColor(TDEditor_TD[2], 1296911693);
- TextDrawFont(TDEditor_TD[2], 1);
- TextDrawSetProportional(TDEditor_TD[2], 1);
- TDEditor_TD[3] = TextDrawCreate(253.629074, 147.351791, "Dano:_100");
- TextDrawLetterSize(TDEditor_TD[3], 0.230114, 0.888329);
- TextDrawAlignment(TDEditor_TD[3], 1);
- TextDrawColor(TDEditor_TD[3], -1378294017);
- TextDrawSetShadow(TDEditor_TD[3], 0);
- TextDrawSetOutline(TDEditor_TD[3], 1);
- TextDrawBackgroundColor(TDEditor_TD[3], 1296911693);
- TextDrawFont(TDEditor_TD[3], 1);
- TextDrawSetProportional(TDEditor_TD[3], 1);
- TDEditor_TD[4] = TextDrawCreate(253.629074, 156.552352, "Distancia:_%f");
- TextDrawLetterSize(TDEditor_TD[4], 0.230114, 0.888329);
- TextDrawAlignment(TDEditor_TD[4], 1);
- TextDrawColor(TDEditor_TD[4], -1378294017);
- TextDrawSetShadow(TDEditor_TD[4], 0);
- TextDrawSetOutline(TDEditor_TD[4], 1);
- TextDrawBackgroundColor(TDEditor_TD[4], 1296911693);
- TextDrawFont(TDEditor_TD[4], 1);
- TextDrawSetProportional(TDEditor_TD[4], 1);
- TDEditor_TD[5] = TextDrawCreate(253.629074, 169.653152, "Voce_levou_um_headshot_de:_%s");
- TextDrawLetterSize(TDEditor_TD[5], 0.230114, 0.888329);
- TextDrawAlignment(TDEditor_TD[5], 1);
- TextDrawColor(TDEditor_TD[5], -1378294017);
- TextDrawSetShadow(TDEditor_TD[5], 0);
- TextDrawSetOutline(TDEditor_TD[5], 1);
- TextDrawBackgroundColor(TDEditor_TD[5], 370546198);
- TextDrawFont(TDEditor_TD[5], 1);
- TextDrawSetProportional(TDEditor_TD[5], 1);
- return 1;
- }
- #endif
- public OnFilterScriptExit()
- {
- mysql_close(ConexaoBDD);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- new row;
- mysql_format(ConexaoBDD, Query, sizeof(Query), "SELECT * FROM `Ranking` WHERE `Nick`='%s'", Nome(playerid));
- mysql_query(ConexaoBDD, Query, true);
- cache_get_row_count(row);
- if(row > 0)
- {
- ShowPlayerDialog(playerid, Dialog_Login, DIALOG_STYLE_MSGBOX, "Base - Não use", "Logando", "Logar", "Sair");
- }
- else
- {
- ShowPlayerDialog(playerid, Dialog_Registro, DIALOG_STYLE_MSGBOX, "Base - Não use", "Registrando", "Registrar", "Sair");
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- AtualizarRanking();
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- SendDeathMessage(killerid, playerid, reason);
- if(killerid != INVALID_PLAYER_ID)
- {
- Dados[killerid][DKills]++;
- }
- SetTimerEx("Morto", 1500, false, "i", playerid);
- return 1;
- }
- forward Morto(playerid);
- public Morto(playerid)
- {
- SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
- for(new i = 0; i < 7; i++) TextDrawHideForPlayer(playerid, TDEditor_TD[i]);
- return 1;
- }
- public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
- {
- if(issuerid != INVALID_PLAYER_ID && bodypart == 9)
- {
- new string[55], Float: Distancia;
- Distancia = GetDistanciaEntrePlayers(issuerid, playerid);
- SetPlayerHealth(playerid, 0);
- format(string, sizeof(string), "Arma:_%s", Weapon(issuerid));
- TextDrawSetString(TDEditor_TD[2], string);
- format(string, sizeof(string), "Distancia:_%.1f Metros", Distancia);
- TextDrawSetString(TDEditor_TD[4], string);
- format(string, sizeof(string), "Voce_levou_um_headshot_de:_%s", Nome(issuerid));
- TextDrawSetString(TDEditor_TD[5], string);
- for(new i = 0; i < 6; i++) TextDrawShowForPlayer(playerid, TDEditor_TD[i]);
- if(issuerid != INVALID_PLAYER_ID)
- {
- Dados[issuerid][DHeadShots]++;
- Dados[playerid][DHsTomados]++;
- }
- AtualizarRanking();
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == Dialog_Registro)
- {
- if(!response) return Kick(playerid);
- if(response)
- {
- format(Query, sizeof(Query), "INSERT INTO `Ranking` (Nick, DHeadShots, DHSTomados, DKills) VALUES ('%s', '0', '0','0')", Nome(playerid));
- mysql_query(ConexaoBDD, Query, true);
- Dados[playerid][mID] = cache_insert_id();
- return 1;
- }
- return 1;
- }
- if(dialogid == Dialog_Login)
- {
- if(!response) return Kick(playerid);
- if(response)
- {
- CarregarRanking(playerid);
- SendClientMessage(playerid, -1, "Logado com sucesso!");
- return 1;
- }
- return 1;
- }
- if(dialogid == Dialog_Top10)
- {
- new QueryHeadShot[100];
- if(response)
- {
- if(listitem == 0)
- {
- format(QueryHeadShot, sizeof(QueryHeadShot), "SELECT `Nick`, `DHeadShots` FROM `Ranking` WHERE `DHeadShots`>'0' ORDER BY DHeadShots DESC LIMIT 10;");
- mysql_tquery(ConexaoBDD, QueryHeadShot, "TopHSs", "i", playerid);
- }
- if(listitem == 1)
- {
- format(QueryHeadShot, sizeof(QueryHeadShot), "SELECT `Nick`, `DHSTomados` FROM `Ranking` WHERE `DHSTomados`>'0' ORDER BY DHSTomados DESC LIMIT 10;");
- mysql_tquery(ConexaoBDD, QueryHeadShot, "TopHSTomados", "i", playerid);
- }
- if(listitem == 2)
- {
- format(QueryHeadShot, sizeof(QueryHeadShot), "SELECT `Nick`, `DKills` FROM `Ranking` WHERE `DKills`>'0' ORDER BY DKills DESC LIMIT 10;");
- mysql_tquery(ConexaoBDD, QueryHeadShot, "TopKills", "i", playerid);
- }
- }
- }
- switch(dialogid)
- {
- case Dialog_NA: if(response) return ShowPlayerDialog(playerid, Dialog_Top10, DIALOG_STYLE_LIST, "#Ranking MySQL!", "DHeadShots\nDHsTomados\nDKills", "Confirmar", "Cancelar");
- }
- return 1;
- }
- CMD:armas(playerid)
- {
- GivePlayerWeapon(playerid, 24, 999);
- GivePlayerWeapon(playerid, 25, 999);
- GivePlayerWeapon(playerid, 29, 999);
- GivePlayerWeapon(playerid, 31, 999);
- GivePlayerWeapon(playerid, 32, 999);
- GivePlayerWeapon(playerid, 34, 999);
- return 1;
- }
- CMD:top10(playerid)
- {
- AtualizarRanking();
- ShowPlayerDialog(playerid, Dialog_Top10, DIALOG_STYLE_LIST, "#Ranking MySQL!", "DHeadShots\nDHSTomados\nDKills", "Confirmar", "Cancelar");
- return 1;
- }
- forward TopHSs(playerid);
- public TopHSs(playerid)
- {
- new string[200], Nick[70], HSs, contagem = 0;
- for(new i, r = cache_num_rows(); i < r; ++i)
- {
- cache_get_value_name(i, "Nick", Nick);
- cache_get_value_name_int(i, "DHeadShots", HSs);
- format(string, sizeof(string),"%sNª %d° - %s | HeadShots: %d | %s\n\n{FFFFFF}", string, i+1, Nick, HSs, (GetPlayerConnect(Nick) == INVALID_PLAYER_ID ? ("{8B0000}Desconectado"):("{00FF00}Conectado")));
- contagem++;
- }
- ShowPlayerDialog(playerid, Dialog_NA, DIALOG_STYLE_MSGBOX, "#Ranking HeadShots!", string, "Voltar", "Fechar");
- if(contagem == 0) return ShowPlayerDialog(playerid, Dialog_NA, DIALOG_STYLE_MSGBOX, "#Ranking HeadShots!", "Não tem ninguém no Ranking de HeadShots!\n", "Voltar", "Fechar");
- return 1;
- }
- forward TopHSTomados(playerid);
- public TopHSTomados(playerid)
- {
- new string[200], Nick[70], HSs, contagem = 0;
- for(new i, r = cache_num_rows(); i < r; ++i)
- {
- cache_get_value_name(i, "Nick", Nick);
- cache_get_value_name_int(i, "DHSTomados", HSs);
- format(string, sizeof(string),"%sNª %d° - %s | DHSTomados: %d | %s\n\n{FFFFFF}", string, i+1, Nick, HSs, (GetPlayerConnect(Nick) == INVALID_PLAYER_ID ? ("{8B0000}Desconectado"):("{00FF00}Conectado")));
- contagem++;
- }
- ShowPlayerDialog(playerid, Dialog_NA, DIALOG_STYLE_MSGBOX, "#Ranking DHSTomados!", string, "Voltar", "Fechar");
- if(contagem == 0) return ShowPlayerDialog(playerid, Dialog_NA, DIALOG_STYLE_MSGBOX, "#Ranking DHSTomados!", "Não tem ninguém no Ranking de DHSTomados!\n", "Voltar", "Fechar");
- return 1;
- }
- forward TopKills(playerid);
- public TopKills(playerid)
- {
- new string[200], Nick[70], HSs, contagem = 0;
- for(new i, r = cache_num_rows(); i < r; ++i)
- {
- cache_get_value_name(i, "Nick", Nick);
- cache_get_value_name_int(i, "DKills", HSs);
- format(string, sizeof(string),"%sNª %d° - %s | DKills: %d | %s\n\n{FFFFFF}", string, i+1, Nick, HSs, (GetPlayerConnect(Nick) == INVALID_PLAYER_ID ? ("{8B0000}Desconectado"):("{00FF00}Conectado")));
- contagem++;
- }
- ShowPlayerDialog(playerid, Dialog_NA, DIALOG_STYLE_MSGBOX, "#Ranking DKills!", string, "Voltar", "Fechar");
- if(contagem == 0) return ShowPlayerDialog(playerid, Dialog_NA, DIALOG_STYLE_MSGBOX, "#Ranking DKills!", "Não tem ninguém no Ranking de DKills!\n", "Voltar", "Fechar");
- return 1;
- }
- stock CarregarRanking(playerid)
- {
- format(Query, sizeof(Query), "SELECT * FROM `Ranking` WHERE `Nick`='%s'", Nome(playerid));
- mysql_query(ConexaoBDD, Query, true);
- cache_get_value_name_int(0, "ID", Dados[playerid][mID]);
- cache_get_value_name_int(0, "DHeadShots", Dados[playerid][DHeadShots]);
- cache_get_value_name_int(0, "DHSTomados", Dados[playerid][DHsTomados]);
- cache_get_value_name_int(0, "DKills", Dados[playerid][DKills]);
- mysql_query(ConexaoBDD, Query, false);
- return 1;
- }
- stock AtualizarRanking()
- {
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- format(Query, sizeof(Query), "UPDATE `Ranking` SET `Nick`='%s',`DHeadShots`=%d,`DHSTomados`=%d, `DKills`=%d WHERE `ID`=%d", Nome(i), Dados[i][DHeadShots], Dados[i][DHsTomados], Dados[i][DKills], Dados[i][mID]);
- mysql_query(ConexaoBDD, Query, false);
- }
- return 1;
- }
- stock Nome(playerid)
- {
- new pNome[MAX_PLAYER_NAME];
- GetPlayerName(playerid, pNome, 24);
- return pNome;
- }
- stock Weapon(playerid)
- {
- new ArmaName[15];
- GetWeaponName(GetPlayerWeapon(playerid), ArmaName, 15);
- return ArmaName;
- }
- stock GetPlayerConnect(const pName[])
- {
- static gpName[MAX_PLAYER_NAME];
- for(new i, j = GetPlayerPoolSize(); i <= j; i++)
- {
- GetPlayerName(i, gpName, sizeof(gpName));
- if(strcmp(pName, gpName, false) == 0)
- return i;
- }
- return INVALID_PLAYER_ID;
- }
- stock GetDistanciaEntrePlayers(playerid, playerid2)
- {
- new Float: Pos1[3], Float: Pos2[3], Float: distancia;
- GetPlayerPos(playerid, Pos1[0], Pos1[1], Pos1[2]);
- GetPlayerPos(playerid2,Pos2[0], Pos2[1], Pos2[2]);
- distancia = floatsqroot(floatpower(floatabs(floatsub(Pos2[0], Pos1[0])),2)+floatpower(floatabs(floatsub(Pos2[1], Pos1[1])),2)+floatpower(floatabs(floatsub(Pos2[2], Pos1[2])),2));
- return floatround(distancia);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement