AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   A few errors. (https://forums.alliedmods.net/showthread.php?t=302147)

Halt 10-18-2017 11:25

A few errors.
 
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");



cigzag 10-18-2017 20:41

Re: A few errors.
 
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

Powerlord 10-18-2017 21:35

Re: A few errors.
 
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.

Halt 10-18-2017 22:44

Re: A few errors.
 
Quote:

Originally Posted by Powerlord (Post 2555324)
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.

hmmmmm 10-18-2017 22:54

Re: A few errors.
 
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.

Halt 10-19-2017 01:03

Re: A few errors.
 
-_-

int Client)

any Client.

hmmmmm 10-19-2017 01:20

Re: A few errors.
 
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)

Halt 10-19-2017 13:05

Re: A few errors.
 
Quote:

Originally Posted by hmmmmm (Post 2555348)
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.

Timocop 10-20-2017 12:22

Re: A few errors.
 
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); 


Halt 10-20-2017 13:21

Re: A few errors.
 
Quote:

Originally Posted by Timocop (Post 2555612)
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.


All times are GMT -4. The time now is 00:34.

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