Jump to content

[Dev] Tele-Command with GMlevel


Guest LickedLurk

Recommended Posts

I would replace this part

uint32 tmp_gmlevel = 0;

by

AccountTypes gmlevel = m_session->GetSecurity();

and work with it in future.

Or we can do next:

uint32 tmp_gmlevel = m_session->GetSecurity();

In this case we can drop this indian code :)

+    switch(m_session->GetSecurity()) // Maybe check this later with the direct GMLevelID from Account table
+    {
+    case SEC_PLAYER:
+        tmp_gmlevel = 0;
+        break;
+    case SEC_MODERATOR:
+        tmp_gmlevel = 1;
+        break;
+    case SEC_GAMEMASTER:
+        tmp_gmlevel = 2;
+        break;
+    case SEC_ADMINISTRATOR:
+        tmp_gmlevel = 3;
+        break;
+    default: 
+        return false;
+    }

My version without the indian code.

http://pastebin.com/m1e03e63

sql:

ALTER TABLE game_tele ADD COLUMN `security` tinyint(3) unsigned NOT NULL DEFAULT '0' AFTER `name`;

Link to comment
Share on other sites

Hmm, i dont really get it..

m_session->GetSecurity()

gives out strings and not integers or iam wrong..

thats why i convert these strings (SEC_PLAYER, SEC_MODERATOR, ect.) to integers with this method..

with your way you will have problems on this part:

if (gmLevel <= secLevelOfTele) // Very simple here. Need more checks!

cause "secLevelOfTele woul be a string , or iam totally wrong with that?

Link to comment
Share on other sites

Hmm, i dont really get it..

m_session->GetSecurity()

gives out strings and not integers or iam wrong..

thats why i convert these strings (SEC_PLAYER, SEC_MODERATOR, ect.) to integers with this method..

with your way you will have problems on this part:

if (gmLevel <= secLevelOfTele) // Very simple here. Need more checks!

cause "secLevelOfTele woul be a string , or iam totally wrong with that?

yes you are.

Try this little example, which will show you one secret of a enums.

#include <iostream>

using std::cout;

enum Acc {
   pl = 1,
   gm,
   ad
};

Acc get();
int main(){

   int m;
   m = pl;
   cout << m << "\\n";
   cout << get() << "\\n";
   if ( m < get())
       cout << "Anti the best!" << "\\n";
   system("PAUSE");
}
Acc get()
{ 
   Acc sec = ad;
   return sec;
}

Link to comment
Share on other sites

Hmm, i dont really get it..

m_session->GetSecurity()

gives out strings and not integers or iam wrong..

thats why i convert these strings (SEC_PLAYER, SEC_MODERATOR, ect.) to integers with this method..

with your way you will have problems on this part:

if (gmLevel <= secLevelOfTele) // Very simple here. Need more checks!

cause "secLevelOfTele woul be a string , or iam totally wrong with that?

SEC_PLAYER basically is a variable that can't be changed that contains a value, SEC_PLAYER would be 0 I think.

Link to comment
Share on other sites

Looks good. The only problem is:

+    uint32 tmp_gmlevel = 0;
+
+    switch(m_session->GetSecurity()) // Maybe check this later with the direct GMLevelID from Account table
+    {
+    case SEC_PLAYER:
+        tmp_gmlevel = 0;
+        break;
+    case SEC_MODERATOR:
+        tmp_gmlevel = 1;
+        break;
+    case SEC_GAMEMASTER:
+        tmp_gmlevel = 2;
+        break;
+    case SEC_ADMINISTRATOR:
+        tmp_gmlevel = 3;
+        break;
+    default: 
+        return false;
+    }
+
+    uint32 a_gmlevel = tmp_gmlevel;   // GM-SecurityLevel from GetSecurity(), maybe pull that directly from AccountData for better Custom Settings

Like they said, can be reduced to just:

+    uint32 a_gmlevel = m_session->GetSecurity();

Does exactly the same thing. If that doesn't work (I haven't tried it) try:

+    uint32 a_gmlevel = ((uint32)m_session->GetSecurity());

Link to comment
Share on other sites

Looks good. The only problem is:

+    uint32 tmp_gmlevel = 0;
+
+    switch(m_session->GetSecurity()) // Maybe check this later with the direct GMLevelID from Account table
+    {
+    case SEC_PLAYER:
+        tmp_gmlevel = 0;
+        break;
+    case SEC_MODERATOR:
+        tmp_gmlevel = 1;
+        break;
+    case SEC_GAMEMASTER:
+        tmp_gmlevel = 2;
+        break;
+    case SEC_ADMINISTRATOR:
+        tmp_gmlevel = 3;
+        break;
+    default: 
+        return false;
+    }
+
+    uint32 a_gmlevel = tmp_gmlevel;   // GM-SecurityLevel from GetSecurity(), maybe pull that directly from AccountData for better Custom Settings

Like they said, can be reduced to just:

+    uint32 a_gmlevel = m_session->GetSecurity();

Does exactly the same thing. If that doesn't work (I haven't tried it) try:

+    uint32 a_gmlevel = ((uint32)m_session->GetSecurity());

It works for int variables. But there are types of variables defined in special way and we have to use static_cast or something else.

I had use static_cast because it'll work as I want it.

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use