Raised This Month: $32 Target: $400
 8% 

Counting players ingame (Left 4 Dead voting plugin inside)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wgooch
Member
Join Date: Dec 2008
Old 04-20-2009 , 18:03   Counting players ingame (Left 4 Dead voting plugin inside)
Reply With Quote #1

I'm writing a custom Left 4 Dead vote plugin and it's about 50% working now, but I'm still having trouble getting the game to decide how many votes to allow to be cast.

I can have it count the number of connected clients, but am stumped on how to get it to exclude bots or "fake clients" from being counted

Help would be appreciated

EDIT

Problem has been solved! I have released a beta for the votes in a post below!

Last edited by wgooch; 04-23-2009 at 22:51.
wgooch is offline
CrimsonGT
Veteran Member
Join Date: Oct 2007
Location: Gainesville, FL
Old 04-20-2009 , 18:14   Re: Counting players ingame
Reply With Quote #2

Do a for loop like for (new i=1;i<=MaxClients;i++) then inside of the for loop do if(IsFakeClient(i)) to find out if they are a bot or not.
__________________
CrimsonGT is offline
wgooch
Member
Join Date: Dec 2008
Old 04-20-2009 , 20:34   Re: Counting players ingame
Reply With Quote #3

So I would this inside of for?
Code:
if(IsFakeClient(i))
        {
        Bots=Bots+1
        }
wgooch is offline
Avitar
Junior Member
Join Date: Feb 2005
Old 04-20-2009 , 21:59   Re: Counting players ingame
Reply With Quote #4

Quote:
Originally Posted by wgooch View Post
So I would this inside of for?
Code:
if(IsFakeClient(i))
        {
        Bots=Bots+1
        }
Yes...kinda... something like:

Code:
new clients = 0;
for (new a = 1; a <= MaxClients; a++){
        if( !IsFakeClient(a) ){
                clients++;
        }
}
.. should give you the number of real clients that are connected.

fyi there are lots of rtv / vote plugins around with source code on the site that might help you coding =)
__________________
Programming Mantra: New errors indicate progress.
Avitar is offline
wgooch
Member
Join Date: Dec 2008
Old 04-23-2009 , 19:13   Re: Counting players ingame
Reply With Quote #5

I continue to get this message

Code:
L 04/23/2009 - 16:12:17: [SM] Native "IsFakeClient" reported: Client 5 is not connected
L 04/23/2009 - 16:12:17: [SM] Displaying call stack trace for plugin "l4dvotes.smx":
L 04/23/2009 - 16:12:17: [SM]   [0]  Line 17,
I'm wondering if a need a newer compiler?
wgooch is offline
msleeper
Veteran Member
Join Date: May 2008
Location: Atlanta, Jawjuh
Old 04-23-2009 , 19:18   Re: Counting players ingame
Reply With Quote #6

Try this.

PHP Code:
new clients 0;
for (new 
1<= maxplayersi++)
{
    if (
IsClientConnected(i) && IsClientInGame(i))
    {
        if (!
IsFakeClient(i))
            
clients++;
    }

__________________
msleeper is offline
wgooch
Member
Join Date: Dec 2008
Old 04-23-2009 , 19:23   Re: Counting players ingame
Reply With Quote #7

worked out great! Thanks
wgooch is offline
SirLamer
Senior Member
Join Date: Oct 2008
Old 04-23-2009 , 19:51   Re: Counting players ingame
Reply With Quote #8

msleeper's solution has redundant nesting.

Code:
new clients = 0; for (new i = 1; i <= maxplayers; i++) {     if (IsClientConnected(i) && IsClientInGame(i) && !IsFakeClient(i))     {         clients++;     } }

If part of a condition test fails early, the subsequent calculations will not be performed and are not at risk of failing if a preceding condition serves as a test to see if the subsequent tests will cause corruption or crashing.
__________________
Visit TEAM CHEESUS, a TF2 community with our own brand of injected shenanigans, for added flavor.

Plugins: Jukebox for Source
SirLamer is offline
msleeper
Veteran Member
Join Date: May 2008
Location: Atlanta, Jawjuh
Old 04-23-2009 , 19:53   Re: Counting players ingame
Reply With Quote #9

It wasn't redudant. In some cases you will get an error about IsFakeClient failing because they are not in-game.

EDIT
I saw your edit. I'm not sure what to tell you - I've seen it happen many times on my servers running L4D.
__________________
msleeper is offline
wgooch
Member
Join Date: Dec 2008
Old 04-23-2009 , 20:59   Re: Counting players ingame
Reply With Quote #10

Alright I got a working beta for voting, it's still in testing so expect bugs!
Feel free to examine the sp and give some hints to a new coder
Attached Files
File Type: sp Get Plugin or Get Source (sm_l4dvote.sp - 562 views - 3.7 KB)
wgooch 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 03:50.


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