• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua [CTRL + R] Is it possible?

Guitar Freak

_LüA_n☺b_
Joined
Dec 27, 2008
Messages
831
Reaction score
13
Location
Caracas, Venezuela
[CTRL + R] Is it possible? EDIT: 3 months and still NOT SOLVED.. any pr0s around?

Hello everyone, first of all, Im using TFS 0.3.2 (+ 8.4 client).

This time Im wondering if its possible to make a script so when people make reports in-game using CTRL + R, it creates a .txt file (or any extension if it is more convenient) on my server's folder called like "reports.txt" and then every subsequent report made in-game would appear there separated by commas, spaces, lines, numbers or whatever if possible.

(Like the file "Players Record.txt" that gets modified automatically when a player record is made in the server)

Or better yet, Id make a folder called like "Reports" and everytime someone makes a report it creates a file with the person's name or maybe the date of the report? Something like "Report 21/6/2009 15;03pm - Guitar Freak.txt" and it makes different .txts for every different report.

So, is this possible? If so, any tips on how to do this? Or does anyone have it and willing to share it? {Of course Ill + Rep}

Again, it would be for TFS 0.3.2.

Thanks in advance.
Guitar Freak~
 
Last edited:
Yes, with sourceedit:
in game.cpp search for
Code:
bool Game::playerReportBug(uint32_t playerId, std::string bug)
{
	Player* player = getPlayerByID(playerId);
	if(!player || player->isRemoved())
		return false;

	Database* db = Database::getInstance();

	DBQuery query;
	query << "INSERT INTO `server_reports` (`id`, `world_id`, `player_id`, `posx`, `posy`, `posz`, `timestamp`, `report`) VALUES (NULL, ";
	query << g_config.getNumber(ConfigManager::WORLD_ID) << ", " << player->getGUID() << ", ";
	Position pos = player->getPosition();
	query << pos.x << ", " << pos.y << ", " << pos.z << ", ";
	query << time(NULL) << ", " << db->escapeString(bug.c_str()) << ");";
	if(!db->executeQuery(query.str()))
	{
		query.str("");
		return false;
	}

	query.str("");
	player->sendTextMessage(MSG_EVENT_DEFAULT, "Your report has been sent to " + g_config.getString(ConfigManager::SERVER_NAME) + ".");
	return true;
}

and replace the function with this:
Code:
bool Game::playerReportBug(uint32_t playerId, std::string bug)
{
	Player* player = getPlayerByID(playerId);
	if(!player || player->isRemoved())
		return false;
		
	//Create report file
	if(FILE* file = fopen("player_reports.txt", "a"))
        {
   	    char bufferDate[32];
            uint64_t tmp = time(NULL);
            formatDate(tmp, bufferDate);
            fprintf(file, "%s Report by %s: %s\n\n", bufferDate, player->getName().c_str(), bug.c_str());
            fclose(file);
        }

	Database* db = Database::getInstance();

	DBQuery query;
	query << "INSERT INTO `server_reports` (`id`, `world_id`, `player_id`, `posx`, `posy`, `posz`, `timestamp`, `report`) VALUES (NULL, ";
	query << g_config.getNumber(ConfigManager::WORLD_ID) << ", " << player->getGUID() << ", ";
	Position pos = player->getPosition();
	query << pos.x << ", " << pos.y << ", " << pos.z << ", ";
	query << time(NULL) << ", " << db->escapeString(bug.c_str()) << ");";
	if(!db->executeQuery(query.str()))
	{
		query.str("");
		return false;
	}

	query.str("");
	player->sendTextMessage(MSG_EVENT_DEFAULT, "Your report has been sent to " + g_config.getString(ConfigManager::SERVER_NAME) + ".");
	return true;
}

Not Testet!!!
Please try and tell me if it works...

Yours,
Markey
 
yeah dude dont worry bout it, its already scripted in 3.5 Release date is set for the 30th (5days from now)

CREATURE EVENT:
onReportBug(cid, comment)

LUA:
function onReportBug(cid, comment)
	local pos = getCreaturePosition(cid)
	if(db.executeQuery("INSERT INTO `server_reports` (`id`, `world_id`, `player_id`, `posx`, `posy`, `posz`, `timestamp`, `report`) VALUES (NULL, " ..
		getConfigValue('worldId') .. ", " .. getPlayerGUID(cid) .. ", " ..
		pos.x .. ", " .. pos.y .. ", " .. pos.z .. ", " ..
		os.time() .. ", " .. db.escapeString(comment) .. ")"))
	then
		doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Your report has been sent to " .. getConfigValue('serverName') .. ".")
	else
		doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, getConfigValue('serverName') .. " couldn't save your report, please contact with gamemaster.")
	end

	return true
end

You can edit that to work with it while you wait, (am I allowed to release that? Its not the server just a unsuable script unless people have it)
 
You published donator's only content :P You'll be hunted !
Rule violations channel is logged by default in /logs if you enable loggin in config.lua
Visit /XML/channels.xml
 
Yes, with sourceedit:
in game.cpp search for
Code:
bool Game::playerReportBug(uint32_t playerId, std::string bug)
{
	Player* player = getPlayerByID(playerId);
	if(!player || player->isRemoved())
		return false;

	Database* db = Database::getInstance();

	DBQuery query;
	query << "INSERT INTO `server_reports` (`id`, `world_id`, `player_id`, `posx`, `posy`, `posz`, `timestamp`, `report`) VALUES (NULL, ";
	query << g_config.getNumber(ConfigManager::WORLD_ID) << ", " << player->getGUID() << ", ";
	Position pos = player->getPosition();
	query << pos.x << ", " << pos.y << ", " << pos.z << ", ";
	query << time(NULL) << ", " << db->escapeString(bug.c_str()) << ");";
	if(!db->executeQuery(query.str()))
	{
		query.str("");
		return false;
	}

	query.str("");
	player->sendTextMessage(MSG_EVENT_DEFAULT, "Your report has been sent to " + g_config.getString(ConfigManager::SERVER_NAME) + ".");
	return true;
}

and replace the function with this:
Code:
bool Game::playerReportBug(uint32_t playerId, std::string bug)
{
	Player* player = getPlayerByID(playerId);
	if(!player || player->isRemoved())
		return false;
		
	//Create report file
	if(FILE* file = fopen("player_reports.txt", "a"))
        {
   	    char bufferDate[32];
            uint64_t tmp = time(NULL);
            formatDate(tmp, bufferDate);
            fprintf(file, "%s Report by %s: %s\n\n", bufferDate, player->getName().c_str(), bug.c_str());
            fclose(file);
        }

	Database* db = Database::getInstance();

	DBQuery query;
	query << "INSERT INTO `server_reports` (`id`, `world_id`, `player_id`, `posx`, `posy`, `posz`, `timestamp`, `report`) VALUES (NULL, ";
	query << g_config.getNumber(ConfigManager::WORLD_ID) << ", " << player->getGUID() << ", ";
	Position pos = player->getPosition();
	query << pos.x << ", " << pos.y << ", " << pos.z << ", ";
	query << time(NULL) << ", " << db->escapeString(bug.c_str()) << ");";
	if(!db->executeQuery(query.str()))
	{
		query.str("");
		return false;
	}

	query.str("");
	player->sendTextMessage(MSG_EVENT_DEFAULT, "Your report has been sent to " + g_config.getString(ConfigManager::SERVER_NAME) + ".");
	return true;
}

Not Testet!!!
Please try and tell me if it works...

Yours,
Markey


He asked about ctrl + r not ctrl + z.
 
You published donator's only content :P You'll be hunted !
Rule violations channel is logged by default in /logs if you enable loggin in config.lua
Visit /XML/channels.xml

How do I enable loggin in config.lua? I saw a couple of things related to Logs but I dont want to mess anything up so I ask just in case.

Im using TFS 0.3.2 btw, seems like I dont have channels.xml in XML folder..

And thanks a lot Old Greg too :thumbup:
 
that's posible !!!!????????
ok.. mmm
We think that is possible and we are proposing that amendment in my server.
can somebody help me, please ???
 
Back
Top