Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/base/game.cc')
-rw-r--r--src/game/base/game.cc67
1 files changed, 63 insertions, 4 deletions
diff --git a/src/game/base/game.cc b/src/game/base/game.cc
index 19b3968..b426989 100644
--- a/src/game/base/game.cc
+++ b/src/game/base/game.cc
@@ -200,7 +200,7 @@ void Game::func_give(core::Player *player, const std::string &args)
std::string labelstr;
if (!player->control()) {
- player->send("^WNeed a ship to swap with!");
+ player->send("^WYou need to join the game first!");
return;
}
@@ -346,6 +346,11 @@ void Game::func_give(core::Player *player, const std::string &args)
// sell request from a player
void Game::func_sell(core::Player *player, const std::string &args)
{
+ if (!player->control()) {
+ player->send("^WYou need to join the game first!");
+ return;
+ }
+
std::istringstream is(args);
std::string typestr;
std::string labelstr;
@@ -384,6 +389,11 @@ void Game::func_sell(core::Player *player, const std::string &args)
// buy request from a player
void Game::func_buy(core::Player *player, const std::string &args)
{
+ if (!player->control()) {
+ player->send("^WYou need to join the game first!");
+ return;
+ }
+
std::istringstream is(args);
std::string typestr;
std::string labelstr;
@@ -426,11 +436,55 @@ void Game::func_buy(core::Player *player, const std::string &args)
return;
}
+// eject cargo request
+void Game::func_eject(core::Player *player, const std::string &args)
+{
+ if (!player->control()) {
+ player->send("^WYou need to join the game first!");
+ return;
+ }
+
+ std::istringstream is(args);
+ std::string typestr;
+ std::string labelstr;
+
+ if (!(is >> typestr)) {
+ player->send("Usage: eject [string] [string] [int] eject an item: specify type, label and amount");
+ return;
+ } else {
+ aux::to_label(typestr);
+ }
+
+ if (!(is >> labelstr)) {
+ player->send("Usage: eject [string] [string] [int] eject an item: specify type, label and amount");
+ return;
+ } else {
+ aux::to_label(labelstr);
+ }
+
+ int amount = 0;
+ if (!(is >> amount))
+ amount = 0;
+
+ if (typestr.compare("cargo") == 0) {
+ Cargo *cargo = Cargo::find(labelstr);
+ if (cargo) {
+ cargo->eject(player->control(), amount);
+ } else {
+ player->send("Unkown cargo type '" + labelstr + "'");
+ }
+ } else {
+ player->send("Unkown item type '" + typestr + "'");
+ }
+}
+
// launch request
void Game::func_launch(core::Player *player, std::string const &args)
{
- if (!player->control())
+ if (!player->control()) {
+ player->send("^WYou need to join the game first!");
return;
+ }
if (!player->view())
return;
@@ -494,8 +548,10 @@ void Game::func_launch(core::Player *player, std::string const &args)
// respawn
void Game::func_respawn(core::Player *player, std::string const &args)
{
- if (!player->control())
+ if (!player->control()) {
+ func_join(player, args);
return;
+ }
if (!(player->view() == player->control()))
return;
@@ -606,7 +662,10 @@ Game::Game() : core::Module("Project::OSiRiON", true)
func = core::Func::add("sell", Game::func_sell);
func->set_info("[string] [string] [int] sell an item: specify type, label and amount");
-
+
+ func = core::Func::add("eject", Game::func_eject);
+ func->set_info("[string] [string] [int] eject an item from inventory: specify type, label and amount");
+
func = core::Func::add("give", Game::func_give);
func->set_info("cheat functions");