BANNED
|
09-28-2021
, 13:52
Re: Error in plugin code block
|
#5
|
Quote:
Originally Posted by azalty
PHP Code:
CPrintToChat(client, "iPenalty %i iPenaltyCounter %i client %i", iPenalty[client],client, iPenaltyCounter[client]);
to
PHP Code:
CPrintToChat(client, "iPenalty %i iPenaltyCounter %i client %i", iPenalty[client], iPenaltyCounter[client], client);
If you use colorvariables, you can use {color} instead of \x05 and similar.
List of colors (CS:GO):
default (white): \x01
teamcolour (will be purple if message from server): \x03
red: \x07
lightred: \x0F
darkred: \x02
bluegrey: \x0A
blue: \x0B
darkblue: \x0C
purple: \x03
orchid: \x0E
yellow: \x09
gold: \x10
lightgreen: \x05
green: \x04
lime: \x06
grey: \x08
grey2: \x0D
clientId is a bad name for an AdminId. It works but it's confusing.
PHP Code:
new iPenaltyCounter[MAXPLAYERS + 1];
to
PHP Code:
int iPenaltyCounter[MAXPLAYERS + 1];
(or even g_iPenaltyCounter if you want to use this style)
The rest seems okay. We need more code since the problem doesn't seem to come from here. That's what "PC Gamer" meant.
you can change
PHP Code:
public void OnClientPostAdminCheck(int client) { //If I want, let's set back to 0 once he's inside our server iPenaltyCounter[client] = 0; }
to
PHP Code:
public void OnClientDisconnect(int client) { iPenaltyCounter[client] = 0; }
since you don't need to wait the admin check to set that variable. Resetting on connection/disconnection doesn't really matter though. I just like to do it on disconnects, especially if I work with databases (push/update values to DB).
What do you mean by "This is a timer variable"?
|
thanks for the answer actually the first thing you answered was a debug code , in order to find out what was the cause of the error. ok, I'll share the entire code with you, but as I said, there is nothing that triggers a reset in other code blocks.
PHP Code:
#pragma semicolon 1 #include <colors> #include <sourcemod> #include <sdkhooks> #include <sdktools> #include <sdktools_sound>
#define HUNTER "sound/hunter_allu.mp3" #define ENTITY_PROPANE "models/props_junk/propanecanister001a.mdl" #define MOLOTOV 0 #define EXPLODE 1
new iPenaltyCounter[MAXPLAYERS + 1]; ConVar bhpDistance, bhpMaxAttempts, bhpCoolTime, bhpShowDamage, bhpShowDistance, bhpShowKills, bhpAvgDistance, bhpRankType, bhpListMax, bhpListType;
float fDistance, fCoolTime, fPouncePos[MAXPLAYERS+1][3]; int iMaxAttempts, iRankType, iListMax, iListType, iPounces[MAXPLAYERS+1], iPenalty[MAXPLAYERS+1], iListPage[MAXPLAYERS+1] = 1;
Handle hPenaltyTime[MAXPLAYERS+1] = null; bool bShowDamage, bShowDistance, bShowKills, bAvgDistance, bShowPenalty[MAXPLAYERS+1], bListDone; char sGame[12], sMap[64];
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) { GetGameFolderName(sGame, sizeof(sGame)); if (!StrEqual(sGame, "left4dead", false) && !StrEqual(sGame, "left4dead2", false)) { strcopy(error, err_max, "[BHP] Plugin Supports L4D And L4D2 Only!"); return APLRes_SilentFailure; } return APLRes_Success; }
public Plugin myinfo = { name = "Hunter Fatal Jump", author = "cravenge <3", description = "Version king_oxo.", version = "3.12", url = "" };
public void OnPluginStart() { CreateConVar("brutal_hunter_pounce_version", "3.12", "Brutal Hunter Pounce Version", FCVAR_NOTIFY|FCVAR_SPONLY|FCVAR_DONTRECORD); bhpDistance = CreateConVar("brutal_hunter_pounce_distance", "1750.0", "Distance To Make Deadly Hunter Pounces", FCVAR_NOTIFY|FCVAR_SPONLY, true, 1.0); bhpMaxAttempts = CreateConVar("brutal_hunter_pounce_max_attempts", "2", "Maximum Attempts Of Brutal Hunter Pounces", FCVAR_NOTIFY|FCVAR_SPONLY); bhpCoolTime = CreateConVar("brutal_hunter_pounce_cool_time", "60.0", "Cool Time For Every Smashing Hunter Pounce", FCVAR_NOTIFY|FCVAR_SPONLY); bhpShowDamage = CreateConVar("brutal_hunter_pounce_show_damage", "1", "Enable/Disable Damage Display", FCVAR_NOTIFY|FCVAR_SPONLY, true, 0.0, true, 1.0); bhpShowDistance = CreateConVar("brutal_hunter_pounce_show_distance", "1", "Enable/Disable Distance Display", FCVAR_NOTIFY|FCVAR_SPONLY, true, 0.0, true, 1.0); bhpShowKills = CreateConVar("brutal_hunter_pounce_show_kills", "1", "Enable/Disable Kills Display", FCVAR_NOTIFY|FCVAR_SPONLY, true, 0.0, true, 1.0); bhpAvgDistance = CreateConVar("brutal_hunter_pounce_avg_distance", "1", "Enable/Disable Average Distance", FCVAR_NOTIFY|FCVAR_SPONLY, true, 0.0, true, 1.0); bhpRankType = CreateConVar("brutal_hunter_pounce_rank_type", "0", "Rank Type: 0=By Kills, 1=By Damage, 2=By Distance", FCVAR_NOTIFY|FCVAR_SPONLY, true, 0.0, true, 1.0); bhpListMax = CreateConVar("brutal_hunter_pounce_list_max", "10", "Maximum Number Of Players To List In The Stats", FCVAR_NOTIFY|FCVAR_SPONLY, true, 3.0, true, 10.0); bhpListType = CreateConVar("brutal_hunter_pounce_list_type", "1", "Stats Listing Type: 0=All Players, 1=Top Players Only", FCVAR_NOTIFY|FCVAR_SPONLY, true, 0.0, true, 1.0); fDistance = bhpDistance.FloatValue; fCoolTime = bhpCoolTime.FloatValue; iMaxAttempts = bhpMaxAttempts.IntValue; iRankType = bhpRankType.IntValue; iListMax = bhpListMax.IntValue; iListType = bhpListType.IntValue; bShowDamage = bhpShowDamage.BoolValue; bShowDistance = bhpShowDistance.BoolValue; bShowKills = bhpShowKills.BoolValue; bAvgDistance = bhpAvgDistance.BoolValue; bhpDistance.AddChangeHook(OnBHPCVarsChanged); bhpMaxAttempts.AddChangeHook(OnBHPCVarsChanged); bhpCoolTime.AddChangeHook(OnBHPCVarsChanged); bhpShowDamage.AddChangeHook(OnBHPCVarsChanged); bhpShowDistance.AddChangeHook(OnBHPCVarsChanged); bhpShowKills.AddChangeHook(OnBHPCVarsChanged); bhpAvgDistance.AddChangeHook(OnBHPCVarsChanged); bhpRankType.AddChangeHook(OnBHPCVarsChanged); bhpListMax.AddChangeHook(OnBHPCVarsChanged); bhpListType.AddChangeHook(OnBHPCVarsChanged); AutoExecConfig(true, "brutal_hunter_pounce"); HookEvent("round_start", OnRoundEvents); HookEvent("round_end", OnRoundEvents); HookEvent("map_transition", OnRoundEvents); HookEvent("ability_use", OnAbilityUse); HookEvent("lunge_pounce", OnLungePounce); RegConsoleCmd("sm_hunthud", TogglePenalty, "Toggles Penalty Notification"); RegConsoleCmd("sm_bhp_reset", ResetBHP, "Resets Brutal Pounce Count"); //RegConsoleCmd("sm_bhp_list", ListBHP, "Displays List Of Brutal Pounces Made"); RegConsoleCmd("sm_tophunters", ListBHP, "Displays List Of Brutal Pounces Made"); }
public void OnBHPCVarsChanged(ConVar cvar, const char[] oldValue, const char[] newValue) { fDistance = bhpDistance.FloatValue; fCoolTime = bhpCoolTime.FloatValue; iMaxAttempts = bhpMaxAttempts.IntValue; iRankType = bhpRankType.IntValue; iListMax = bhpListMax.IntValue; iListType = bhpListType.IntValue; bShowDamage = bhpShowDamage.BoolValue; bShowDistance = bhpShowDistance.BoolValue; bShowKills = bhpShowKills.BoolValue; bAvgDistance = bhpAvgDistance.BoolValue; }
public Action TogglePenalty(int client, int args) { if (client == 0 || !IsClientInGame(client)) { return Plugin_Handled; } if (bShowPenalty[client]) { bShowPenalty[client] = false; } else { bShowPenalty[client] = true; } CPrintToChat(client, "\x04Penalty Notification\x01: \x03%s", (bShowPenalty[client]) ? "\x03On" : "\x03Off"); return Plugin_Handled; }
public Action ResetBHP(int client, int args) { if (CheckCommandAccess(client, "", ADMFLAG_CUSTOM3, true)) { AdminId clientId = GetUserAdmin(client); if (clientId == INVALID_ADMIN_ID || iPounces[client] == 0) { PrintToChat(client, "\x05CountDown Cannot \x03Be Reset \x05Because You Didn't Do \x04Brutal!"); return Plugin_Handled; } if (iPenalty[client] < 3 && iPenaltyCounter[client] < 3) { iPenalty[client] = 0; iPenaltyCounter[client]++; CPrintToChat(client, "\x05You Can Used \x03Counts Reset \x04(\x03%i\x05/\x033\x04)", iPenaltyCounter[client]); } else { CPrintToChat(client, "\x05You Cannot Use Count Reset \x04Limit Reached."); } } else { PrintToChat (client, "\x05No Acces"); } return Plugin_Handled; }
public void OnClientDisconnect(int client) { //If u want, let's set back to 0 once he's inside our server iPenaltyCounter[client] = 0; }
public Action ListBHP(int client, int args) { if (client == 0 || !IsClientInGame(client)) { return Plugin_Handled; } if (iListPage[client] != 1) { iListPage[client] = 1; } BHPStats(client, _, _, _, _, iListPage[client]); return Plugin_Handled; }
public void OnPluginEnd() { bhpDistance.RemoveChangeHook(OnBHPCVarsChanged); bhpMaxAttempts.RemoveChangeHook(OnBHPCVarsChanged); bhpCoolTime.RemoveChangeHook(OnBHPCVarsChanged); bhpShowDamage.RemoveChangeHook(OnBHPCVarsChanged); bhpShowDistance.RemoveChangeHook(OnBHPCVarsChanged); bhpShowKills.RemoveChangeHook(OnBHPCVarsChanged); bhpAvgDistance.RemoveChangeHook(OnBHPCVarsChanged); bhpRankType.RemoveChangeHook(OnBHPCVarsChanged); bhpListMax.RemoveChangeHook(OnBHPCVarsChanged); bhpListType.RemoveChangeHook(OnBHPCVarsChanged); //delete bhpDistance; delete bhpMaxAttempts; delete bhpCoolTime; delete bhpShowDamage; delete bhpShowDistance; delete bhpShowKills; //delete bhpAvgDistance; //delete bhpRankType; //delete bhpListMax; //delete bhpListType; UnhookEvent("round_start", OnRoundEvents); UnhookEvent("round_end", OnRoundEvents); UnhookEvent("map_transition", OnRoundEvents); UnhookEvent("ability_use", OnAbilityUse); UnhookEvent("lunge_pounce", OnLungePounce); }
public void OnMapStart() { GetCurrentMap(sMap, sizeof(sMap)); PrecacheSound(HUNTER, true); InitPrecache(); //AddFileToDownloadsTable("sound/hunter_allu.mp3"); }
InitPrecache() { /* Precache models */ PrecacheModel("models/props_junk/propanecanister001a.mdl", true); PrecacheModel("models/props_junk/gascan001a.mdl", true); /* Precache particles */ PrecacheParticle("gas_explosion_main"); PrecacheParticle("electrical_arc_01_cp0"); PrecacheParticle("electrical_arc_01_system"); }
public void OnRoundEvents(Event event, const char[] name, bool dontBroadcast) { if (fDistance < 1.0) { return; } for (int i = 1; i <= MaxClients; i++) { if (IsClientInGame(i)) { iPounces[i] = 0; iPenalty[i] = 0; iListPage[i] = 1; bShowPenalty[i] = true; for (int i2 = 0; i2 < 3; i2++) { fPouncePos[i][i2] = 0.0; } if (hPenaltyTime[i] != null) { if (StrEqual(sGame, "left4dead2", false)) { KillTimer(hPenaltyTime[i]); } hPenaltyTime[i] = null; } } } }
public void OnAbilityUse(Event event, const char[] name, bool dontBroadcast) { if (fDistance <= 0.0) { return; } int user = GetClientOfUserId(event.GetInt("userid")); if (user < 1 || !IsClientInGame(user) || GetClientTeam(user) != 3 || GetEntProp(user, Prop_Send, "m_zombieClass") != 3) { return; } char sAbility[24]; event.GetString("ability", sAbility, 24); if (StrEqual(sAbility, "ability_lunge", false)) { if (iPounces[user] <= iMaxAttempts) { GetClientAbsOrigin(user, fPouncePos[user]); } if (!IsFakeClient(user)) { CreateTimer(0.1, MakeFartherPounce, user); } } }
public Action MakeFartherPounce(Handle timer, any client) { KillTimer(timer); if (!IsServerProcessing()) { return Plugin_Stop; } float fVelocity[3]; GetEntPropVector(client, Prop_Data, "m_vecVelocity", fVelocity); fVelocity[0] *= 1.0; fVelocity[1] *= 1.0; fVelocity[2] *= 1.2; TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, fVelocity); return Plugin_Stop; }
public void OnLungePounce(Event event, const char[] name, bool dontBroadcast) { if (fDistance < 1.0) { return; } int pouncer = GetClientOfUserId(event.GetInt("userid")); if (pouncer < 1 || pouncer > MaxClients || !IsClientInGame(pouncer) || GetClientTeam(pouncer) != 3 || GetEntProp(pouncer, Prop_Send, "m_zombieClass") != 3) { return; } int pounced = GetClientOfUserId(event.GetInt("victim")); if (pounced < 1 || pounced > MaxClients || !IsClientInGame(pounced) || GetClientTeam(pounced) != 2) { return; } float fLandedPos[3]; GetClientAbsOrigin(pouncer, fLandedPos); if (GetVectorDistance(fPouncePos[pouncer], fLandedPos) < fDistance) { CPrintToChat(pouncer, "\x04Fatal Jump\x01 \x03Failed!\x01 \x05(\x04%.1f\x05 / \x04%.1f\x05)", GetVectorDistance(fPouncePos[pouncer], fLandedPos), fDistance); return; } if (iPounces[pouncer] > iMaxAttempts) { CPrintToChat(pouncer, "\x03Maximum Limits Reached!\x01 \x04%s\x01", (GetUserAdmin(pouncer) == INVALID_ADMIN_ID) ? "" : " \x03Please Wait Other Round\x01"); return; } if (iPenalty[pouncer] > 0) { if (!bShowPenalty[pouncer]) { CPrintToChat(pouncer, "\x04Fatal Jump\x01 For \x03Please Wait!\x01"); } return; } int iDmg = (GetEntProp(pounced, Prop_Send, "m_isIncapacitated", 1)) ? GetClientHealth(pounced) : (GetClientHealth(pounced) + FindConVar("survivor_incap_health").IntValue); BHPStats(pouncer, 1, iDmg, RoundFloat(GetVectorDistance(fPouncePos[pouncer], fLandedPos)), true); Event ePlayerHurt = CreateEvent("player_hurt", true); ePlayerHurt.SetInt("userid", GetClientUserId(pounced)); ePlayerHurt.SetInt("attacker", GetClientUserId(pouncer)); ePlayerHurt.SetString("weapon", "hunter_claw"); ePlayerHurt.SetInt("dmg_health", iDmg); ePlayerHurt.Fire(); if (!GetEntProp(pounced, Prop_Send, "m_isIncapacitated", 1) && GetEntProp(pounced, Prop_Send, "m_currentReviveCount") < FindConVar("survivor_max_incapacitated_count").IntValue) { Event ePlayerIncapacitated = CreateEvent("player_incapacitated", true); ePlayerIncapacitated.SetInt("userid", GetClientUserId(pounced)); ePlayerIncapacitated.SetInt("attacker", GetClientUserId(pouncer)); ePlayerIncapacitated.SetString("weapon", "hunter_claw"); ePlayerIncapacitated.Fire(); } ForcePlayerSuicide(pounced); EmitSoundToAll(HUNTER, SNDCHAN_WEAPON, SNDLEVEL_SCREAMING); ExplodeMain(fLandedPos); Event ePlayerDeath = CreateEvent("player_death", true); ePlayerDeath.SetInt("userid", GetClientUserId(pounced)); ePlayerDeath.SetInt("attacker", GetClientUserId(pouncer)); ePlayerDeath.SetString("weapon", "hunter_claw"); ePlayerDeath.Fire(); iPounces[pouncer] += 1; CPrintToChat(pouncer, "\x05Your Hunter Kills In This Round: \x04(\x01\x03%d / %i\x01\x04)\x01", iPounces[pouncer], iMaxAttempts + 1); if (bShowDamage && bShowDistance) { CPrintToChatAll("\x03%N\x01 \x05Was\x01 Brutally Pounced \x05By\x01 \x03%N\x01 \x05From A Deadly Distance\x01 \x04[\x01%.2f\x04]\x01 \x05And Got His\x01 Spine Broken.", pounced, pouncer, GetVectorDistance(fPouncePos[pouncer], fLandedPos)); } /*else if (bShowDamage) { CPrintToChatAll("{orange}[{red}HUNTER{orange}] {olive}%N{default} Brutally Pounced {olive}%N! {orange}[%i Dmg]", pouncer, pounced, iDmg); } else if (bShowDistance) { CPrintToChatAll("\x03%N\x01 \x05Was\x01 Brutally Pounced \x05By\x01 \x03%N\x01 \x05From A Deadly Distance\x01 \x04[\x01%.2f\x04]\x01 \x05And Got His\x01 Spine Broken.", pouncer, pounced, GetVectorDistance(fPouncePos[pouncer], fLandedPos)); } else { CPrintToChatAll("\x03%N\x01 \x05Was\x01 Brutally Pounced \x05By\x01 \x03%N\x01 \x05From A Deadly Distance\x01 \x04[\x01%.2f\x04]\x01 \x05And Got His\x01 Spine Broken.", pouncer, pounced); } */ if (hPenaltyTime[pouncer] == null) { iPenalty[pouncer] = RoundToNearest(fCoolTime * iPounces[pouncer]); hPenaltyTime[pouncer] = CreateTimer(1.0, ShowNextBP, pouncer, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT); } }
public Action ShowNextBP(Handle timer, any client) { if (!IsClientInGame(client)) { if (hPenaltyTime[client] != null) { if (StrEqual(sGame, "left4dead2", false)) { KillTimer(hPenaltyTime[client]); } hPenaltyTime[client] = null; } return Plugin_Stop; } if (hPenaltyTime[client] == null) { return Plugin_Stop; } if (iPenalty[client] < 1) { CPrintToChat(client, "\x05Again You Can Make\x01 \x04A Fatal Jump.\x01"); if (hPenaltyTime[client] != null) { if (StrEqual(sGame, "left4dead2", false)) { KillTimer(hPenaltyTime[client]); } hPenaltyTime[client] = null; } return Plugin_Stop; } if (bShowPenalty[client]) { PrintHintText(client, "Wait %d %s For You Next Fatal Jump\nType !hunthud To Hide This Timer", iPenalty[client], (iPenalty[client] == 1) ? "Second" : "Seconds"); } iPenalty[client] -= 1; return Plugin_Continue; }
void BHPStats(int client, int iKill = 0, int iDamage = 0, int iDistance = 0, bool bUpdate = false, int iPage = 1) { char sRequirePath[PLATFORM_MAX_PATH]; BuildPath(Path_SM, sRequirePath, sizeof(sRequirePath), "data/bhpstats"); if (!DirExists(sRequirePath)) { CreateDirectory(sRequirePath, FPERM_O_READ|FPERM_O_WRITE|FPERM_O_EXEC); } BuildPath(Path_SM, sRequirePath, sizeof(sRequirePath), "data/bhpstats/%s.txt", sMap); KeyValues kvStats = new KeyValues("bhpstats"); if (!bUpdate) { if (!kvStats.ImportFromFile(sRequirePath)) { CPrintToChat(client, "\x04[\x05SM\x04]\x01 No Saved Data!"); delete kvStats; return; } kvStats.JumpToKey("pouncers"); int iTotal = kvStats.GetNum("total", 0); decl String:bhpNames[iTotal][MAX_NAME_LENGTH]; new bhpRecord[iTotal][4]; kvStats.GoBack(); kvStats.JumpToKey("records"); kvStats.GotoFirstSubKey(); for (int i = 0; i < iTotal; i++) { kvStats.GetString("name", bhpNames[i], MAX_NAME_LENGTH, "Unknown Player"); bhpRecord[i][0] = i; //bhpRecord[i][1] = kvStats.GetNum("kills", 0); //bhpRecord[i][2] = kvStats.GetNum("dmg", 0); bhpRecord[i][3] = kvStats.GetNum("dist", 0); kvStats.GotoNextKey(); } SortCustom2D(bhpRecord, iTotal, BPRankSort); Panel pStats = new Panel(); char sTitle[128]; Format(sTitle, sizeof(sTitle), "MAP: (%s)", sMap); pStats.SetTitle(sTitle); pStats.DrawText(" \n"); char sTextList[128]; for (int i = (iListType == 0 && iPage > 1) ? iListMax * iPage : 0; i < iTotal; i++) { if (bShowKills) { if (bShowDamage && bShowDistance) { if (i == 0) { if (bAvgDistance) { strcopy(sTextList, sizeof(sTextList), "No. Name | Avg. Distance"); } else { strcopy(sTextList, sizeof(sTextList), "No. Name | Avg. Distance"); } pStats.DrawText(sTextList); } Format(sTextList, sizeof(sTextList), "%i. %s | %d", i + 1, bhpNames[bhpRecord[i][0]], bhpRecord[i][3]); } else if (bShowDamage) { if (i == 0) { strcopy(sTextList, sizeof(sTextList), "No. Name | Avg. Distance"); pStats.DrawText(sTextList); } Format(sTextList, sizeof(sTextList), "%i. %s | %d", i + 1, bhpNames[bhpRecord[i][0]], bhpRecord[i][3]); } else if (bShowDistance) { if (i == 0) { if (bAvgDistance) { strcopy(sTextList, sizeof(sTextList), "No. Name | Avg. Distance"); } else { strcopy(sTextList, sizeof(sTextList), "No. Name | Avg. Distance"); } pStats.DrawText(sTextList); } Format(sTextList, sizeof(sTextList), "%i. %s | %d", i+1, bhpNames[bhpRecord[i][0]], bhpRecord[i][3]); } else { if (i == 0) { strcopy(sTextList, sizeof(sTextList), "No. Name - Kills"); pStats.DrawText(sTextList); } Format(sTextList, sizeof(sTextList), "%i. %s - %d", i + 1, bhpNames[bhpRecord[i][0]], bhpRecord[i][1]); } } else { if (bShowDamage && bShowDistance) { if (i == 0) { if (!bAvgDistance) { strcopy(sTextList, sizeof(sTextList), "No. Name | Avg. Distance"); } else { strcopy(sTextList, sizeof(sTextList), "No. Name | Avg. Distance"); } pStats.DrawText(sTextList); } Format(sTextList, sizeof(sTextList), "%i. %s | %d", i + 1, bhpNames[bhpRecord[i][0]], bhpRecord[i][3]); } else if (bShowDamage) { if (i == 0) { strcopy(sTextList, sizeof(sTextList), "No. Name - Damage"); pStats.DrawText(sTextList); } Format(sTextList, sizeof(sTextList), "%i. %s - %d", i + 1, bhpNames[bhpRecord[i][0]], bhpRecord[i][2]); } else if (bShowDistance) { if (i == 0) { if (!bAvgDistance) { strcopy(sTextList, sizeof(sTextList), "No. Name - Distance"); } else { strcopy(sTextList, sizeof(sTextList), "No. Name - Avg. Distance"); } pStats.DrawText(sTextList); } Format(sTextList, sizeof(sTextList), "%i. %s - %d", i + 1, bhpNames[bhpRecord[i][0]], bhpRecord[i][3]); } else { if (i == 0) { strcopy(sTextList, sizeof(sTextList), "No. Name "); pStats.DrawText(sTextList); } Format(sTextList, sizeof(sTextList), "%i. %s", i + 1, bhpNames[bhpRecord[i][0]]); } } pStats.DrawText(sTextList); if (i >= (iListMax * iPage) - 1 || i >= iTotal) { pStats.DrawText(" \n"); if (iListType != 1) { if (iPage > 1) { pStats.DrawItem("Back"); } if (i + iListMax < iTotal) { pStats.DrawItem("Next"); } pStats.DrawText(" \n"); } break; } } Format(sTextList, sizeof(sTextList), "%d Brutal %s Recorded On This Map!", iTotal, (iTotal > 1) ? "Pouncers" : "Pouncer"); pStats.DrawText(sTextList); pStats.Send(client, pStatsHandler, 20); delete pStats; } else { char sFileVersion[16]; kvStats.GetString("Version", sFileVersion, sizeof(sFileVersion), "0.0"); if (FileExists(sRequirePath) && !StrEqual(sFileVersion, "3.12", false)) { DeleteFile(sRequirePath); } char sName[MAX_NAME_LENGTH], sSteamID[32]; int iTotal, iTotalKill, iTotalDmg, iTotalDist; GetClientName(client, sName, sizeof(sName)); GetClientAuthString(client, sSteamID, sizeof(sSteamID)); kvStats.ImportFromFile(sRequirePath); kvStats.SetString("version", "3.12"); kvStats.JumpToKey("records", true); if (!kvStats.JumpToKey(sSteamID)) { kvStats.GoBack(); kvStats.JumpToKey("pouncers", true); iTotal = kvStats.GetNum("total", 0); iTotal += 1; kvStats.SetNum("total", iTotal); kvStats.GoBack(); kvStats.JumpToKey("records"); kvStats.JumpToKey(sSteamID, true); } kvStats.SetString("name", sName); iTotalKill = kvStats.GetNum("kills", 0); iTotalKill += 1; kvStats.SetNum("kills", iTotalKill); iTotalDmg = kvStats.GetNum("dmg", 0); iTotalDmg += iDamage; kvStats.SetNum("dmg", iTotalDmg); iTotalDist = kvStats.GetNum("dist", 0); iTotalDist += iDistance; if (bAvgDistance) { kvStats.SetNum("dist", RoundFloat(float(iTotalDist) / float(iTotalKill))); } else { kvStats.SetNum("dist", iTotalDist); } kvStats.Rewind(); kvStats.ExportToFile(sRequirePath); } delete kvStats; }
public int BPRankSort(int[] array1, int[] array2, const int[][] completeArray, Handle hndl) { if (array1[iRankType+1] > array2[iRankType+1]) { return -1; } if (array1[iRankType+1] == array2[iRankType+1]) { return 0; } return 1; }
public int pStatsHandler(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_Select && iListType != 0) { if (param1 > 0 && param1 <= MaxClients && IsClientInGame(param1)) { iListPage[param1] += (param2 == 1) ? 1 : (-1); BHPStats(param1, _, _, _, _, iListPage[param1]); } } }
public ExplodeMain(Float:pos[3]) { ShowParticle(pos, "electrical_arc_01_system", 5.0); LittleFlower(pos, EXPLODE); ShowParticle(pos, "gas_explosion_main", 5.0); LittleFlower(pos, MOLOTOV); }
public ShowParticle(Float:pos[3], String:particlename[], Float:time) { /* Show particle effect you like */ new particle = CreateEntityByName("info_particle_system"); if (IsValidEdict(particle)) { TeleportEntity(particle, pos, NULL_VECTOR, NULL_VECTOR); DispatchKeyValue(particle, "effect_name", particlename); DispatchKeyValue(particle, "targetname", "particle"); DispatchSpawn(particle); ActivateEntity(particle); AcceptEntityInput(particle, "start"); CreateTimer(time, DeleteParticles, particle); } }
public PrecacheParticle(String:particlename[]) { /* Precache particle */ new particle = CreateEntityByName("info_particle_system"); if (IsValidEdict(particle)) { DispatchKeyValue(particle, "effect_name", particlename); DispatchKeyValue(particle, "targetname", "particle"); DispatchSpawn(particle); ActivateEntity(particle); AcceptEntityInput(particle, "start"); CreateTimer(0.01, DeleteParticles, particle); } }
public Action:DeleteParticles(Handle:timer, any:particle) { /* Delete particle */ if (IsValidEntity(particle)) { new String:classname[64]; GetEdictClassname(particle, classname, sizeof(classname)); if (StrEqual(classname, "info_particle_system", false)) RemoveEdict(particle); } }
public LittleFlower(Float:pos[3], type) { /* Cause fire(type=0) or explosion(type=1) */ new entity = CreateEntityByName("prop_physics"); if (IsValidEntity(entity)) { pos[2] += 10.0; if (type == 0) /* fire */ DispatchKeyValue(entity, "model", "models/props_junk/gascan001a.mdl"); else /* explode */ DispatchKeyValue(entity, "model", "models/props_junk/propanecanister001a.mdl"); DispatchSpawn(entity); SetEntData(entity, GetEntSendPropOffs(entity, "m_CollisionGroup"), 1, 1, true); TeleportEntity(entity, pos, NULL_VECTOR, NULL_VECTOR); AcceptEntityInput(entity, "break"); } }
Last edited by Darkwob; 09-28-2021 at 13:53.
|
|