Home » Renegade Discussions » Mod Release Forum » [Code]Custom PPAGE
[Code]Custom PPAGE [message #449210] |
Tue, 28 June 2011 14:05 ![Go to next message Go to next message](/theme/Renegade_Forums/images/down.png) |
iRANian
Messages: 4307 Registered: April 2011
Karma: 0
|
General (4 Stars) |
|
|
This function will sent custom a specified message (with specified custom colours) and a specified sound that emulates PPAGE, if the player who is being paged doesn't have scripts 2.9 or later installed, it will fallback to using PPAGE. There's also a convenience function with the same name that takes less arguments and has defaults for the custom sound and message colour.
This is about the same code as the ones used in YaRR & OnOeS and it's based off that so credits go to their author(s).
.cpp:
Toggle Spoiler
#include "stdlib.h"
#include "stdarg.h"
#include "stdio.h"
#include YOUR_CORRESPONDING_HEADER_FILE
#include "scripts.h"
#include "engine.h"
float BHS_Versions[128];
void PPage(int ID, bool use_sound, const char* soundname, const char* rgb_colour, const char *Format, ...)
{
if(ID < 1)
{
return;
}
char buffer[256];
va_list va;
_crt_va_start(va, Format);
vsnprintf(buffer, 256, Format, va);
va_end(va);
if (!Get_GameObj(ID))
{
return;
}
if(BHS_Versions[ID] < 2.9)
{
Console("ppage %d %s",ID, buffer);
return;
}
else
{
Console("cmsgp %d %s Host (to %s): %s", ID, rgb_colour, Get_Player_Name_By_ID(ID), buffer);
}
if (use_sound) //m01evag_dsgn0193a1evag_snd.wav, //Unknown command, please re-iterate
Console("sndp %d %s", ID, soundname);
}
//Workaround for variable arguments
void PPage(int ID, const char* message, char* soundname, char* rgb_colour )
{
PPage(ID, true, soundname, rgb_colour, message);
}
void VersionHook(int PlayerID,float Version)
{
BHS_Versions[PlayerID] = Version;
}
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);
}
.h:
Toggle Spoilervoid __cdecl PPage(int ID, bool use_sound, const char* soundname, const char* rgb_colour, const char *Format, ...);
void PPage(int ID, const char* message, char* soundname = "paging_caution_2.wav", char* rgb_colour = "255,128,64" );
void Console(const char *Format, ...);
void VersionHook(int PlayerID,float Version);
And then in your start-up code, add the version hook somewhere, e.g.:
void Plugin_Load() {
...
AddVersionHook(VersionHook);
...
}
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: Sat, 06 August 2011 10:49] Report message to a moderator
|
|
|
Re: [Code]Custom PPAGE [message #449212 is a reply to message #449210] |
Tue, 28 June 2011 14:39 ![Go to previous message Go to previous message](/theme/Renegade_Forums/images/up.png) ![Go to next message Go to next message](/theme/Renegade_Forums/images/down.png) |
![](http://renegadeforums.com/images/custom_avatars/25625.png) |
sla.ro(master)
Messages: 610 Registered: September 2010 Location: Romania
Karma: 0
|
Colonel |
|
|
i use this PPage function on Lua but similar codded, it creates a table where stores info about player's scripts versions and checks if player has scripts when the function is called and does the action. nice to see it and on C++
edit: based on YARR? my script is based on YALB (who is similar to YARR)
Creator of Mutant Co-Op
Developer of LuaTT
[Updated on: Tue, 28 June 2011 14:41] Report message to a moderator
|
|
|
|
|
Re: [Code]Custom PPAGE [message #449246 is a reply to message #449210] |
Wed, 29 June 2011 12:31 ![Go to previous message Go to previous message](/theme/Renegade_Forums/images/up.png) |
iRANian
Messages: 4307 Registered: April 2011
Karma: 0
|
General (4 Stars) |
|
|
It's a pity SSGM doesn't use it, though. :/ It's really annoying to get paged with the dark blue message and the paging sound when it's just random bot/regulator stuff like getting a vehicle bound to you.
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
|
|
|
Goto Forum:
Current Time: Sat Aug 17 09:13:18 MST 2024
Total time taken to generate the page: 0.00598 seconds
|