בדיקת קוד:
קוד:
 
 
//this script limits resting by the set ammount of time(variable fRestDelay). //created by Eyal Heber. void main() { //get the last pc object that rested and saves it in oPc object oPc = GetLastPCRested(); int nLevel; float fRestDelay; nLevel = GetTotalLevels(oPc,TRUE);
//checks the level of the oPc to set his rest delay right. if (nLevel<10 ) { fRestDelay = 300.0f; } else if (nLevel<20) { fRestDelay = 480.0f; } else if (nLevel<30) { fRestDelay = 720.0f; } else { fRestDelay = 900.0f; }
//checks the local int of oPc to know if it needs to rest or not. if (GetLocalInt(oPc,"RestCheck")==0)
{ // a loop to set a variable in oPc object to let oPc know how many minutes left before he can rest again when he attempts and fails to do so. int nMinuteWait = FloatToInt(fRestDelay/60); int nLoop = 0; float fLoop; while (nLoop<nMinuteWait) { fLoop = IntToFloat(nLoop*60); DelayCommand(fLoop,SetLocalInt(oPc,"nMinutesLeft",(nMinuteWait)-(nLoop))); nLoop++; }
SetLocalInt(oPc,"RestCheck",1); DelayCommand(fRestDelay,SetLocalInt(oPc,"RestCheck",0));
//uncomment the excutescript line if you want it to also //run the onrest script conditions when someone rests //ExecuteScript(x2_onrest,oPc);
} else {
int nEventType = GetLastRestEventType(); if (nEventType !=2) { //stops all actions because he cant rest yet AssignCommand(oPc,ClearAllActions(TRUE)); //sends a message that tells him how many minutes before he can rest (when you it says 1 minute it could be between 1-60 seconds and so on) int nMinutesWrite; nMinutesWrite = GetLocalInt(oPc,"nMinutesLeft"); string sMinutesWrite = IntToString(nMinutesWrite); DisplayMessageBox(oPc,0,"You have to wait " + sMinutesWrite + " more minute(s) before you can rest"); }
}
}