Home » Renegade Discussions » Mod Release Forum » [SSGM 4.0 Plugin] TeamDonate Plugin
[SSGM 4.0 Plugin] TeamDonate Plugin [message #455775] |
Fri, 23 September 2011 16:44 |
iRANian
Messages: 4308 Registered: April 2011
Karma: 0
|
General (4 Stars) |
|
|
This plugin adds support for !teamdonate, !td and !tdonate (case insensitive). It's ported from the TeamDonate plugin that reborn made for ssgm 2.0.2. I've added the following changes:
1. Players running scripts 2.9.2 or higher get a green coloured message instead of an annoying PM.
2. The amount of credits that's shared per every member of the team can't be lower than 100.
3. You get a page telling you the amount of credit per team member that was donated to them.
4. The command that was typed in isn't displayed.
5. If you don't specify an amount of credits to donate, all of your credits are donated.
To install copy TeamDonate.dll to your FDS folder and add an entry for 'TeamDonate.dll' in the [Plugins] section of ssgm.ini.
Long time and well respected Renegade community member, programmer, modder and tester.
Scripts 4.0 private beta tester since May 2011.
My Renegade server plugins releases
[Updated on: Mon, 02 July 2012 06:40] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: [SSGM 4.0 Plugin] TeamDonate Plugin [message #472600 is a reply to message #455775] |
Wed, 01 August 2012 16:27 |
|
Distrbd21
Messages: 743 Registered: September 2008
Karma: 0
|
Colonel |
|
|
Quote: | If you don't specify an amount of credits to donate, all of your credits are donated.
|
What if I didn't mean to type that? 0_o, All my credits would be gone, and I myself as a player would be pissed if I didn't mean to type it, and it takes all my credits.!
Live Your Life Not Some one Else's.| Sharing Is Caring
Cookie Jar<glome> Who stole the cookie from the cookie jar?!
<content> glome stole the cookie from the cookie jar!
<glome> Who me?!
<content> Yes you!
<glome> Couldn't be!
<content> Then WHO?!!
<glome> Woody stole the cookie from the cookie jar!
*** glome has been kicked by DrWoody (fuck you i didn't touch the motherfucking cookie, bitch
Suicide<TB> I was depressed last night so I called the Suicide Life Line.
<TB> I reached a call center in Pakistan.
<TB> I told them I was suicidal.
<TB> They got all excited and asked if I could drive a truck
|
|
|
|
|
Re: [SSGM 4.0 Plugin] TeamDonate Plugin [message #472786 is a reply to message #472619] |
Sat, 04 August 2012 18:18 |
|
roszek
Messages: 296 Registered: June 2010
Karma: 0
|
Recruit |
|
|
I wanted to add a timer to your team donate (like the !donate) as it had none and I also wanted to change some other things.
It seems to work okay.
TeamDonate.h
Toggle Spoiler#pragma once
#include "gmplugin.h"
void __cdecl PPage(int ID, const char* rgb_colour, const char *Format, ...);
void Console(const char *Format, ...);
int Get_Team_Player_Count_Working(int Team);
TeamDonate.cpp
Toggle Spoiler#include "General.h"
#include "TeamDonate.h"
#include "engine_tt.h"
#include "engine_io.h"
#include "gmgame.h"
#define GREEN "104,234,40"
int ct;
void PPage(int ID, const char* rgb_colour, const char *Format, ...)
{
if(ID < 1 || ID > 128)
{
return;
}
if (!Get_GameObj(ID))
{
return;
}
char buffer[256];
va_list va;
_crt_va_start(va, Format);
vsnprintf(buffer, 256, Format, va);
va_end(va);
float Version = Get_Client_Version(ID);
if(Version < 2.9)
{
Console("ppage %d %s",ID, buffer);
return;
}
else
{
Console("cmsgp %d %s %s", ID, rgb_colour, buffer);
}
}
void Console(const char *Format, ...)
{
char buffer[256];
va_list va;
_crt_va_start(va, Format);
vsnprintf(buffer, 256, Format, va);
va_end(va);
Console_Input(buffer);
}
int Get_Team_Player_Count_Working(int Team)
{
int Total = 0;
for (SLNode<cPlayer>* PlayerIter = Get_Player_List()->Head(); (PlayerIter != NULL); PlayerIter = PlayerIter->Next())
{
cPlayer *p = PlayerIter->Data();
if (p->IsActive)
{
int ID = p->PlayerId;
if (Get_Team(ID) == Team)
{
Total++;
}
}
}
return Total;
}
class TeamDonate : public Plugin
{
public:
int WaitTime;
TeamDonate()
{
RegisterEvent(EVENT_CHAT_HOOK,this);
RegisterEvent(EVENT_GLOBAL_INI,this);
}
~TeamDonate()
{
UnregisterEvent(EVENT_CHAT_HOOK,this);
UnregisterEvent(EVENT_GLOBAL_INI,this);
}
virtual void OnLoadGlobalINISettings(INIClass *SSGMIni)
{
WaitTime = SSGMIni->Get_Int("TeamDonate", "WaitTime", 300);
}
virtual bool TeamDonate::OnChat(int PlayerID,TextMessageEnum Type,const wchar_t *Message,int recieverID)
{
if (Message[0] == L'!')
{
if ((wcsistr(Message,L"!teamdonate") == Message) || (wcsistr(Message,L"!tdonate") == Message)
|| (wcsistr(Message,L"!td") == Message))
{
char throwaway[64];
float Credits = 0;
int ret = swscanf(Message, L"%s %f", throwaway, &Credits);
if (ret == 1)
{
Credits = Get_Money(PlayerID);
}
ct = The_Game()->Get_Game_Duration_S();
if(ct>WaitTime)
{
if (Credits > 0)
{
float PlayerMoney = Get_Money(PlayerID);
if(PlayerMoney >= Credits)
{
int Team = Get_Team(PlayerID);
int Count = Get_Team_Player_Count_Working(Team);
if(Count > 1)
{
int DonateAmount = (int)Credits/(Count - 1);
for (SLNode<cPlayer>* PlayerIter = Get_Player_List()->Head(); (PlayerIter != NULL); PlayerIter = PlayerIter->Next())
{
cPlayer *p = PlayerIter->Data();
if (p->IsActive)
{
int ID = p->PlayerId;
if ((Get_Team(ID) == Team) && (ID != PlayerID))
{
Commands->Give_Money(Get_GameObj(ID),(float)DonateAmount,false);
PPage(ID, GREEN, "You have just been team donated %i credits by player %s.", DonateAmount, Get_Player_Name_By_ID(PlayerID));
}
}
}
Commands->Give_Money(Get_GameObj(PlayerID),(Credits * -1),false);
PPage(PlayerID, GREEN, "You have donated %i credits to every member of your team.", DonateAmount);
}
else
{
PPage(PlayerID, GREEN, "Sorry %s%, but you can't team-donate without a team!",Get_Player_Name_By_ID(PlayerID));
}
}
else
{
PPage(PlayerID,GREEN, "Sorry %s%, but you do not have %.0f credits%, please lower your donation amount.",Get_Player_Name_By_ID(PlayerID), Credits);
}
}
else
{
PPage(PlayerID,GREEN, "Sorry %s%, but you have entered an invalid amount%, please try again.",Get_Player_Name_By_ID(PlayerID));
}
}
else
{
PPage(PlayerID, GREEN, "Sorry %s%, but you need to wait another %i seconds before you can donate to your team.",Get_Player_Name_By_ID(PlayerID), WaitTime - ct + 1);
}
return false;
}
}
return true;
}
};
TeamDonate teamdonate;
extern "C" __declspec(dllexport) Plugin* Plugin_Init()
{
return &teamdonate;
}
ssgm.ini stuff
[TeamDonate]
; WaitTime=
;
; Number of seconds before players can team donate.
WaitTime=180
I've never messed with the ssgm plugins before and wouldn't mind some tips.
[Updated on: Wed, 15 August 2012 03:55] Report message to a moderator
|
|
|
Re: [SSGM 4.0 Plugin] TeamDonate Plugin [message #472807 is a reply to message #455775] |
Sun, 05 August 2012 00:41 |
iRANian
Messages: 4308 Registered: April 2011
Karma: 0
|
General (4 Stars) |
|
|
You need to move
Commands->Give_Money(Get_GameObj(PlayerID),(Credits * -1),false);
To directly above or under this line:
PPage(PlayerID, GREEN, "You have donated %i credits to every member of your team.", DonateAmount);
Else you still get the bug.
Long time and well respected Renegade community member, programmer, modder and tester.
Scripts 4.0 private beta tester since May 2011.
My Renegade server plugins releases
|
|
|
Re: [SSGM 4.0 Plugin] TeamDonate Plugin [message #472809 is a reply to message #472807] |
Sun, 05 August 2012 01:25 |
|
roszek
Messages: 296 Registered: June 2010
Karma: 0
|
Recruit |
|
|
iRANian wrote on Sun, 05 August 2012 00:41 | You need to move
Commands->Give_Money(Get_GameObj(PlayerID),(Credits * -1),false);
To directly above or under this line:
PPage(PlayerID, GREEN, "You have donated %i credits to every member of your team.", DonateAmount);
Else you still get the bug.
|
Done did it.
|
|
|
Goto Forum:
Current Time: Mon Nov 18 07:51:57 MST 2024
Total time taken to generate the page: 0.01317 seconds
|