A really needed addition: the restart command!
-
As I stated before I already have solved this and recently ported every feature I wrote for New Universe to a plugin, including the restart command. I did some changes to the restart and so far there were no bugs discovered, so i am thinking about releasing the restart command as a plugin soon. The question is wether to wait until I implemented to change the ship and loadout or not. Depends on what the people want I guess
-
You can release multiple versions; I am sure people are dying for this feature…
-
Someone can will make a plugin based on this code. This is flshell-like restarts
void UserCmd_Dots(uint iClientID, wstring wscParam) { if(set_bAllowRestarts) { WIN32_FIND_DATA FileData; HANDLE hSearch; wchar_t oldDir[MAX_PATH]; GetCurrentDirectoryW(MAX_PATH,oldDir); SetCurrentDirectoryW(set_wscRestartDotsPath.c_str()); BOOL fFinished = FALSE; // Start searching for .fl files in the current directory. hSearch = FindFirstFile("*.fl", &FileData); if (hSearch == INVALID_HANDLE_VALUE) { PrintUserCmdText(iClientID, L"Dots not found"); FindClose(hSearch); SetCurrentDirectoryW(oldDir); return; } wstring wscMsg =L""; string scFileName=""; // while (!fFinished) { // add filename scFileName = FileData.cFileName; size_t len = scFileName.length(); scFileName.erase(len-3,len); if (scFileName[0]!='_') wscMsg+=stows(scFileName)+L" "; if (!FindNextFile(hSearch, &FileData)) { if (GetLastError() == ERROR_NO_MORE_FILES) { PrintUserCmdText(iClientID, L"You can use these restarts:"); PrintUserCmdText(iClientID, wscMsg); fFinished = TRUE; } else { PrintUserCmdText(iClientID, L"Internal server error"); FindClose(hSearch); SetCurrentDirectoryW(oldDir); return; } } } // Close the search handle. FindClose(hSearch); SetCurrentDirectoryW(oldDir); } else { PRINT_DISABLED(); } } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// void UserCmd_Restart(uint iClientID, wstring wscParam) { if(ClientInfo[iClientID].bAllowRestart) { wstring wscError[] = { L"Error: Invalid parameters", L"Usage: /restart <faction>", }; wstring wscFraction = GetParam(wscParam, ' ', 0); if(!wscFraction.length()) PRINT_ERROR(); // get rank for MaxRank limit int iRank; pub::Player::GetRank(iClientID, iRank); // searching restart string scPathDot=wstos(set_wscRestartDotsPath) + wstos(wscFraction)+".fl"; if(_access( scPathDot.c_str(), 0 )) {// file not exists scPathDot=wstos(set_wscRestartDotsPath) + "_" + wstos(wscFraction)+".fl"; if(_access( scPathDot.c_str(), 0 )) { PRINT_ERROR(); return; } } if (iRank > set_iMaxRank) { PrintUserCmdText(iClientID,L"Error: You must create a new char to restart. Your rank is too high"); return; } wstring wscCharname=Players.GetActiveCharacterName(iClientID); // Kick player CAccount *acc = Players.FindAccountFromClientID(iClientID); HkMsgAndKick(iClientID, L" restarting... ",set_iKickMsgPeriod); acc->ForceLogout(); // get savefile wstring wscDir; if(!HKHKSUCCESS(HkGetAccountDirName(acc, wscDir))) { string err=wstos(L"Restart failed. " + wscCharname + L" not exists. wscDir = "+wscDir); AddLog(err.c_str()); return;// HKE_CHAR_DOES_NOT_EXIST; } wstring wscFile; HkGetCharFileName(wscCharname, wscFile); string scCharFile = scAcctPath + wstos(wscDir) + "\\" + wstos(wscFile) + ".fl"; // delete savefile if(!(_access( scCharFile.c_str(), 0 ))) {// file exists DeleteFile(scCharFile.c_str()); } // rewrite savefile if(!(CopyFile(scPathDot.c_str(),scCharFile.c_str(),FALSE))) { string err=wstos(L"Restart failed. " + wscCharname + L". Files not copied "); AddLog(err.c_str()); return;// HKE_CHAR_DOES_NOT_EXIST; } // restore nickname. Copy&Paste from HkRename wstring wscNewNameString = L""; for(uint i = 0; (i < wscCharname.length()); i++) { char cHiByte = wscCharname[i] >> 8; char cLoByte = wscCharname[i] & 0xFF; wchar_t wszBuf[8]; swprintf(wszBuf, L"%02X%02X", ((uint)cHiByte) & 0xFF, ((uint)cLoByte) & 0xFF); wscNewNameString += wszBuf; } if(HkIsEncoded(scCharFile)) { string scCharFileNew = scCharFile + ".ini"; if(!flc_decode(scCharFile.c_str(), scCharFileNew.c_str())) { string err=wstos(L"Restart failed. Name " + wscCharname + L" not set. File ")+scCharFile; AddLog(err.c_str()); return;// HKE_COULD_NOT_DECODE_CHARFILE; } IniWrite(scCharFileNew, "Player", "name", wstos(wscNewNameString)); if(!flc_encode(scCharFileNew.c_str(), scCharFile.c_str())) { string err=wstos(L"Restart failed. Name " + wscCharname + L" not set. File ")+scCharFile; AddLog(err.c_str()); return;// HKE_COULD_NOT_ENCODE_CHARFILE; } DeleteFile(scCharFileNew.c_str()); } else { IniWrite(scCharFile, "Player", "name", wstos(wscNewNameString)); } } else { PRINT_DISABLED(); } } [/i][/i]</faction>
-
Right, I’ve hacked up a plugin with this functionality. You can get it here
http://host-a.net/Cannon/restart0.1_plugin.zip
I haven’t done much testing but it seems to work okay. Comments and questions welcome.
It’ll be up on the forge shortly…as soon as I can get the forge upload working again.
I’ve based the code on the post by Jerzy - with a few modifications. If anyone knows the original author(s) of the code please let me know and I’ll credit them.
-
VERY nice work there Cannon
-
VERY nice work there Cannon
YUP!
(And i really enjoy, you just did + posted that, without telling half a year
‘Oh i v done that….’ - ‘…as i told before…’ - ‘…’ - ‘… i m soooo good …’
as we hear from other pebs, without ever seeing, what they did in fact.) -
-
@F!R:
(And i really enjoy, you just did + posted that, without telling half a year
‘Oh i v done that….’ - ‘…as i told before…’ - ‘…’ - ‘… i m soooo good …’
as we hear from other pebs, without ever seeing, what they did in fact.)Sorry Im too stupid to write a plugin, rofl
I said “As soon as New Universe 1.7 is out I will have time to release it (if no one else does it before me).” Well maybe you forgot but some of us have actually something to do in their life despite programming (how about studying at university?). Plus we decided it would be best to have an anticheat solution so I portet about 2500 lines of written code for NU to a big plugin (yes our plugin is about 120Kb compiled). And as expected there were some bugs due to the different way the plugin version handles the function calling of the plugins. Honestly I don’t even care what you say, you say “without ever seeing, what they did in fact”, well make a new char on our server, undock, type i.e. /restart outcast an whoops, you just saw what I wrote…
Im glad there is now an other restart plugin which handles restarts by editing the charfile, I tried to avoid that because of the many warnings the tools give when you do that and used the server functions. So now there are two ways of doing this, maybe someone is willing to combine the techniques. Im still thinking about releasing, maybe I will find time the next days (despite I discovered a problem when using SetAffiliation, but could be plugin version related).
-
Just a heads up….
Your restart plugin dosnt seem to like numbers being in the restart commands name…
We have been using FLShell for restarts, in combination with FLHook, about 2.5 years for clan chars and RP events.
I scrambled the restart names and added a few numbers so players couldnt guess clan restarts and steal equipment, etc…
We moved to a Core2 setup with Server03 and switched to the FLHook 1.6.0 plugin and dropped FLShell as you all know it dosnt play well with a 64 bit setup. I could not get restarts recognized if they had a number in thier name…
Other than that it seems to work perfectly, thanks for the excellent plugins.