PenUltima Online

It is currently Sat Sep 06, 2008 9:55 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Problem with an exploit stopper stub
PostPosted: Mon Mar 13, 2006 6:38 pm 
Ok, been working on this problem for a day or two for one of my friends. I've been out of the escript loop for better than a year and a half, and I know I'm missing something obvious.

The code posted here is just a stub representative of what I'm trying to do. When a player uses this command more than once every 5 seconds, he is supposed to adopt an "exploitCount" flag that is incremented every time he uses the command.

My problem: When getting the properties (using getObjProperty(..)) from the player, errortext is returned. I'm not quite getting why. Also--I know that the usingAbility is actually set, I've checked using .propedit.
Thanks in advance.

Code:
use uo;
use cfgfile;
use os;

include "../pkg/character/abilities/abilities";

var abiCfgFile := ReadConfigFile( ":abilities:abilities" );

const TIME_BETWEEN_ABILITY_USES := 5;  //change this number to how long you wish the restriction to be; in seconds


program DotCommand( who, text )
   var abiElem;
   var usableAbilityArray := array;
   var params := array;

   var useAbility := CInt(GetObjProperty(who, "UsingAbility"));
   var exploitCount := CInt(GetObjProperty(who, "exploitCount"));
   var gameClock := (ReadGameClock());
   var useWaitTime := gameClock - TIME_BETWEEN_ABILITY_USES;




//debug code
SysLog("useWaitTime: " + (useWaitTime));
SysLog("gameClock " + (gameClock));
SysLog("useAbility " + CStr(useAbility));
SysLog("exploitCount " + CStr(exploitCount));
SysLog("");
SysLog("");
//end debug

   if (useAbility)
   //has he used an ability?

SysLog("If useAbility");//debug

      if(useAbility > useWaitTime)

SysLog("If useAbility > useWaitTime");//debug

      //has he used the ability in the last TIME_BETWEEN_ABILITY_USES seconds?
         SysLog(who.name + " is attempting to use the .ability exploit!");
         SendSysMessage(who, "Don't do that again...");
            
                     
         if(exploitCount)

SysLog("If exploitCount");//debug

         //has he exploited before?
            SetObjProperty(who, "exploitCount", CInt(exploitCount+1));
                       
            if(exploitCount > 9)

SysLog("If exploitCount > 9");//debug

            //habitual violator, kill him
               SetVital( who, "Life", 1 );
               ApplyRawDamage ( who, 200 );
               return;
            endif
            
            if(exploitCount > 4)

SysLog("If exploitCount > 4");//debug

            //habitual violator, kick him offline
               DisconnectClient(who);
               return;
            endif
         
         else
            //obviously not, set their counter up
            SetObjProperty(who, "exploitCount", CInt(1));
         endif
      endif
   endif
      
   //flag to let other iterations of this script know
   //when the last time it was used   
   SetObjProperty(who, "usingAbility", CInt(ReadGameClock()));

endprogram


edit: aww crap. "usingAbility" != "UsingAbility"


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl