///************************************* //* NWN-MySQL 4.0 (c) 2004 FastFrench * //************************************* // This file is licensed under the terms of the // GNU GENERAL PUBLIC LICENSE (GPL) Version 2 // ************************ // ** ff_on_cl_enter.nss ** // ************************ // ** use this script on your OnClientEnter module event // ** (or add the instruction: // ** ExecuteScript("ff_on_cl_enter", OBJECT_SELF); // ** at the beginning of your main function in your existing script #include "ff_inc_action" void JumpBack(object oPC) { if (GetLocalInt(oPC, "InstantRespawn")==0) { SendMessageToPC(oPC, "Nice to see you again "+GetName(oPC)+", wellcome on this server Powered by NWN-FF 4("+GetModuleName()+")"); location lPC = GetLocalLocation(oPC,"Position"); ff_JumpToLocation(oPC, lPC); } DeleteLocalInt(oPC, "InstantRespawn"); } void ProcessEnter(object oPC) { if (GetLocalInt(oPC, "DM_STATUS")>=LV_DM) return; int MaxHP = GetMaxHitPoints(oPC); int Damage = GetLocalInt(oPC,"Damage"); if (Damage<0) Damage=0; effect eDamage; if (MaxHP<=Damage) { SetLocalInt(oPC, "InstantRespawn", 1); ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDeath(TRUE, TRUE), oPC); } else if (Damage>0) { eDamage = EffectDamage(Damage, DAMAGE_TYPE_MAGICAL, DAMAGE_POWER_PLUS_FIVE); ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oPC); } } // Process all actions stored for this PC void Pass5(object oPC) { string sId = GetLocalString(oPC, "PWId"); if (sId == "" || !GetIsObjectValid(oPC)) return; if (FF_USING_LOG_ACTIONS) { SQLExecDirect("SELECT Action,DelayFromLoad,Value1,Value2 FROM logactions WHERE Id="+sId+" AND Date<=NOW()");// Actions du PC while (SQLLocalFetch()==SQL_SUCCESS) { string Action = SQLLocalEatData(); float DelayFromLoad = StringToFloat(SQLLocalEatData()); string Value1 = SQLDecodeSpecialChars(SQLLocalEatData()); string Value2 = SQLDecodeSpecialChars(SQLLocalEatData()); AssignCommand(oPC,DelayCommand(DelayFromLoad, RunIt(Action, Value1, Value2,oPC))); } SQLExecDirect("DELETE FROM logactions WHERE Id="+sId+" AND Date<=NOW() AND OnlyOnce=1");// Actions du joueur } DeleteLocalInt(oPC, "InitRunning"); SendMessageToPC(oPC,"Initialisation completed"); DelayCommand(15.0, ExecuteScript("ff_pc_loops", oPC)); } // Put the hp back void Pass4(object oPC) { if (GetIsObjectValid(oPC)) ProcessEnter(oPC); if (GetIsObjectValid(oPC)) DelayCommand(2.5, Pass5(oPC)); } // Jump back to saved location void Pass3(object oPC) { DeleteLocalInt(oPC, "BLOCKED"); if (GetIsObjectValid(oPC)) { if (FF_USING_NWN_SPEECH) { object oSpeech=GetWaypointByTag("NWN_Speech"); SetLocalObject(oSpeech, GetPCIPAddress(oPC), oPC); SetLocalObject(oSpeech, GetPCPlayerName(oPC), oPC); } JumpBack(oPC); } if (GetIsObjectValid(oPC)) DelayCommand(0.2, Pass4(oPC)); } // Wait for the PC being in a valid location void Pass2(object oPC, int No) { if (!GetIsObjectValid(oPC)) return; // Stop here: PC leaved ? if (!GetIsObjectValid(GetArea(oPC))) { DelayCommand(1.0+IntToFloat(No), Pass2(oPC, No+1)); return; } DelayCommand(0.2, Pass3(oPC)); FadeFromBlack(oPC); } void Pass1(object oPC) { if (ff_SelectPersistentChar(oPC)) { if (GetIsObjectValid(oPC)) DelayCommand(0.2, Pass2(oPC,1)); } else // Perso rejected { AssignCommand(oPC, ClearAllActions()); SetCutsceneMode(oPC, TRUE); SetCommandable(FALSE, oPC); } } void main() { object oPC = GetEnteringObject(); if (!GetIsPC(oPC)) return; DeleteLocalInt(oPC, "BLOCKED"); BlackScreen(oPC); SetLocalObject(oPC, "LastHostile", OBJECT_INVALID); if (GetLocalInt(GetModule(),"ModuleInit") && !GetIsDM(oPC)) { BootPC(oPC); return; } int iLVPlayer = LV_PC; if (GetPCPublicCDKey(oPC)=="VD7TANWT") // Add here the conditions to be an admin (based on CD key, account name, IP...) iLVPlayer = LV_ADMIN; else if (GetIsDM(oPC) || GetIsDMPossessed(oPC)) iLVPlayer = LV_DM; else if (GetSubRace(oPC)=="Vampire") iLVPlayer = LV_VAMPIRE; SetLocalInt(oPC, "DM_STATUS", iLVPlayer); SetLocalInt(oPC, "InitRunning", 1); DeleteLocalString(oPC, "PWId"); string VarNameBAN = GetPCPlayerName(oPC)+"_BAN"; if (GetLocalInt(GetModule(),VarNameBAN)) // This PC was banned by a DM online -> ejected ('til next restart) { if (FF_USE_EXTERNAL_DATABASE) pwWriteLog(oPC, "LOGIN", "REJECT PC", "Soft Var Ban=1 pour "+GetName(oPC)); BootPC(oPC); return; } if (FF_USE_EXTERNAL_DATABASE) DelayCommand(0.4, Pass1(oPC)); else DelayCommand(5.0, FadeFromBlack(oPC)); }