Senior Member
|
12-25-2015
, 18:42
What's wrong?
|
#1
|
Happy Holidays everyone!!
retrieveCachedData() is not retrieving info... I created a keyvalues Handle previously, now I wanted to use it again to search another value.. however it seems to not be working? Can someone help me please? :p
PHP Code:
#pragma semicolon 1
#define DEBUG
#define PLUGIN_AUTHOR "" #define PLUGIN_VERSION "0.00"
#define Kv_Location "configs/_loc/location.cfg"
#include <sourcemod> #include <sdktools> #include <cstrike>
bool AmmoWhitelisted[MAXPLAYERS + 1]; bool GodWhitelisted[MAXPLAYERS + 1]; bool RespawnWhitelisted[MAXPLAYERS + 1];
KeyValues kv;
Handle g_adtArray;
public Plugin myinfo = { name = "", author = PLUGIN_AUTHOR, description = "", version = PLUGIN_VERSION, url = "" };
public void OnPluginStart() { RegConsoleCmd("sm_tpmenu", buildUI, "builds UI"); CreateTimer(2.0, loopremove, _, TIMER_REPEAT); g_adtArray = CreateArray(32); }
public void OnMapEnd() { ClearArray(g_adtArray); }
public void OnMapStart() { CacheinitVl(); }
public bool CacheinitVl() { kv = new KeyValues("locations"); char buffer[256]; char dirLoc[PLATFORM_MAX_PATH]; BuildPath(Path_SM, dirLoc, sizeof(dirLoc), Kv_Location); FileToKeyValues(kv, dirLoc); if (!KvGotoFirstSubKey(kv)) { CloseHandle(kv); return false; // cfg is broken... } do { KvGetSectionName(kv, buffer, sizeof(buffer)); PushArrayString(g_adtArray, buffer); // get section name, store into a dynamic array } while (KvGotoNextKey(kv)); return true; }
public int handlerUI(Menu menu, MenuAction action, int parameterCL, int parameterARGS) { /* If an option was selected, tell the client about the item. */ if (action == MenuAction_Select) { char selectedName[32]; menu.GetItem(parameterARGS, selectedName, sizeof(selectedName)); bool found = retrieveCachedData(parameterCL, selectedName); if (!found) { PrintHintText(parameterCL, "<font size='35'><font color = '#FF0000'>ERROR: Data is missing for the given section! Please contact the admin. Could not teleport.</font></font>"); } /* Know which section we talkin' bout = selectedName = Section*/ /* Compare data with the keyValues */ /* Retrieve Info */ /* Teleport */ } /* If the menu was cancelled, print a message to the server about it. */ else if (action == MenuAction_Cancel) { PrintToServer("Client %d's menu was cancelled. Reason: %d", parameterCL, parameterARGS); } /* If the menu has ended, destroy it */ else if (action == MenuAction_End) { delete menu; } }
public Action buildUI(int cl, int args) { char buffer[32]; Menu menu = new Menu(handlerUI); menu.SetTitle("Teleport to:"); for (int i = 0; i < GetArraySize(g_adtArray); i++) { GetArrayString(g_adtArray, i, buffer, sizeof(buffer)); menu.AddItem(buffer, buffer); } menu.ExitButton = true; menu.Display(cl, MENU_TIME_FOREVER); return Plugin_Handled; }
public bool retrieveCachedData(int cl, char[] section) { PrintToChatAll("Section: being itterated: %s", section); int tempAmmoInt = 0; int tempGodInt = 0; int tempRespawnInt = 0; float temploc[3]; if (!kv.JumpToKey(section)) { PrintToChatAll("You fucked it big sir..."); return false; // no setted section ??? } int clteam = GetClientTeam(cl); // grab locations switch (clteam) { case CS_TEAM_CT: { kv.GetFloat("ctlocx", temploc[0]); kv.GetFloat("ctlocy", temploc[1]); kv.GetFloat("ctlocz", temploc[2]); } case CS_TEAM_T: { kv.GetFloat("tlocx", temploc[0]); kv.GetFloat("tlocy", temploc[1]); kv.GetFloat("tlocz", temploc[2]); } } // grab ammo kv.GetNum("ammo", tempAmmoInt); switch (tempAmmoInt) { case 1: { AmmoWhitelisted[cl] = true; } case 0: { AmmoWhitelisted[cl] = false; } } kv.GetNum("god", tempGodInt); switch (tempGodInt) { case 1: { GodWhitelisted[cl] = true; } case 0: { GodWhitelisted[cl] = false; } } kv.GetNum("respawn", tempRespawnInt); switch (tempRespawnInt) { case 1: { RespawnWhitelisted[cl] = true; } case 0: { RespawnWhitelisted[cl] = false; } } handlecl(cl, temploc, AmmoWhitelisted[cl], GodWhitelisted[cl], RespawnWhitelisted[cl]); delete kv; return true; }
public handlecl(int cl, float pos[3], bool ammo, bool god, bool respawn) { TeleportEntity(cl, pos, NULL_VECTOR, NULL_VECTOR); PrintToChat(cl, "You were given: %s", ammo ? "Ammo | " : "", god ? "God | " : "", respawn ? "Respawn | " : ""); if (god) { ApplyGodMode(cl); } }
public Action loopremove(Handle timer) { int ent; if (GameRules_GetProp("m_bWarmupPeriod") == 0) // it's not warm up { for (int i = 1; i < MaxClients; i++) { if (IsClientInGame(i) && IsPlayerAlive(i) && !AmmoWhitelisted[i]) { for (int wep; wep < 4; wep++) { if ((ent = GetPlayerWeaponSlot(i, wep)) != -1) { SetEntProp(ent, Prop_Send, "m_iPrimaryReserveAmmoCount", 0); SetEntProp(ent, Prop_Send, "m_iClip1", 0); } } } } } }
public bool ApplyGodMode(int cl) { if (cl > 0 && cl <= MaxClients && IsClientConnected(cl) && IsClientInGame(cl) && IsPlayerAlive(cl)) { SetEntProp(cl, Prop_Data, "m_takedamage", 0, 1); // godmode } }
public OnClientDisconnect(cl) { AmmoWhitelisted[cl] = false; GodWhitelisted[cl] = false; RespawnWhitelisted[cl] = false; }
/*public OnPlayerSpawned(Handle event, char name[], bool dontBroadcast) { int cl = GetClientOfUserId(GetEventInt(event, "userid"));
//Had godmode on before -> reapply if (RespawnWhitelisted[cl]) { Handle Packhead; CreateDataTimer(0.1, teleportback, Packhead); WritePackCell(Packhead, cl); WritePackCell(Packhead, 1); } }*/
__________________
Perhaps my lack of faith was my undoing,
Last edited by bally; 12-25-2015 at 18:43.
|
|