Raised This Month: $12 Target: $400
 3% 

What's wrong?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bally
Senior Member
Join Date: Aug 2015
Old 12-25-2015 , 18:42   What's wrong?
Reply With Quote #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.0loopremove_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_SMdirLocsizeof(dirLoc), Kv_Location);
    
    
    
FileToKeyValues(kvdirLoc);
    if (!
KvGotoFirstSubKey(kv))
    {
        
CloseHandle(kv);
        return 
false;
        
// cfg is broken...
    
}
    
    do {
        
        
KvGetSectionName(kvbuffersizeof(buffer));
        
PushArrayString(g_adtArraybuffer);
        
// get section name, store into a dynamic array
        
    
} while (KvGotoNextKey(kv));
    
    return 
true;
}

public 
int handlerUI(Menu menuMenuAction actionint parameterCLint parameterARGS)
{
    
/* If an option was selected, tell the client about the item. */
    
    
if (action == MenuAction_Select)
    {
        
char selectedName[32];
        
menu.GetItem(parameterARGSselectedNamesizeof(selectedName));
        
bool found retrieveCachedData(parameterCLselectedName);
        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"parameterCLparameterARGS);
    }
    
/* If the menu has ended, destroy it */
    
else if (action == MenuAction_End)
    {
        
delete menu;
    }
}


public 
Action buildUI(int clint args)
{
    
char buffer[32];
    
Menu menu = new Menu(handlerUI);
    
menu.SetTitle("Teleport to:");
    
    for (
int i 0GetArraySize(g_adtArray); i++)
    {
        
GetArrayString(g_adtArrayibuffersizeof(buffer));
        
menu.AddItem(bufferbuffer);
    }
    
menu.ExitButton true;
    
menu.Display(clMENU_TIME_FOREVER);
    
    return 
Plugin_Handled;
}

public 
bool retrieveCachedData(int clchar[] 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(cltemplocAmmoWhitelisted[cl], GodWhitelisted[cl], RespawnWhitelisted[cl]);
    
delete kv;
    return 
true;
}

public 
handlecl(int clfloat pos[3], bool ammobool godbool respawn)
{
    
TeleportEntity(clposNULL_VECTORNULL_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 1MaxClientsi++)
        {
            if (
IsClientInGame(i) && IsPlayerAlive(i) && !AmmoWhitelisted[i])
            {
                for (
int wepwep 4wep++)
                {
                    if ((
ent GetPlayerWeaponSlot(iwep)) != -1)
                    {
                        
SetEntProp(entProp_Send"m_iPrimaryReserveAmmoCount"0);
                        
SetEntProp(entProp_Send"m_iClip1"0);
                    }
                }
                
            }
            
        }
    }
    
}

public 
bool ApplyGodMode(int cl)
{
    if (
cl && cl <= MaxClients && IsClientConnected(cl) && IsClientInGame(cl) && IsPlayerAlive(cl))
    {
        
SetEntProp(clProp_Data"m_takedamage"01); // 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.
bally is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:05.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode