1. The trade part of Lethal Zone has fully been taken over by FoG (Fortress of Gamers) and this site can no longer be used to make appeals. If you feel that your tag is unjust, please file an appeal over at https://f-o-g.eu.trade instead.

[Request] Help with SourcePawn scripting

Discussion in 'Team Fortress 2' started by Krutte, Apr 10, 2014.

  1. Krutte

    Krutte Registered

    Joined:
    Jun 29, 2013
    Messages:
    47
    Likes Received:
    0
    Hello everyone!

    I've been trying to make an already existing plugin work independently, and I think I'm done.
    The plugin is called Skeys, it's part of Jumpassist; a big plugin used by some servers to handle all kind of rocket jumping. Skeys lets you see what buttons the target you're spectating is pressing.

    I need some help getting the plugin to be enabled by default for spectating players. Here is the code that I've put together:
    http://codepad.org/0f79yoFT

    It's not pretty, basicly straight from jumpassist (which is a mess), with a few alterations. Help appreciated!

    For reference, here is the source code from jumpassist which I snagged skeys from: https://code.google.com/p/jumpassist/source/browse/scripting/, keep in mind that you have to browse up and down the folders.

    Thanks!
     
  2. rswallen

    rswallen Wizzard

    Joined:
    Apr 29, 2013
    Messages:
    488
    Likes Received:
    18
    change:
    Code:
    24   new bool:g_bGetClientKeys[MAXPLAYERS+1];
    to
    Code:
    24   new bool:g_bGetClientKeys[MAXPLAYERS+1] = { true, ... };
    and change
    Code:
    iClientToShow = i;
    to
    Code:
    continue;
    on line 78

    you should also do the IsValidClient() check before grabbing the value of "m_hObserverTarget" (if the player is not in game, you'll get errors and the function will terminate, ignoring any players after them)

    finally, use continue (not return) in OnGameFrame(), else you'll ignore all players after you reach the first player for whom certain conditions fail
     
  3. Krutte

    Krutte Registered

    Joined:
    Jun 29, 2013
    Messages:
    47
    Likes Received:
    0
    Thanks, jelly, but now it doesn't show anything at all, and it is staggering a lot when I spectate someone in 1st person view. Looks like some sort of memory leak.

    Here is the code after your changes:
    http://codepad.org/0KiCGZad
     
  4. rswallen

    rswallen Wizzard

    Joined:
    Apr 29, 2013
    Messages:
    488
    Likes Received:
    18
    Whoops.
    The IsValidClient() problerm persists (I indicated the wrong netprop)
    Here's a fixed version:
    Code:
    public OnGameFrame()
    {
    	new iClientToShow, iObserverMode;
    	for (new i = 1; i < MaxClients; i++)
    	{
    		if (IsClientInGame(i) && IsClientObserver(i) && !IsFakeClient(i) && g_bGetClientKeys)
    		{
    			if (g_iButtons & IN_SCORE)
    			{
    				continue;
    			}
    
    			iObserverMode = GetEntPropEnt(i, Prop_Send, "m_iObserverMode");
    			if (iObserverMode == 6)
    			{
    				continue;
    			}
    			
    			iClientToShow = GetEntPropEnt(i, Prop_Send, "m_hObserverTarget");
    			if (!IsValidClient(iClientToShow))
    			{
    				continue;
    			}
    			
    			// client and target validated, so do stuff
    		}
    	}
    }
     
  5. Krutte

    Krutte Registered

    Joined:
    Jun 29, 2013
    Messages:
    47
    Likes Received:
    0
    Jellyfish, I love you.
    It works like a charm! I urge you to put this on the lethal-zone rocket jump servers (removing Showkeys in the process, as it don't work together with Specinfo).
     
  6. Snelvuur

    Snelvuur King of Sand

    Joined:
    Sep 27, 2008
    Messages:
    4,036
    Likes Received:
    76
    upload the smx + source and it shall be done. (or herras me some more too, or panromir, or alias, or jellyfish)
     
  7. Krutte

    Krutte Registered

    Joined:
    Jun 29, 2013
    Messages:
    47
    Likes Received:
    0
  8. Krutte

    Krutte Registered

    Joined:
    Jun 29, 2013
    Messages:
    47
    Likes Received:
    0