Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- 888888888888888888888888888888888888888888
- 88 CBUG-TIMER 88
- 888888888888888888888888888888888888888888
- 88 - AUTHOR: Badjouras 88
- 88 (aka hbzi @ forum.sa-mp.com) 88
- 88 - VERSION: 1.0 88
- 88 - LAST UPDATE: 23/06 88
- 888888888888888888888888888888888888888888
- 88 - CHANGELOG: 88
- 88 88
- 888888888888888888888888888888888888888888
- */
- // * INCLUDES * //
- #include <a_samp> //Credits to SA-MP Team
- #include <YSI\y_ini> //Credits to Y_Less
- #include <zcmd> //Credits to Zeex
- // * DEFINES FUNCS * //
- #define Msg SendClientMessage
- #define MsgAll SendClientMessageToAll
- #define PRESSED(%0) \
- (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
- #define RELEASED(%0) \
- (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
- // * CONSTANTES * //
- #define DIALOG_TOPS 874
- // * CORES * //
- // * VARS * //
- new isCbug[MAX_PLAYERS+1];
- new bool:disparou[MAX_PLAYERS+1] = false;
- new Float:ccount[4][MAX_PLAYERS+1];
- new sstr[128];
- new str1[256];
- new fileToWrite[] = "topcbug.ini";
- new Float:tops[5];
- new jogtops[5][MAX_PLAYER_NAME+1];
- // * STOCKS * //
- stock GetPlayerN(playerid)
- {
- new nomeJog[MAX_PLAYER_NAME];
- GetPlayerName(playerid, nomeJog, MAX_PLAYER_NAME);
- return nomeJog;
- }
- WaitReset(playerid)
- {
- SetTimerEx("FuncPart2", 2000, 0, "i", playerid);
- }
- // * FUNÇÕES * //
- forward FuncPart2(playerid);
- public FuncPart2(playerid)
- {
- ccount[0][playerid] = 0; ccount[1][playerid] = 0; ccount[2][playerid] = 0; ccount[3][playerid] = 0;
- ResetPlayerWeapons(playerid);
- GivePlayerWeapon(playerid, 24, 7);
- }
- forward ini_tempos_topcbug(name[], value[]);
- public ini_tempos_topcbug(name[], value[])
- {
- INI_Float("1", tops[0]);
- INI_Float("2", tops[1]);
- INI_Float("3", tops[2]);
- INI_Float("4", tops[3]);
- INI_Float("5", tops[4]);
- return 1;
- }
- forward ini_jogadores_topcbug(name[], value[]);
- public ini_jogadores_topcbug(name[], value[])
- {
- INI_String("j1", jogtops[0], MAX_PLAYER_NAME+1);
- INI_String("j2", jogtops[1], MAX_PLAYER_NAME+1);
- INI_String("j3", jogtops[2], MAX_PLAYER_NAME+1);
- INI_String("j4", jogtops[3], MAX_PLAYER_NAME+1);
- INI_String("j5", jogtops[4], MAX_PLAYER_NAME+1);
- return 1;
- }
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" C-Bug Timer v1.0 FINAL by Badjouras");
- print("--------------------------------------\n");
- if(!fexist(fileToWrite))
- {
- new INI:iniFile = INI_Open(fileToWrite);
- INI_SetTag(iniFile, "tempos");
- INI_WriteFloat(iniFile, "1", 9999999.0, 4);
- INI_WriteFloat(iniFile, "2", 9999999.0, 4);
- INI_WriteFloat(iniFile, "3", 9999999.0, 4);
- INI_WriteFloat(iniFile, "4", 9999999.0, 4);
- INI_WriteFloat(iniFile, "5", 9999999.0, 4);
- INI_SetTag(iniFile, "jogadores");
- INI_WriteString(iniFile, "j1", "N/D");
- INI_WriteString(iniFile, "j2", "N/D");
- INI_WriteString(iniFile, "j3", "N/D");
- INI_WriteString(iniFile, "j4", "N/D");
- INI_WriteString(iniFile, "j5", "N/D");
- INI_Close(iniFile);
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- isCbug[playerid] = 0;
- return 1;
- }
- public OnPlayerDisconnect(playerid)
- {
- isCbug[playerid] = 0;
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- if(isCbug[playerid] == 1) isCbug[playerid] = 0;
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(isCbug[playerid] == 1)
- {
- if(GetPlayerWeapon(playerid) == 24)
- {
- if(GetPlayerAmmo(playerid) == 7 && PRESSED(KEY_FIRE))
- {
- ccount[0][playerid] = GetTickCount();
- disparou[playerid] = true;
- }
- else if(RELEASED(KEY_FIRE))
- {
- if(GetPlayerAmmo(playerid) == 0)
- {
- ccount[1][playerid] = GetTickCount();
- ccount[2][playerid] = ccount[1][playerid] - ccount[0][playerid];
- ccount[3][playerid] = ccount[2][playerid] / 1000;
- disparou[playerid] = false;
- format(sstr, sizeof(sstr), "~r~C-Bug Time~w~:~n~%0.4f~y~s", ccount[3][playerid]);
- GameTextForPlayer(playerid, sstr, 2000, 4);
- format(str1, sizeof(str1), "{FF0000}C-Bug Time{FFFFFF}: %0.4f{FFFF00}s", ccount[3][playerid]);
- Msg(playerid, -1, str1);
- // Y_INI
- INI_ParseFile(fileToWrite,"ini_%s_%s");
- if (ccount[3][playerid] < tops[4])
- {
- new INI:iniFile = INI_Open(fileToWrite);
- new nick[MAX_PLAYER_NAME+1];
- format(nick, sizeof(nick), GetPlayerN(playerid));
- if (ccount[3][playerid] < tops[0])
- {
- INI_SetTag(iniFile, "tempos");
- INI_WriteFloat(iniFile, "1", ccount[3][playerid], 4);
- INI_WriteFloat(iniFile, "2", tops[0], 4);
- INI_WriteFloat(iniFile, "3", tops[1], 4);
- INI_WriteFloat(iniFile, "4", tops[2], 4);
- INI_WriteFloat(iniFile, "5", tops[3], 4);
- INI_SetTag(iniFile, "jogadores");
- INI_WriteString(iniFile, "j1", nick);
- INI_WriteString(iniFile, "j2", jogtops[0]);
- INI_WriteString(iniFile, "j3", jogtops[1]);
- INI_WriteString(iniFile, "j4", jogtops[2]);
- INI_WriteString(iniFile, "j5", jogtops[3]);
- format(str1, sizeof(str1), "[CBug-Time] {00FF00}%s{FFFFFF} is now in {00FF00}1st place{FFFFFF} with a time of {00FF00}%0.4f{FFFFFF} seconds!", nick, ccount[3][playerid]);
- MsgAll(0xFF0000FF, str1);
- INI_Close(iniFile);
- }
- else if (ccount[3][playerid] < tops[1])
- {
- INI_SetTag(iniFile, "tempos");
- INI_WriteFloat(iniFile, "2", ccount[3][playerid], 4);
- INI_WriteFloat(iniFile, "3", tops[1], 4);
- INI_WriteFloat(iniFile, "4", tops[2], 4);
- INI_WriteFloat(iniFile, "5", tops[3], 4);
- INI_SetTag(iniFile, "jogadores");
- INI_WriteString(iniFile, "j2", nick);
- INI_WriteString(iniFile, "j3", jogtops[1]);
- INI_WriteString(iniFile, "j4", jogtops[2]);
- INI_WriteString(iniFile, "j5", jogtops[3]);
- format(str1, sizeof(str1), "[CBug-Time] {00FF00}%s{FFFFFF} is now in {00FF00}2nd place{FFFFFF} with a time of {00FF00}%0.4f{FFFFFF} seconds!", nick, ccount[3][playerid]);
- MsgAll(0xFF0000FF, str1);
- INI_Close(iniFile);
- }
- else if (ccount[3][playerid] < tops[2])
- {
- INI_SetTag(iniFile, "tempos");
- INI_WriteFloat(iniFile, "3", ccount[3][playerid], 4);
- INI_WriteFloat(iniFile, "4", tops[2], 4);
- INI_WriteFloat(iniFile, "5", tops[3], 4);
- INI_SetTag(iniFile, "jogadores");
- INI_WriteString(iniFile, "j3", nick);
- INI_WriteString(iniFile, "j4", jogtops[2]);
- INI_WriteString(iniFile, "j5", jogtops[3]);
- format(str1, sizeof(str1), "[CBug-Time] {00FF00}%s{FFFFFF} is now in {00FF00}3rd place{FFFFFF} with a time of {00FF00}%0.4f{FFFFFF} seconds!", nick, ccount[3][playerid]);
- MsgAll(0xFF0000FF, str1);
- INI_Close(iniFile);
- }
- else if (ccount[3][playerid] < tops[3])
- {
- INI_SetTag(iniFile, "tempos");
- INI_WriteFloat(iniFile, "4", ccount[3][playerid], 4);
- INI_WriteFloat(iniFile, "5", tops[3], 4);
- INI_SetTag(iniFile, "jogadores");
- INI_WriteString(iniFile, "j4", nick);
- INI_WriteString(iniFile, "j5", jogtops[3]);
- format(str1, sizeof(str1), "[CBug-Time] {00FF00}%s{FFFFFF} is now in {00FF00}4th place{FFFFFF} with a time of {00FF00}%0.4f{FFFFFF} seconds!", nick, ccount[3][playerid]);
- MsgAll(0xFF0000FF, str1);
- INI_Close(iniFile);
- }
- else
- {
- INI_SetTag(iniFile, "tempos");
- INI_WriteFloat(iniFile, "5", ccount[3][playerid], 4);
- INI_SetTag(iniFile, "jogadores");
- INI_WriteString(iniFile, "j5", nick);
- format(str1, sizeof(str1), "[CBug-Time] {00FF00}%s{FFFFFF} is now in {00FF00}5th place{FFFFFF} with a time of {00FF00}%0.4f{FFFFFF} seconds!", nick, ccount[3][playerid]);
- MsgAll(0xFF0000FF, str1);
- INI_Close(iniFile);
- }
- }
- // Y_INI
- ccount[0][playerid] = 0; ccount[1][playerid] = 0; ccount[2][playerid] = 0; ccount[3][playerid] = 0;
- WaitReset(playerid);
- }
- }
- }
- }
- return 1;
- }
- // * COMANDOS * //
- CMD:cbug(playerid, params[])
- {
- if(isCbug[playerid] == 1) return Msg(playerid, -1, "You are already in the CBug Arena!");
- ccount[0][playerid] = 0; ccount[1][playerid] = 0; ccount[2][playerid] = 0; ccount[3][playerid] = 0;
- isCbug[playerid] = 1;
- SetPlayerPos(playerid, 1351.6174, 2183.8823, 11.0234);
- ResetPlayerWeapons(playerid);
- GivePlayerWeapon(playerid, 24, 7);
- SetPlayerHealth(playerid, 9999999.0);
- return 1;
- }
- CMD:exitcbug(playerid, params[])
- {
- ccount[0][playerid] = 0; ccount[1][playerid] = 0; ccount[2][playerid] = 0; ccount[3][playerid] = 0;
- isCbug[playerid] = 0;
- SetPlayerHealth(playerid, 0.0);
- return 1;
- }
- CMD:gdeagle(playerid, params[])
- {
- if(isCbug[playerid] == 0) return Msg(playerid, -1, "You are not in the CBug Arena!");
- if(GetPlayerWeapon(playerid) == 24) return Msg(playerid, -1, "You already have a deagle!");
- ResetPlayerWeapons(playerid);
- GivePlayerWeapon(playerid, 24, 7);
- return 1;
- }
- CMD:topcbug(playerid, params[])
- {
- INI_ParseFile(fileToWrite,"ini_%s_%s");
- for (new i=0; i<5; i++)
- {
- if(tops[i] == 9999999.0000) tops[i] = 0.0000;
- }
- format(str1, sizeof(str1), "{FFFFFF}#1 {FFFF00}%s {00FFFF}%0.4f\n{FFFFFF}#2 {FFFF00}%s {00FFFF}%0.4f\n{FFFFFF}#3 {FFFF00}%s {00FFFF}%0.4f\n{FFFFFF}#4 {FFFF00}%s {00FFFF}%0.4f\n{FFFFFF}#5 {FFFF00}%s {00FFFF}%0.4f", jogtops[0], tops[0], jogtops[1], tops[1], jogtops[2], tops[2], jogtops[3], tops[3], jogtops[4], tops[4]);
- ShowPlayerDialog(playerid, DIALOG_TOPS, 0, "Top 5 CBug-Time", str1, "OK", "");
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement