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

L4D2: How to detect a passed vote to restart campaign?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
NgBUCKWANGS
Senior Member
Join Date: Dec 2014
Old 10-04-2016 , 14:17   L4D2: How to detect a passed vote to restart campaign?
Reply With Quote #1

A friend laid out the foundation to a pretty nice plugin and I've been hacking at it and got it to a point I'd like to release it on here. There's still many things I'd like to do with it but at the moment there is what I consider a show stopping bug that occurs when a vote to restart (passing) happens.

Basically, I'm tracking some information in which a vote to restart will always pollute making that captured information unreliable. I pretty much have everything nailed to get this started but that damn campaign restart I can't figure out.

I'm beyond new to SourcePawn with my only background being in Python and Bash. I'm really hacking at it though and fixed it up nicely, I really need some help. I'd appreciate an example if you have the time or anything you think will help.

Thanks!
NgBUCKWANGS is offline
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 10-04-2016 , 17:23   Re: L4D2: How to detect a passed vote to restart campaign?
Reply With Quote #2

You have provided no explanation of what the plugin is about. You would have a much better luck, if you provide more details, as opposed making a shot in the dark.
__________________
Spirit_12 is offline
Skyy
AlliedModders Donor
Join Date: Jan 2010
Location: Toronto, Canada
Old 10-05-2016 , 02:15   Re: L4D2: How to detect a passed vote to restart campaign?
Reply With Quote #3

Please provide additional info so the gods of l4d2 plugin development may be of assistance.
Skyy is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 10-05-2016 , 08:11   Re: L4D2: How to detect a passed vote to restart campaign?
Reply With Quote #4

L4D2 uses UserMessages to tell clients when votes start and end.

if you want to catch when a Restart vote passes:

PHP Code:
#define L4D_VOTE_RESTART_PASSED                "#L4D_vote_passed_restart_game"

public void OnPluginStart()
{
    
// other startup stuff here

    
HookUserMessage(GetUserMessageId("VotePass"), Msg_VotePassed);
}

public 
Action Msg_VotePassed(UserMsg msg_idBfRead msg, const int[] playersint playersNumbool reliablebool init)
{
    
char title[255];
    
char details[255];

    
int team msg.ReadByte();
    
msg.ReadString(titlesizeof(title));
    
msg.ReadString(detailssizeof(details));

    if (
StrEqual(titleL4D_VOTE_RESTART_PASSED))
    {
        
// Your logic for if a restart vote passed here
    
}

Note: I haven't tested this, even to see if it compiles.

Note 2: This will definitely not work on any other game, including L4D1.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 10-05-2016 at 08:15.
Powerlord is offline
NgBUCKWANGS
Senior Member
Join Date: Dec 2014
Old 10-05-2016 , 10:13   Re: L4D2: How to detect a passed vote to restart campaign?
Reply With Quote #5

Fellas, I did intend on releasing the plugin and just did so here https://forums.alliedmods.net/showth...52#post2459352 I didn't think explaining the idea was important and figured I'd ask what I needed which is how to check if the campaign restarted. The source and plugin are at the link if you'd like to look them over.

I thank you all for your time spent here. Powerlord, thanks for that code, it's a better starting point than where I was. It's appreciated!
NgBUCKWANGS is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 10-05-2016 , 21:42   Re: L4D2: How to detect a passed vote to restart campaign?
Reply With Quote #6

Quote:
Originally Posted by NgBUCKWANGS View Post
Fellas, I did intend on releasing the plugin and just did so here https://forums.alliedmods.net/showth...52#post2459352 I didn't think explaining the idea was important and figured I'd ask what I needed which is how to check if the campaign restarted. The source and plugin are at the link if you'd like to look them over.

I thank you all for your time spent here. Powerlord, thanks for that code, it's a better starting point than where I was. It's appreciated!
I should note that this was new-style syntax. It'd look slightly different in old-style syntax.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 01-08-2018 , 23:15   Re: L4D2: How to detect a passed vote to restart campaign?
Reply With Quote #7

That method didn't really work for me. You got any other suggestions?
__________________
Spirit_12 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:39.


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