Log in

View Full Version : vaultmp christmas / new years eve script



foxtacles
12-23-2012, 04:04 PM
The script I wrote for https://www.vaultmp.com/showthread.php?1569-vaultmp-christmas-new-years-eve-screenshot

Has some commands:

/anim [ID]
/goto [ID]
/players
/age
/young
/sex
/bimbo
/mutant
/safe

#include "vaultscript.h"
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cstdlib>

using namespace vaultmp;

IDHash<UCount> cons;

Void VAULTSCRIPT exec() noexcept
{
std::printf("vaultmp christmas / new years eve meetup\n");
SetServerName("vaultmp christmas / new years eve meetup");
SetServerRule("website", "vaultmp.com");

switch (GetGameCode())
{
case Index::FALLOUT3:
SetServerMap("the wasteland");
break;

case Index::NEWVEGAS:
SetServerMap("mojave desert");
break;

default:
break;
}
}

Base VAULTSCRIPT OnPlayerRequestGame(ID player) noexcept
{
Player(player)
<< "Welcome to vaultmp christmas / new years eve meetup!"
<< "The goal is to create some footage for the public."
<< "Gather with other players and take screenshots / video,"
<< "and post it on the website: www.vaultmp.com"
<< "For this purpose, some animation commands are available:"
<< "type \"/anim 0\" \"/anim 1\" \"/anim 2\" etc."
<< "other commands: /players /goto [ID] /age /young /sex /bimbo /mutant /safe"
<< " $red merry christmas and a happy new year!";

cons[player] = GetConnection(player);

SetPos(player, -15444.0, 15454.0, 12007.0);

return static_cast<Base>(0x00000000);
}

Void VAULTSCRIPT OnPlayerDisconnect(ID player, Reason) noexcept
{
cons.erase(player);
}

State VAULTSCRIPT OnPlayerChat(ID player, RawString message) noexcept
{
if (*message == '/')
{
std::vector<String> tokens;
RawString cmd = std::strtok(message + 1, " ");

while (cmd)
{
tokens.emplace_back(cmd);
cmd = std::strtok(nullptr, " ");
}

if (!tokens.empty())
{
// Player object
Player pplayer(player);

if (!tokens[0].compare("anim"))
{
static std::vector<unsigned int> anims {
562248, // LooseWaveHello
550036, // DukovDrinkStand01
537880, // LooseSmokingStanding
15338, // BeerDrinkingStanding
365632, // LooseBDayCheerA
212187, // LooseCheeringOneArmUp
212188, // LooseCheeringBothArmsUp
84935, // HitBrain
};

if (tokens.size() > 1)
{
unsigned int idx = std::strtoul(tokens[1].c_str(), nullptr, 10);

if (idx < anims.size())
pplayer.PlayIdle(static_cast<Base>(anims[idx]));
}
}
else if (!tokens[0].compare("goto"))
{
if (tokens.size() > 1)
{
UCount idx = std::strtoul(tokens[1].c_str(), nullptr, 10);
auto it = std::find_if(cons.begin(), cons.end(), [idx](const std::pair<const ID, UCount>& player) { return player.second == idx; });

if (it != cons.end())
{
Player pplayer2(it->first);
Value X, Y, Z;
pplayer2.GetPos(X, Y, Z);
pplayer.SetCell(pplayer2.GetCell(), X, Y, Z);
}
else
pplayer << "Player not found!";
}
}
else if (!tokens[0].compare("players"))
{
IDVector players = Player::GetList();

for (const auto& ID : players)
{
char num[4];
std::snprintf(num, sizeof(num), "%d", GetConnection(ID));
pplayer << "(" + String(num) + ") " + GetName(ID);
}
}
else if (!tokens[0].compare("age"))
pplayer.AgeActorBaseRace(1);
else if (!tokens[0].compare("young"))
pplayer.AgeActorBaseRace(-1);
else if (!tokens[0].compare("sex"))
pplayer.SetActorBaseSex(!pplayer.GetActorBaseSex() );
else if (!tokens[0].compare("bimbo"))
{
static Base talon_merc = static_cast<Base>(0x0007E948);
static Index health = static_cast<Index>(0x10);

Actor actor(Actor::Create(talon_merc, player));
actor.SetActorBaseValue(health, 100.0);
actor.SetActorValue(health, 100.0);
}
else if (!tokens[0].compare("mutant"))
{
static Base mutant = static_cast<Base>(0x0001CF95);
static Index health = static_cast<Index>(0x10);

Actor actor(Actor::Create(mutant, player));
actor.SetActorBaseValue(health, 100.0);
actor.SetActorValue(health, 100.0);
}
else if (!tokens[0].compare("safe"))
{
static Base safe = static_cast<Base>(0x000533CE);
Container::Create(safe, player);
}
else
pplayer << String("Unrecognized command: " + tokens[0]);
}

return False;
}
else
{
String msg = GetName(player) + ": " + message;
std::strncpy(message, msg.c_str(), static_cast<size_t>(Index::MAX_CHAT_LENGTH));
}

return True;
}

Void VAULTSCRIPT OnSpawn(ID object) noexcept
{
Player player(object);

if (player)
player.UIMessage("Hello, " + player.GetName() + "!");
}

Result VAULTSCRIPT RemoveActor(ID actor)
{
DestroyObject(actor);
KillTimer();
return static_cast<Result>(0);
}

Void VAULTSCRIPT OnActorDeath(ID actor, Limb limbs, Death cause) noexcept
{
if (GetType(actor) != Type::ID_PLAYER)
CreateTimerEx(RemoveActor, static_cast<Interval>(8000), actor);
}


# vaultserver configuration file
# www.vaultmp.com

[general]
game=fallout3 ;can be "fallout3" or "newvegas"
master=127.0.0.1 ;master server address, default is: vaultmp.com (can have the format IP:port)
port=1770 ;the port to run the server on, default is: 1770 (UDP for game, TCP for fileserve)
query=1 ;enable direct query, default is: 1
players=16 ;number of player slots, default is: 4
spawn=0x0000146B ;default spawn cell
fileserve=1 ;allow users to download required files (such as mods) from the server, default is: 0
fileslots=8 ;maximum number of parallel fileserve connnections, default is: 8

[scripts]
;comma seperated list of PAWN / C++ scripts, will be loaded in the given order
;scripts need to be located in the root
scripts=vaultscript.so

[mods]
;comma seperated list of mod files required to play on this server
;mods need to be located in the folder "mods", which is the games "Data" folder clientside
;mods will be loaded in the given order
mods=bondsxmas.esp,\
meshes/AACH/jrChristmasPkg01.nif,\
meshes/AACH/jrChristmasPkg02.nif,\
meshes/AACH/jrchristmaspkg06.nif,\
meshes/AACH/jrChristmaspkg09.nif,\
meshes/AACH/jrChristmaspkg11.nif,\
meshes/jr/Art/drinkingglass01.nif,\
meshes/jr/Art/jrRattanBasket.nif,\
meshes/jr/Art/jrrattanbasket01.nif,\
meshes/jr/Misc/jrmotorcycleNeonBlue01.nif,\
meshes/jr/Xmas/jrFestivePlate02.nif,\
meshes/jr/Xmas/jrFestiveMug01.nif,\
textures/aach/christmaspkg01.dds,\
textures/aach/christmaspkg02.dds,\
textures/aach/christmaspkg03.dds,\
textures/aach/christmaspkg04.dds,\
textures/jr/art/p/jrfestivemug01.dds,\
textures/jr/art/p/jrfestivemug01_n.dds,\
textures/jr/art/p/jrfestiveplate02.dds,\
textures/jr/art/jrgreenglass.dds,\
textures/jr/art/rattan.pl.dds,\
textures/jr/misc/jrmotorcycle02.dds,\
textures/jrtent/art/aajrplanter02_n.dds


Using this mod: https://fallout3.nexusmods.com/mods/10393

foxtacles
12-26-2012, 05:01 PM
Added commands to spawn NPC / mutant / safe (gary 2.5)

foxtacles
01-01-2013, 01:38 PM
First reason why to create a timer to depop objects or to limit creation in the first place:

https://i.imgur.com/cCeTa.jpg

Silentfood
01-01-2013, 08:27 PM
Would this be doable in pawn, as in are these functions already binded in?

foxtacles
01-01-2013, 08:42 PM
This is doable in PAWN. All functions are available in PAWN.

StarshipGhost
01-02-2013, 04:18 PM
I noticed all those safes yesterday and didn't understand why they were there at first, then I spawned a mutant and realized someone did that. maybe the safes is why i crashed a few times. I haven't been able to connect to the server since to do more testing but I will as soon as it's connectable for me.