Home » Renegade Discussions » Mod Release Forum » [Code]Custom PPAGE
[Code]Custom PPAGE [message #449210] |
Tue, 28 June 2011 14:05 |
iRANian
Messages: 4308 Registered: April 2011
Karma:
|
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
|
|
|
Goto Forum:
Current Time: Wed Dec 04 20:57:38 MST 2024
Total time taken to generate the page: 0.00682 seconds
|