From: <rav...@us...> - 2016-12-20 21:09:17
|
Revision: 9979 http://sourceforge.net/p/planeshift/code/9979 Author: ravna-ps Date: 2016-12-20 21:09:16 +0000 (Tue, 20 Dec 2016) Log Message: ----------- Added: A math script called "CalculateChanceOfMountSuccess" will be called before a player can mount, it gets 2 variables "Mount" and "Actor", both of GemActor type, it is supposed to set a variable named "Result", if it set to a positive number, it will allow the mounting, if it is set to 0 or not at all, it will not allow mounting. If the script does not exist on the server, it will be ignored. Modified Paths: -------------- trunk/src/server/usermanager.cpp Modified: trunk/src/server/usermanager.cpp =================================================================== --- trunk/src/server/usermanager.cpp 2016-12-17 22:56:09 UTC (rev 9978) +++ trunk/src/server/usermanager.cpp 2016-12-20 21:09:16 UTC (rev 9979) @@ -2403,6 +2403,27 @@ return; } + { + MathEnvironment env; + env.Define("Actor", client->GetActor()); + env.Define("Mount", mount->GetActorPtr()); + MathScriptEngine* eng = psserver->GetMathScriptEngine(); + MathScript* mountScript = eng->FindScript("CalculateChanceOfMountSuccess"); + if (mountScript) + { + mountScript->Evaluate(&env); + int result = env.Lookup("Result")->GetRoundValue(); + if (!result) + { + psserver->SendSystemError(client->GetClientNum(), + "You are not allowed to ride this mount."); + return; + } + } + } + //<eonwind> Result= 1; + //<eonwind> if Result = 0; fail + /*Client *targetClient = mount->GetClient(); if(targetClient) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |