Raised This Month: $51 Target: $400
 12% 

Did I miss something?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sumguy14
Senior Member
Join Date: Apr 2006
Old 12-26-2007 , 20:53   Did I miss something?
Reply With Quote #1

Why was IsValidHandle depreciated?

What should we use now? (Totally ruined about all my plugins)

And can someone make this work again?

Code:
stock StrToken(const String:inputstr[],tokennum,String:outputstr[],maxlen)
{
  decl String:buf;
  new cur_idx;
  new idx;
  new curind;
  idx=BreakString(inputstr,buf,maxlen);
  if(tokennum==1)
  {
    strcopy(outputstr,maxlen,buf);
    return;
  }
  curind=1;
  while (idx!=-1)
  {
    cur_idx+=idx;
    idx=BreakString(inputstr[cur_idx],buf,maxlen);
    curind++;
    if(tokennum==curind)
    {
      strcopy(outputstr,maxlen,buf);
      break;
    }
  }
}
I was using StrBreak, but it was depreciated and said to use BreakString, but now I'm getting compiler errors saying that arg 2 of the breakstring line has a datatype mismatch.

I dont understand. arg 2 is 'buf' and 'buf' is declared about 3-4 lines above as a string, which is the same type in the native.

Btw, this is an old stock and has seen many updates, so it might not be optimized as much as it could be.
__________________
Don't think of them as bugs think of them as unexpected features
sumguy14 is offline
pRED*
Join Date: Dec 2006
Old 12-26-2007 , 21:37   Re: Did I miss something?
Reply With Quote #2

new String:buf[length] - it needs to be an array not a single cell.

IsValidHandle was deprecated because you should already know if it is valid or not. When you close a Handle make sure you re-assign it to 'INVALID_HANDLE'.
pRED* is offline
ferret
SourceMod Developer
Join Date: Dec 2004
Location: Atlanta, GA
Old 12-26-2007 , 22:09   Re: Did I miss something?
Reply With Quote #3

IsValidHandle was depreciated. Just check if your handles are set to INVALID_HANDLE. They won't go invalid on you unless you personally close them.

I.e.

Code:
if (myHandle == INVALID_HANDLE)
{
myHandle = CreateDataPack();
}
else
{
DestroyDataPack(myHandle);
myHandle = INVALID_HANDLE;
}
Psuedo code.
__________________
I'm a blast from the past!
ferret is offline
BAILOPAN
Join Date: Jan 2004
Old 12-27-2007 , 02:08   Re: Did I miss something?
Reply With Quote #4

There is also a more subtle problem with IsValidHandle() in that it will tell you if a Handle is readable or not, but it will not type check it. That is, your Handle could change types, revalidate, and then not work in the same native. All in all it was a disastrous API idea and I regret adding it
__________________
egg
BAILOPAN is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:57.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode