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

Plugin deficiencies I cannot figure out


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Halt
Senior Member
Join Date: Jan 2015
Location: Black Mesa
Old 09-14-2017 , 20:46   Plugin deficiencies I cannot figure out
Reply With Quote #1

Alright so there are a few items I cannot get functioning properly on my mod/server. I've held out on asking them because they seem simple enough to fix but every method I've tried fails. Any feedback helps! Thanks!

1. mp_waitingforplayers_cancel 1
I cannot seem to change this cvar value for the life of me. Its in my server.cfg, I've tried putting it in OnPluginStart and OnMapStart as
Code:
ServerCommand("mp_waitingforplayers_cancel 1");
I've even attempted putting it in a timer thinking it was being fired too soon on map start. What really gets me is if I type sm_cvar mp_waitingforplayers_cancel 1 AFTER the waiting time starts it stops it and begins the round setup time. but the overall value will still remain 0. This interferes with my plugins custom timer that has to be in tune with my custom maps timer. Therefore ruining the first two rounds.

2. Getting the first random zombie
Sometimes it selects two random players. It should only select one for the time being. This creates a real issue when there are only two players left then it instantly restarts the round which is a headache. I have no clue why this all of a sudden stopped working. It only seems to fail on the first few rounds (perhaps its because of the waiting for players time). Here are the two blocks that deal with that functionality.

PHP Code:
public Action _GetZombie(Handle timer)
{
    new 
Zombie GetRandomPlayer();
    
CreateTimer(0.3RespawnPlayerZombie);
    
PrintToChat(Zombie"\x07ff2929[\x0730FF31ZomXR\x07ff2929] - \x07e3f010You've been selected as the first zombie");
    
PrintToChatAll("\x07ff2929[\x0730FF31ZomXR\x07ff2929] - \x07e3f010%N is the zombie leader!"Zombie);

PHP Code:
GetRandomPlayer()
{
    new 
players[MaxClients 1];
    new 
ClientCount;
    for(new 
1<= MaxClientsi++)
        if(
IsClientInGame(i))
            if(
PlayerTeam[i] == TFTeam_Blue && PlayerClass[i] >= 1)
                
players[ClientCount++] = i;
    return (
ClientCount == 0) ? -players[GetRandomInt(0ClientCount 1)];


3. Some errors that do not seem to affect game play.
Code:
L 05/31/2017 - 13:31:07: [SM]   [1] Line 960, C:\Users\Halt03\Desktop\Dev\Programming\SourceMod 1.8\scripting\ZombieX_Reloaded.sp::RespawnPlayer
L 05/31/2017 - 13:36:22: [SM] Exception reported: Client index 0 is not valid
Here is line 960 and the block its in
PHP Code:
public Action LastHumanTimer(Handle timerany Client)
{
    if(
IsClientInGame(Client))
    {
        
PrintToChatAll("\x07ff2929[\x0730FF31ZomXR\x07ff2929] - \x07e3f010%N is our last hope!"Client);
        
PrintToChat(Client"\x07ff2929[\x0730FF31ZomXR\x07ff2929] - \x07e3f010+30 ZomPoints!");
        switch(
GetRandomInt(15))
        {
            case 
1:
            {
                
EmitSoundToAll("black_sun_studios/zombiex_reloaded/last_man1.wav");
                
SoundPlaying "black_sun_studios/zombiex_reloaded/last_man1.wav";
            }
            case 
2:
            { 
//<------------LINE 960 -------------------
                
EmitSoundToAll("black_sun_studios/zombiex_reloaded/last_man2.wav");
                
SoundPlaying "black_sun_studios/zombiex_reloaded/last_man2.wav";
            } 

Error 2
Code:
L 06/02/2017 - 00:11:40: [SM]   [0] TF2_RespawnPlayer
L 06/02/2017 - 00:11:40: [SM]   [1] Line 995, C:\Users\Halt03\Desktop\Dev\Programming\SourceMod 1.8\scripting\ZombieX_Reloaded.sp::RespawnPlayer
L 06/02/2017 - 00:16:55: [SM] Exception reported: Client index 0 is not valid
PHP Code:
public Action RespawnPlayer(Handle timerany Client)
{
    if(!
IsValidClient(Client))
        return
    else
        
TF2_RespawnPlayer(Client);

I don't understand either of these errors because I check to see if their valid clients and in game.
Halt is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 09-14-2017 , 21:34   Re: Plugin deficiencies I cannot figure out
Reply With Quote #2

For #3, you garbled the error messages. They should look like this:

Code:
L 08/11/2017 - 16:54:41: [SM] Exception reported: Some error message
L 08/11/2017 - 16:54:41: [SM] Blaming: someplugin.smx
L 08/11/2017 - 16:54:41: [SM] Call stack trace:
L 08/11/2017 - 16:54:41: [SM]   [0] somefunction
L 08/11/2017 - 16:54:41: [SM]   [1] Line 182, someplugin.sp::someotherfunction
...maybe more stack frames
You grouped the lines together wrong. Maybe the blaming line isn't there in 1.8, I don't remember.

But anyway, for #3, you can't check IsClientInGame(0) which might be what you're doing. Zero isn't a valid client number. I don't know what IsClientValid is, it's not part of SM itself.

For #2, you haven't provided enough code. It would be easier if you attached your whole plugin for reference, but you will have to show all the places you call the two functions you did supply.

For #1, that might actually be a command even though it looks like a cvar. It might only work when set during waiting for players. I don't know, though.
Fyren is offline
Halt
Senior Member
Join Date: Jan 2015
Location: Black Mesa
Old 09-14-2017 , 22:22   Re: Plugin deficiencies I cannot figure out
Reply With Quote #3

#1 so shouldn't it run when I use it in the ServerCommand function?


For #2 that is the only place I use GetRandomPlayer unless the first zombie disconnects, in this case its not even calling that block so wouldn't the error lay in the code provided?

The only other place GetRadnomPlayer is called.

PHP Code:
public void OnClientDisconnect_Post(int Client)
{
    
bIsPlayerAlive[Client] = false;
    
bIsPlayerZombie[Client] = false;
    
PlayerSpawnTimer[Client] = false;
    
ArtillaryRestriction[Client] = false;
    
ZomPoints[Client] = 0;
    
KillStreak[Client] = 0;
    
    if(!
HasRoundStarted)
        return;
    if(
GetTeamClientCount(2) == && GetTeamClientCount(3) == || GetTeamClientCount(2) >= && GetTeamClientCount(3) == 0)
        
ServerCommand("mp_forcewin 2");
    else if(
GetTeamClientCount(2) == && GetTeamClientCount(3) >= 1)
    {
        if(
GetTeamClientCount(3) >= 2)
        {
            
TF2_RespawnPlayer(GetRandomPlayer());
            return;
        }
        
        
CreateTimer(0.1ResetRound);
    }

The only place _GetZombie is called.

PHP Code:
public Action StartTheRound(Handle timer)
{
    
HasRoundStarted true;
    
CreateTimer(1.0_GetZombie);
    
EmitSoundToAll("ambient/wolf01.wav");
    
PrintToChatAll("\x07ff2929[\x0730FF31ZomXR\x07ff2929] - \x07e3f010Here they come! Outbreaks begun!");


Edit - Fixed RespawnPlayer Error
I added IsClientConnected to the else end of the if statement.

Last edited by Halt; 09-14-2017 at 22:27.
Halt is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 09-15-2017 , 07:39   Re: Plugin deficiencies I cannot figure out
Reply With Quote #4

you are getting more than 1 zombie probablyo b/c _GetZombie ran more than once
try killing the timer before starting another 1
8guawong is offline
Halt
Senior Member
Join Date: Jan 2015
Location: Black Mesa
Old 09-15-2017 , 10:54   Re: Plugin deficiencies I cannot figure out
Reply With Quote #5

I will go ahead and add that, but any idea on the mp_waitingforplayercancel? This is my main issue the first 30 seconds that only happens once per map change is really interfering with the mod.
Halt is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 09-15-2017 , 11:00   Re: Plugin deficiencies I cannot figure out
Reply With Quote #6

Quote:
Originally Posted by Halt View Post
I will go ahead and add that, but any idea on the mp_waitingforplayercancel? This is my main issue the first 30 seconds that only happens once per map change is really interfering with the mod.
i don't play tf2 sorry so i donno anything about that cvar and how it works
8guawong is offline
Halt
Senior Member
Join Date: Jan 2015
Location: Black Mesa
Old 09-15-2017 , 14:34   Re: Plugin deficiencies I cannot figure out
Reply With Quote #7

Quote:
Originally Posted by 8guawong View Post
i don't play tf2 sorry so i donno anything about that cvar and how it works
Perhaps someone who works with VSH & ZombieFortress?
Halt is offline
Halt
Senior Member
Join Date: Jan 2015
Location: Black Mesa
Old 09-15-2017 , 15:11   Re: Plugin deficiencies I cannot figure out
Reply With Quote #8

I'm going to go ahead and give this method a try.

PHP Code:
ConVar WaitingForPlayers;

public 
void OnMapStart()
{
    
WaitingForPlayers FindConVar("mp_waitingforplayers_cancel");
    if (
GetConVarInt(WaitingForPlayers) != 1)
    {
        
SetConVarInt(WaitingForPlayers1falsefalse);
    }

Halt is offline
Halt
Senior Member
Join Date: Jan 2015
Location: Black Mesa
Old 09-15-2017 , 15:38   Re: Plugin deficiencies I cannot figure out
Reply With Quote #9

So the method above did not work. I think I'm just going to try and write around the waiting for players time. In order to do that I need to find my map entity that controls the time and send an input to it. How would I locate an entity on the map preferably by name not classname. Would I use

FindEntityByClassname

In short, I'm going to start a 30 second timer on map start that enables my map timer to begin. So 30 seconds after the map loads (waiting for players time) the mod resumes my maps timer.
Halt is offline
Halt
Senior Member
Join Date: Jan 2015
Location: Black Mesa
Old 09-20-2017 , 13:57   Re: Plugin deficiencies I cannot figure out
Reply With Quote #10

So I have two more questions a little more geared towards scripting.

This runs when there is only one human remaining.

PHP Code:
        switch(GetRandomInt(15))
        {
            case 
1:
            {
                
EmitSoundToAll("black_sun_studios/zombiex_reloaded/last_man1.wav");
                
SoundPlaying "black_sun_studios/zombiex_reloaded/last_man1.wav";
            }
            case 
2:
            {
                
EmitSoundToAll("black_sun_studios/zombiex_reloaded/last_man2.wav");
                
SoundPlaying "black_sun_studios/zombiex_reloaded/last_man2.wav";
            }
            case 
3:
            {
                
EmitSoundToAll("black_sun_studios/zombiex_reloaded/last_man3.wav");
                
SoundPlaying "black_sun_studios/zombiex_reloaded/last_man3.wav";
            }
            case 
4:
            {
                
EmitSoundToAll("black_sun_studios/zombiex_reloaded/last_man4.wav");
                
SoundPlaying "black_sun_studios/zombiex_reloaded/last_man4.wav";
            }
            case 
5:
            {
                
EmitSoundToAll("black_sun_studios/zombiex_reloaded/last_man5.wav");
                
SoundPlaying "black_sun_studios/zombiex_reloaded/last_man4.wav"
            
}
        } 
And I'd like to use StopSound when the round ends to cut off the sound playing. How would I use the StopSound function? SoundPlaying being the variable containing the sounds path.

PHP Code:
//I've tried this
StopSound(SoundPlayingsizeof(SoundPlaying)); 

Also in Tf2 does mp_forcewin fire game event teamplay_round_win?

Last edited by Halt; 09-20-2017 at 14:04.
Halt 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 12:51.


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