Day 1 of the week of plug-ins:
Summary:
Players self-capping their own flags works alright on HTF maps, but however this does not work well on any other map.
So what this plug-in does is prevent players from capping their own flag.
License: LGPL 2.1
Link to plug-in: NoSelfCaptures
-Zehra
NoSelfCaptures
- Zehra
- Private First Class
- Posts: 915
- Joined: Sun Oct 18, 2015 3:36 pm
- Location: Within the BZFS API and Beyond it
- Contact:
NoSelfCaptures
Those who are critical of me, I'll likely be the same of them. ~Zehra
The decisions we make are the ones we look forward too and the ones we regret. ~Zehra
There's a difference between knowing my name and knowing me, one shows respect to my name and the other is to who I am. ~Zehra
See where I've last been active at Strayers.
Visit BZList.net for a modern HTML5 server stats site.
Click here to view the 101 Leaderboard & Score Summaries Last updated 2021-01-12 (YYYY-MM-DD)
Latest 101 thread
The decisions we make are the ones we look forward too and the ones we regret. ~Zehra
There's a difference between knowing my name and knowing me, one shows respect to my name and the other is to who I am. ~Zehra
See where I've last been active at Strayers.
Visit BZList.net for a modern HTML5 server stats site.
Click here to view the 101 Leaderboard & Score Summaries Last updated 2021-01-12 (YYYY-MM-DD)
Latest 101 thread
Re: NoSelfCaptures
If (bz_getPlayerTeam(capData->playerCapping) == capData->teamCapped)
{
capData->allow = false;
}
else capData->allow = true;
You should be consistent in how you handle single line conditionals.
Also learn about assignment.
{
capData->allow = false;
}
else capData->allow = true;
You should be consistent in how you handle single line conditionals.
Also learn about assignment.
JeffM
Re: NoSelfCaptures
There is no need to get the capping player's team because it's already part of the event data, stored as teamCapping.
capData->allow = (capData->teamCapping != capData->teamCapped);
(That will set the 'allow' value to the boolean result of the inequality comparison of teamCapping and teamCapped)
capData->allow = (capData->teamCapping != capData->teamCapped);
(That will set the 'allow' value to the boolean result of the inequality comparison of teamCapping and teamCapped)
Re: NoSelfCaptures
A few more things;
Does this even run? You have your plugin members not marked as public, so they'll be private by default, you have an empty public section at the bottom.
You should put the license and copyright information in the file so it's clear what the license is. How do people who find the code on github know if they don't also somehow magically find this forum post. You also need to actually state the copyright holder's name.
Plugins like this should be exceptionaly short and simple.
Does this even run? You have your plugin members not marked as public, so they'll be private by default, you have an empty public section at the bottom.
You should put the license and copyright information in the file so it's clear what the license is. How do people who find the code on github know if they don't also somehow magically find this forum post. You also need to actually state the copyright holder's name.
Plugins like this should be exceptionaly short and simple.
Code: Select all
/* NoSelfCaptures
* This plug-in prevents self-captures in CTF maps.
* Copyright (c) 2018 ???????
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the LGPL 2.1 license.
* https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
*
* THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#include "bzfsAPI.h"
class NoSelfCaptures : public bz_Plugin
{
public:
virtual const char* Name()
{
return "NoSelfCaptures";
}
virtual void Init(const char* /*config*/)
{
Register(bz_eAllowCTFCaptureEvent);
}
virtual void Event(bz_EventData *eventData)
{
if (eventData->eventType == bz_eAllowCTFCaptureEvent)
{
bz_AllowCTFCaptureEventData_V1 *capData = (bz_AllowCTFCaptureEventData_V1*)eventData;
capData->allow = capData->teamCapped != capData->teamCapping;
}
}
virtual void Cleanup(void)
{
Flush();
}
};
// Local Variables: ***
// mode: C++ ***
// tab-width: 4 ***
// c-basic-offset: 4 ***
// indent-tabs-mode: nil ***
// End: ***
// ex: shiftwidth=4 tabstop=4
JeffM
- Zehra
- Private First Class
- Posts: 915
- Joined: Sun Oct 18, 2015 3:36 pm
- Location: Within the BZFS API and Beyond it
- Contact:
Re: NoSelfCaptures
@JeffM
Thanks for the input, it looks like I didn't make it exactly right.
Seems like I remembered my badly written code, compare to standards.
(I'll take a few notes on conditionals and assignments.)
@blast
I tried to do something like this, but it didn't work as intended.(Or I might have messed up somewhere else.)
@JeffM
I made a localhost test after compiling the plug-in.
(It was possible to capture other teams flags, but not do self-caps.)
I didn't really think of adding the licenses in each plug-in, since I mostly intended them to be downloaded as a single release.
I had this for license information: Plug-in Licenses.
I'm not experienced with copyright matters, I thought simply adding a license was enough. (Sample is released into public domain.)
I'll see about making the plug-ins simple and short, as I haven't really seen examples of them.
-Zehra
Thanks for the input, it looks like I didn't make it exactly right.
Seems like I remembered my badly written code, compare to standards.
(I'll take a few notes on conditionals and assignments.)
@blast
I tried to do something like this, but it didn't work as intended.(Or I might have messed up somewhere else.)
Code: Select all
bz_AllowCTFCaptureEventData_V1 *capData = (bz_AllowCTFCaptureEventData_V1*)eventData;
if (capData->teamCapping == capData->teamCapped)
{
capData->allow = false;
}
else capData->allow = true;
I didn't know the solution could be so simple and elegant.blast wrote: ↑Sun Jul 01, 2018 4:21 pm There is no need to get the capping player's team because it's already part of the event data, stored as teamCapping.
capData->allow = (capData->teamCapping != capData->teamCapped);
(That will set the 'allow' value to the boolean result of the inequality comparison of teamCapping and teamCapped)
@JeffM
I made a localhost test after compiling the plug-in.
(It was possible to capture other teams flags, but not do self-caps.)
I didn't really think of adding the licenses in each plug-in, since I mostly intended them to be downloaded as a single release.
I had this for license information: Plug-in Licenses.
I'm not experienced with copyright matters, I thought simply adding a license was enough. (Sample is released into public domain.)
I'll see about making the plug-ins simple and short, as I haven't really seen examples of them.
-Zehra
Those who are critical of me, I'll likely be the same of them. ~Zehra
The decisions we make are the ones we look forward too and the ones we regret. ~Zehra
There's a difference between knowing my name and knowing me, one shows respect to my name and the other is to who I am. ~Zehra
See where I've last been active at Strayers.
Visit BZList.net for a modern HTML5 server stats site.
Click here to view the 101 Leaderboard & Score Summaries Last updated 2021-01-12 (YYYY-MM-DD)
Latest 101 thread
The decisions we make are the ones we look forward too and the ones we regret. ~Zehra
There's a difference between knowing my name and knowing me, one shows respect to my name and the other is to who I am. ~Zehra
See where I've last been active at Strayers.
Visit BZList.net for a modern HTML5 server stats site.
Click here to view the 101 Leaderboard & Score Summaries Last updated 2021-01-12 (YYYY-MM-DD)
Latest 101 thread
Re: NoSelfCaptures
Yeah you did, we went over this in irc. You keep saying you will learn the basics of c, but you never do.
As for copyright, you need to provide a copyright notice, usuallyt with your real name, and the license, with the work.
Last edited by JeffM on Sun Jul 01, 2018 10:09 pm, edited 1 time in total.
JeffM
- Zehra
- Private First Class
- Posts: 915
- Joined: Sun Oct 18, 2015 3:36 pm
- Location: Within the BZFS API and Beyond it
- Contact:
Re: NoSelfCaptures
Okay, will look into this a bit more.
Edit: Plug-in now has license info in header.
-Zehra
Edit: Plug-in now has license info in header.
-Zehra
Those who are critical of me, I'll likely be the same of them. ~Zehra
The decisions we make are the ones we look forward too and the ones we regret. ~Zehra
There's a difference between knowing my name and knowing me, one shows respect to my name and the other is to who I am. ~Zehra
See where I've last been active at Strayers.
Visit BZList.net for a modern HTML5 server stats site.
Click here to view the 101 Leaderboard & Score Summaries Last updated 2021-01-12 (YYYY-MM-DD)
Latest 101 thread
The decisions we make are the ones we look forward too and the ones we regret. ~Zehra
There's a difference between knowing my name and knowing me, one shows respect to my name and the other is to who I am. ~Zehra
See where I've last been active at Strayers.
Visit BZList.net for a modern HTML5 server stats site.
Click here to view the 101 Leaderboard & Score Summaries Last updated 2021-01-12 (YYYY-MM-DD)
Latest 101 thread