Jump to content

[Dev] Tele-Command with GMlevel


Recommended Posts

Posted

Hey guys,

this is my first custom patch and my first work i would like to share..

the script is not finished, so i want a little help from you guys, to finish my work..

I hope you guys can help me and find ways together with me to implement it better.

I will also share some other stuff with you in future..

Tele-GM-Patch v1

Regards LickedLurk

Posted

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`;

Posted

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?

Posted
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;
}

Posted

okay... now im really confused^^...

your example is more difficult than my hole script xD

i will learn more about that, i promise.. :)

do you test my script with you changes, cause i cant, cause im not at home now..

Posted

Works patch. Based on the Licked's patch but i have rewrited many things and it looks fine now.

Enjoy it!

And sql.

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

Posted
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.

Posted
Ok! i like the patch! but where is the sql?

damn. Forgot about it.

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

Posted

Yeah im really new with C++ it was my first try...

I already do some other stuff, but i dont do it official yet..

maybe Anti can help me with rework some thing on my nooby and maybe hacky data..

regards

lickedlurk

Posted

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());

Posted
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.

×
×
  • 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