Raised This Month: $ Target: $400
 0% 

Need Opinion (Optimizing / File or Array)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Drak
Veteran Member
Join Date: Jul 2005
Old 01-31-2009 , 18:14   Need Opinion (Optimizing / File or Array)
Reply With Quote #1

In a file, I have the line:
Code:
 hitman *p STEAM_ID_SOMETHING a b c d
This restricts the model "hitman" to "steam_id_something" and access flags "a b c d". I have this function to check it.
Code:
bool:CheckAccess(id,const Model[]) {     if(!is_user_connected(id))         return false         new pFile = fopen(g_ConfigDir,"r"),bool:FileFound = false,bool:HasAccess = false     if(!pFile)         return false         static Data[128],fModel[36],Access[36]     while(!feof(pFile))     {         fgets(pFile,Data,127);         strbreak(Data,fModel,35,Access,35);                 if(containi(Model,fModel) == -1)             continue                 if(containi(Access,"*P") != -1)             strbreak(Access,Data,1,Access,35);                 FileFound = true                 if(!Access[0])             break                 strbreak(Access,Access,35,Data,127);         if(containi(Access,"STEAM_") != -1)         {             new AuthID[36]             get_user_authid(id,AuthID,35);                         if(equali(Access,Data))             {                 HasAccess = true                 break             }         }         if(Data[0])         {             new Len = strlen(Data) / 2,iAccess             server_print("LEN: %d",Len);             for(new Count;Count < Len;Count++)             {                 strbreak(Data,Access,35,Data,127);                 iAccess = GetStringAccess(Access);                 if(iAccess & GetUserAccess(id))                 {                     HasAccess = true                     break                 }             }             if(HasAccess)                 break         }     }     fclose(pFile);         if(FileFound)         return HasAccess         return true }

But I'm super annoyed when I think I'm doing something wrong. The above function works. But I think it can be better, is there anything / other alternatives i can do, to accomplish this?

Also, since i'm using a file. Should I use ether a vault system, or dynamic arrays?
__________________
Oh yeah
Drak is offline
Send a message via MSN to Drak
 



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 01:43.


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