Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //////////////////////////////////////////////////////////////////////////
- // [FilterScript] Sistema de Nivel //
- // //
- // http://forum.sa-mp.com/showthread.php?t=502080 //
- //////////////////////////////////////////////////////////////////////////
- // Informações do projeto //
- // //
- // - Nome do projeto: Sistema de Nivel //
- // - Autor do projeto: WPNiGGa aka n0tt_ //
- // - Versão do projeto: 1.2b //
- // - Data de criação: 21/03/2014 //
- // - Ultima edição: 14/04/2014 //
- // - Changelog: http://forum.sa-mp.com/showthread.php?t=502080 //
- // - Helpers: Wiki SA-MP //
- // - Tempo de desenvolvimento da fase 1.0b: 3h. //
- // - Tempo de desenvolvimento da fase 1.2b: 20m. //
- // - Tempo de desenvolvimento da fase 2.0: 35m. //
- // - Razão do projeto: Desenferrujar o meu conhecimento de pawn. //
- //////////////////////////////////////////////////////////////////////////
- // Notas do autor //
- // //
- // - Este projeto já foi testado IN-Game; //
- // - Não foram encontrados quaisquer bugs; //
- // - Não fazer mirrors do projeto; //
- // - Não retirar os créditos; //
- // - Não publicar noutros foruns/sites sem o meu concentimento. //
- //////////////////////////////////////////////////////////////////////////
- #include <a_samp>
- #include <zcmd>
- #include <DOF2>
- #include <sscanf2>
- #include <progressbar>
- #define COLOR_BLUE 0x1E90FFAA
- #define COLOR_ORANGE 0xFF8C00AA
- #define Nivel_Info "|| %s (id: %d) || Nível: %d & Experiência: %d/%d"
- #if defined FILTERSCRIPT
- #else
- #endif
- new Exp[MAX_PLAYERS];
- new TExp[MAX_PLAYERS];
- new Nivel[MAX_PLAYERS];
- new Kills[MAX_PLAYERS];
- new String[128];
- new TOnline[MAX_PLAYERS];
- new Online[MAX_PLAYERS];
- new TimerPlayerOnline[MAX_PLAYERS];
- new PlayerText:ExpDraw[9];
- new Bar:ExpBar[2][MAX_PLAYERS];
- forward PlayerOnline(playerid);
- public OnFilterScriptInit()
- {
- SetTimer("Atualizar", 1000, true);
- return 1;
- }
- public OnFilterScriptExit()
- {
- DOF2_Exit();
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- LoadConta(playerid);
- LoadPlayerTextDraws(playerid);
- for(new i = 0; i < 9; i++)
- PlayerTextDrawShow(playerid, ExpDraw[i]);
- //exp bar total exp percentagem
- ExpBar[playerid][0] = CreateProgressBar(535.00, 125.00, 67.50, 5.19, -7601921, 100.0);
- ShowProgressBarForPlayer(playerid, ExpBar[playerid][0]);
- //ExpBar +1exp
- ExpBar[playerid][1] = CreateProgressBar(498.00, 137.00, 111.50, 10.19, 512819199, 100.0);
- ShowProgressBarForPlayer(playerid, ExpBar[playerid][1]);
- TimerPlayerOnline[playerid] = SetTimerEx("PlayerOnline", 1000, true,"i", playerid);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- GuardarConta(playerid);
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- format(String, sizeof(String), "%.0f%", (floatdiv(Exp[playerid], TExp[playerid]) * 100.0));
- PlayerTextDrawSetString(playerid, ExpDraw[7], String);
- format(String, sizeof(String), "%.0f%", (floatdiv(Kills[playerid], 13) * 100.0));
- PlayerTextDrawSetString(playerid, ExpDraw[8], String);
- PlayerTextDrawShow(playerid, ExpDraw[7]);
- format(String, sizeof(String), "~w~Nivel: ~y~%d", Nivel[playerid]);
- PlayerTextDrawSetString(playerid, ExpDraw[1], String);
- PlayerTextDrawShow(playerid, ExpDraw[1]);
- SetProgressBarValue(ExpBar[playerid][0],(floatdiv(Exp[playerid], TExp[playerid]) * 100.0));
- ShowProgressBarForPlayer(playerid, ExpBar[playerid][0]);
- SetProgressBarValue(ExpBar[playerid][1],(floatdiv(Kills[playerid], 13) * 100.0));
- ShowProgressBarForPlayer(playerid, ExpBar[playerid][1]);
- if(Kills[playerid] == 13)
- {
- SendClientMessage(playerid, COLOR_BLUE, "|| INFO || Fizes-te 13 kills e ganhas-te +2EXP !");
- Exp[playerid] = Exp[playerid] + 2;
- Kills[playerid] = 0;
- }
- new H, M, S;
- gettime(H, M, S);
- if(M == 00 && S == 00)
- {
- format(String, sizeof(String), "~b~ São ~r~%d ~b~Horas e ~r~%d ~b~Minutos\n ~r~HORA DO PAYDAY!", H, M);
- GameTextForAll(String, 1500, 6);
- if(Online[playerid] != 1) return SendClientMessage(playerid, COLOR_ORANGE, "|| INFO || Não recebeste o payday. Razão: Não estás online á mais de 30minutos.");
- Exp[playerid]+=7;
- if(TExp[playerid] == Exp[playerid] || Exp[playerid] > TExp[playerid])
- {
- Nivel[playerid]++;
- TExp[playerid] = Nivel[playerid]*6;
- Exp[playerid] = 0;
- format(String, sizeof(String), "|| INFO || Parabéns, subiste para nivel %d e tens %d/%d de experiência", Nivel[playerid], Exp[playerid], TExp[playerid]);
- SendClientMessage(playerid, COLOR_BLUE, String);
- GuardarConta(playerid);
- }
- }
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- if(killerid != INVALID_PLAYER_ID)
- {
- Kills[playerid]--;
- Kills[killerid]++;
- }
- return 1;
- }
- public PlayerOnline(playerid)
- {
- TOnline[playerid]++;
- if(60*30 <= TOnline[playerid])
- {
- Online[playerid] = 1;
- KillTimer(TimerPlayerOnline[playerid]);
- }
- return 1;
- }
- CMD:nivel(playerid, params[])
- {
- new id;
- format(String, sizeof(String), Nivel_Info, Name(playerid), playerid, Nivel[playerid], Exp[playerid], TExp[playerid]);
- if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_BLUE, String);
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_ORANGE, "|| ERRO || O player não está conectado.");
- format(String, sizeof(String), Nivel_Info, Name(id), id, Nivel[id], Exp[id], TExp[id]);
- SendClientMessage(playerid, COLOR_BLUE, String);
- return 1;
- }
- stock CriarConta(playerid)
- {
- if(DOF2_FileExists(file(playerid)))
- return LoadConta(playerid);
- DOF2_CreateFile(file(playerid));
- DOF2_SetInt(file(playerid), "Nivel", 1);
- DOF2_SetInt(file(playerid), "Exp", 0);
- DOF2_SetInt(file(playerid), "TExp", 6);
- DOF2_SaveFile();
- return LoadConta(playerid);
- }
- stock GuardarConta(playerid)
- {
- if(!DOF2_FileExists(file(playerid)))
- return DOF2_CreateFile(file(playerid));
- DOF2_SetInt(file(playerid), "Nivel", Nivel[playerid]);
- DOF2_SetInt(file(playerid), "Exp", Exp[playerid]);
- DOF2_SetInt(file(playerid), "TExp", TExp[playerid]);
- DOF2_SaveFile();
- return 1;
- }
- stock LoadConta(playerid)
- {
- if(!DOF2_FileExists(file(playerid)))
- CriarConta(playerid);
- Nivel[playerid] = DOF2_GetInt(file(playerid), "Nivel");
- Exp[playerid] = DOF2_GetInt(file(playerid), "Exp");
- TExp[playerid] = DOF2_GetInt(file(playerid), "TExp");
- return 1;
- }
- stock Name(playerid)
- {
- new Nick[MAX_PLAYER_NAME];
- GetPlayerName(playerid, Nick, 24);
- return Nick;
- }
- stock LoadPlayerTextDraws(playerid)
- {
- ExpDraw[0] = CreatePlayerTextDraw(playerid,620.000000, 102.000000, "_");
- PlayerTextDrawBackgroundColor(playerid,ExpDraw[0], 255);
- PlayerTextDrawFont(playerid,ExpDraw[0], 1);
- PlayerTextDrawLetterSize(playerid,ExpDraw[0], 0.500000, 5.599999);
- PlayerTextDrawColor(playerid,ExpDraw[0], -1);
- PlayerTextDrawSetOutline(playerid,ExpDraw[0], 0);
- PlayerTextDrawSetProportional(playerid,ExpDraw[0], 1);
- PlayerTextDrawSetShadow(playerid,ExpDraw[0], 1);
- PlayerTextDrawUseBox(playerid,ExpDraw[0], 1);
- PlayerTextDrawBoxColor(playerid,ExpDraw[0], 96);
- PlayerTextDrawTextSize(playerid,ExpDraw[0], 488.000000, -41.000000);
- PlayerTextDrawSetSelectable(playerid,ExpDraw[0], 0);
- ExpDraw[1] = CreatePlayerTextDraw(playerid,496.000000, 102.000000, "~w~Nivel: ~y~20");
- PlayerTextDrawBackgroundColor(playerid,ExpDraw[1], 255);
- PlayerTextDrawFont(playerid,ExpDraw[1], 2);
- PlayerTextDrawLetterSize(playerid,ExpDraw[1], 0.310000, 1.600000);
- PlayerTextDrawColor(playerid,ExpDraw[1], -1);
- PlayerTextDrawSetOutline(playerid,ExpDraw[1], 0);
- PlayerTextDrawSetProportional(playerid,ExpDraw[1], 1);
- PlayerTextDrawSetShadow(playerid,ExpDraw[1], 1);
- PlayerTextDrawSetSelectable(playerid,ExpDraw[1], 0);
- ExpDraw[2] = CreatePlayerTextDraw(playerid,496.000000, 119.000000, "~w~Exp:");
- PlayerTextDrawBackgroundColor(playerid,ExpDraw[2], 255);
- PlayerTextDrawFont(playerid,ExpDraw[2], 2);
- PlayerTextDrawLetterSize(playerid,ExpDraw[2], 0.310000, 1.600000);
- PlayerTextDrawColor(playerid,ExpDraw[2], -1);
- PlayerTextDrawSetOutline(playerid,ExpDraw[2], 0);
- PlayerTextDrawSetProportional(playerid,ExpDraw[2], 1);
- PlayerTextDrawSetShadow(playerid,ExpDraw[2], 1);
- PlayerTextDrawSetSelectable(playerid,ExpDraw[2], 0);
- ExpDraw[3] = CreatePlayerTextDraw(playerid,489.500000, 98.000000, "ld_dual:health");
- PlayerTextDrawBackgroundColor(playerid,ExpDraw[3], 255);
- PlayerTextDrawFont(playerid,ExpDraw[3], 4);
- PlayerTextDrawLetterSize(playerid,ExpDraw[3], 0.500000, 1.000000);
- PlayerTextDrawColor(playerid,ExpDraw[3], -1);
- PlayerTextDrawSetOutline(playerid,ExpDraw[3], 0);
- PlayerTextDrawSetProportional(playerid,ExpDraw[3], 1);
- PlayerTextDrawSetShadow(playerid,ExpDraw[3], 1);
- PlayerTextDrawUseBox(playerid,ExpDraw[3], 1);
- PlayerTextDrawBoxColor(playerid,ExpDraw[3], 255);
- PlayerTextDrawTextSize(playerid,ExpDraw[3], 129.000000, 2.000000);
- PlayerTextDrawSetSelectable(playerid,ExpDraw[3], 0);
- ExpDraw[4] = CreatePlayerTextDraw(playerid,489.500000, 153.000000, "ld_dual:health");
- PlayerTextDrawBackgroundColor(playerid,ExpDraw[4], 255);
- PlayerTextDrawFont(playerid,ExpDraw[4], 4);
- PlayerTextDrawLetterSize(playerid,ExpDraw[4], 0.500000, 1.000000);
- PlayerTextDrawColor(playerid,ExpDraw[4], -1);
- PlayerTextDrawSetOutline(playerid,ExpDraw[4], 0);
- PlayerTextDrawSetProportional(playerid,ExpDraw[4], 1);
- PlayerTextDrawSetShadow(playerid,ExpDraw[4], 1);
- PlayerTextDrawUseBox(playerid,ExpDraw[4], 1);
- PlayerTextDrawBoxColor(playerid,ExpDraw[4], 255);
- PlayerTextDrawTextSize(playerid,ExpDraw[4], 129.000000, 2.000000);
- PlayerTextDrawSetSelectable(playerid,ExpDraw[4], 0);
- ExpDraw[5] = CreatePlayerTextDraw(playerid,489.000000, 98.000000, "ld_dual:health");
- PlayerTextDrawBackgroundColor(playerid,ExpDraw[5], 255);
- PlayerTextDrawFont(playerid,ExpDraw[5], 4);
- PlayerTextDrawLetterSize(playerid,ExpDraw[5], 0.500000, 1.000000);
- PlayerTextDrawColor(playerid,ExpDraw[5], -1);
- PlayerTextDrawSetOutline(playerid,ExpDraw[5], 0);
- PlayerTextDrawSetProportional(playerid,ExpDraw[5], 1);
- PlayerTextDrawSetShadow(playerid,ExpDraw[5], 1);
- PlayerTextDrawUseBox(playerid,ExpDraw[5], 1);
- PlayerTextDrawBoxColor(playerid,ExpDraw[5], 255);
- PlayerTextDrawTextSize(playerid,ExpDraw[5], 1.000000, 57.000000);
- PlayerTextDrawSetSelectable(playerid,ExpDraw[5], 0);
- ExpDraw[6] = CreatePlayerTextDraw(playerid,618.000000, 98.000000, "ld_dual:health");
- PlayerTextDrawBackgroundColor(playerid,ExpDraw[6], 255);
- PlayerTextDrawFont(playerid,ExpDraw[6], 4);
- PlayerTextDrawLetterSize(playerid,ExpDraw[6], 0.500000, 1.000000);
- PlayerTextDrawColor(playerid,ExpDraw[6], -1);
- PlayerTextDrawSetOutline(playerid,ExpDraw[6], 0);
- PlayerTextDrawSetProportional(playerid,ExpDraw[6], 1);
- PlayerTextDrawSetShadow(playerid,ExpDraw[6], 1);
- PlayerTextDrawUseBox(playerid,ExpDraw[6], 1);
- PlayerTextDrawBoxColor(playerid,ExpDraw[6], 255);
- PlayerTextDrawTextSize(playerid,ExpDraw[6], 1.000000, 57.000000);
- PlayerTextDrawSetSelectable(playerid,ExpDraw[6], 0);
- ExpDraw[7] = CreatePlayerTextDraw(playerid,568.000000, 122.500000, "100%");
- PlayerTextDrawAlignment(playerid,ExpDraw[7], 2);
- PlayerTextDrawBackgroundColor(playerid,ExpDraw[7], 255);
- PlayerTextDrawFont(playerid,ExpDraw[7], 2);
- PlayerTextDrawLetterSize(playerid,ExpDraw[7], 0.289999, 1.000000);
- PlayerTextDrawColor(playerid,ExpDraw[7], 255);
- PlayerTextDrawSetOutline(playerid,ExpDraw[7], 0);
- PlayerTextDrawSetProportional(playerid,ExpDraw[7], 1);
- PlayerTextDrawSetShadow(playerid,ExpDraw[7], 0);
- PlayerTextDrawSetSelectable(playerid,ExpDraw[7], 0);
- ExpDraw[8] = CreatePlayerTextDraw(playerid,553.000000, 137.000000, "100%");
- PlayerTextDrawAlignment(playerid,ExpDraw[8], 2);
- PlayerTextDrawBackgroundColor(playerid,ExpDraw[8], 255);
- PlayerTextDrawFont(playerid,ExpDraw[8], 1);
- PlayerTextDrawLetterSize(playerid,ExpDraw[8], 0.500000, 1.000000);
- PlayerTextDrawColor(playerid,ExpDraw[8], 65535);
- PlayerTextDrawSetOutline(playerid,ExpDraw[8], 0);
- PlayerTextDrawSetProportional(playerid,ExpDraw[8], 1);
- PlayerTextDrawSetShadow(playerid,ExpDraw[8], 0);
- PlayerTextDrawSetSelectable(playerid,ExpDraw[8], 0);
- return 1;
- }
- stock file(playerid)
- {
- new files[11+MAX_PLAYER_NAME];
- format(files, sizeof(files), "Contas/%s.ini", Name(playerid));
- return files;
- }
Add Comment
Please, Sign In to add comment