Raised This Month: $344 Target: $400
 86%   Almost there!

A few errors.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Halt
Senior Member
Join Date: Jan 2015
Location: Black Mesa
Old 10-18-2017 , 11:25   A few errors.
Reply With Quote #1

So this block is intended to select a random player, but does not.

PHP Code:
public Action GetZombieTimer(Handle timer)
{
    
int Zombie GetZombie();
    
PrintToChatAll("\x07ff2929[\x0730FF31ZomXR\x07ff2929] - \x07e3f010%N a the zombie leader!"Zombie);
    
CreateTimer(0.5RespawnPlayerGetClientUserId(Zombie), TIMER_FLAG_NO_MAPCHANGE);
}

int GetZombie()
{
    
HasRoundStarted true;
    
int[] Players = new int[MaxClients +1];
    
int ClientCount;
    
    for    (
int IGC 1IGC <= MaxClientsIGC++)
    {
        if    (
IsClientInGame(IGC))
        {
            if    (
PlayerTeam[IGC] == TFTeam_Blue && bIsPlayerAlive[IGC])
                
Players[ClientCount++] = IGC;
        }
    }
    
    return (
ClientCount == 0) ? -Players[GetRandomInt(0ClientCount 1)];

Secondly this block is supposed to respawn players w/o a waiting period. "Instant respawn"

PHP Code:
CreateTimer(0.5RespawnPlayerGetClientUserId(Client), TIMER_FLAG_NO_MAPCHANGE);

public 
Action RespawnPlayer(Handle timerint Client//No client passing though timer
{
    
int iClient GetClientOfUserId(Client);
    if    (!
IsClientConnected(iClient))
        return
    else if    (
IsClientConnected(iClient))
        
TF2_RespawnPlayer(iClient);
    
    
PrintToChat(iClient"You've been respawned");

Halt is offline
cigzag
AlliedModders Donor
Join Date: Nov 2014
Location: NZ
Old 10-18-2017 , 20:41   Re: A few errors.
Reply With Quote #2

Do what the instant respawn plugin does, gets from serial

also are you calling them blocks because your unaware that these are functions? or am I just being a dick.

https://forums.alliedmods.net/showthread.php?p=2174552

Last edited by cigzag; 10-18-2017 at 20:42.
cigzag is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 10-18-2017 , 21:35   Re: A few errors.
Reply With Quote #3

Any particular reason you're caching which team players are on and whether they're alive?

If that cache data is stale, that could very much be why you're having issues.

Side note: GetClientOfUserId returns -1 if the player disconnected.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 10-18-2017 at 21:35.
Powerlord is offline
Halt
Senior Member
Join Date: Jan 2015
Location: Black Mesa
Old 10-18-2017 , 22:44   Re: A few errors.
Reply With Quote #4

Quote:
Originally Posted by Powerlord View Post
Any particular reason you're caching which team players are on and whether they're alive?

If that cache data is stale, that could very much be why you're having issues.

Side note: GetClientOfUserId returns -1 if the player disconnected.
Yes, so I'm checking because red team (zombies) have certain attributes. Secondly thanks for the side note. I am getting error logs from some timers.
Halt is offline
hmmmmm
Great Tester of Whatever
Join Date: Mar 2017
Location: ...
Old 10-18-2017 , 22:54   Re: A few errors.
Reply With Quote #5

Yeah probably PlayerTeam and/or bIsPlayerAlive aren't filled properly leading to unexpected results. You don't need to store them anyway, theres TF_GetClientTeam and IsPlayerAlive functions to do that.

Also please stop using tabs in front of if/for. 1 space is enough.
hmmmmm is offline
Halt
Senior Member
Join Date: Jan 2015
Location: Black Mesa
Old 10-19-2017 , 01:03   Re: A few errors.
Reply With Quote #6

-_-

int Client)

any Client.
Halt is offline
hmmmmm
Great Tester of Whatever
Join Date: Mar 2017
Location: ...
Old 10-19-2017 , 01:20   Re: A few errors.
Reply With Quote #7

Doesn't really matter. The variable type can be anything.
EDIT: unless you mean GetZombieTimer, that one has wrong function prototype. Should be public Action GetZombieTimer(Handle timer, any data)

Last edited by hmmmmm; 10-19-2017 at 01:22.
hmmmmm is offline
Halt
Senior Member
Join Date: Jan 2015
Location: Black Mesa
Old 10-19-2017 , 13:05   Re: A few errors.
Reply With Quote #8

Quote:
Originally Posted by hmmmmm View Post
Doesn't really matter. The variable type can be anything.
EDIT: unless you mean GetZombieTimer, that one has wrong function prototype. Should be public Action GetZombieTimer(Handle timer, any data)
GetZombieTimer doesn't need data passed to it.
Halt is offline
Timocop
AlliedModders Donor
Join Date: Mar 2013
Location: Germany
Old 10-20-2017 , 12:22   Re: A few errors.
Reply With Quote #9

Not sure what the point of bIsPlayerAlive is but seems like you're respawning already alive clients. (Which doesnt work?)

Shouldnt it be:
Code:
PlayerTeam[IGC] == TFTeam_Blue && !bIsPlayerAlive[IGC]
to get dead clients for respawn?

And
PHP Code:
if (!IsClientConnected(iClient)) 
      return 
else if    (
IsClientConnected(iClient)) 
      
TF2_RespawnPlayer(iClient); 
can be shortened to

PHP Code:
if (!IsClientConnected(iClient)) 
      return 
Plugin_Stop;

TF2_RespawnPlayer(iClient); 
Timocop is offline
Halt
Senior Member
Join Date: Jan 2015
Location: Black Mesa
Old 10-20-2017 , 13:21   Re: A few errors.
Reply With Quote #10

Quote:
Originally Posted by Timocop View Post
Not sure what the point of bIsPlayerAlive is but seems like you're respawning already alive clients. (Which doesnt work?)

Shouldnt it be:
Code:
PlayerTeam[IGC] == TFTeam_Blue && !bIsPlayerAlive[IGC]
to get dead clients for respawn?
No this is to select a zombie, the player must be alive IOT be selected by this block. I dont want dead players being selected.



Thanks man, appreciate pointing out the errors.

Last edited by Halt; 10-20-2017 at 13:23.
Halt is offline
Reply


Thread Tools
Display Modes

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 05:45.


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