Useful Function For Beginners

Newbie Spellweaver
Joined
Jan 19, 2013
Messages
41
Reaction score
20
Get map name by the ID:
Code:
char *QueryClass::MapIdToString(int MapId)
{
    switch(MapId)
    {
    case 0: return "Lorencia";
    case 1: return "Dungeon";
    case 2: return "Devias";
    case 3: return "Noria";
    case 4: return "Lost Tower";
    case 6: return "Arena";
    case 7: return "Atlans";
    case 8: return "Tarkan";
    case 9: return "Devil Square";
    case 10: return "Icarus";
    case 32: return "Devil Square";
    case 11: return "Blood Castle";
    case 12: return "Blood Castle";
    case 13: return "Blood Castle";
    case 14: return "Blood Castle";
    case 15: return "Blood Castle";
    case 16: return "Blood Castle";
    case 17: return "Blood Castle";
    case 52: return "Blood Castle";
    case 18: return "Chaos Castle 1";
    case 19: return "Chaos Castle 2";
    case 20: return "Chaos Castle 3";
    case 21: return "Chaos Castle 4";
    case 22: return "Chaos Castle 5";
    case 23: return "Chaos Castle 6";
    case 24: return "Kalima 1";
    case 25: return "Kalima 2";
    case 26: return "Kalima 3";
    case 27: return "Kalima 4";
    case 28: return "Kalima 5";
    case 29: return "Kalima 6";
    case 36: return "Kalima 7";
    case 33: return "Adia";
    case 37: return "Kanturu";
    case 38: return "Kanturu Tower";
    case 39: return "Kanturu Event";
    default: return "Unknown";
    }
}

Get class name by ID:
Code:
char *QueryClass::ClassIdToString(int ClassId)
{
    switch(ClassId)
    {
    case 0: return "Dark Wizard";
    case 1: return "Soul Master";
    case 16: return "Dark Knight";
    case 17: return "Blade Knight";
    case 32: return "Fairy Elf";
    case 33: return "Muse Elf";
    case 48: return "Magic Gladiator";
    case 64: return "Dark Lord";
    default: return "Unknown";
    }
}

Get (Admin Only):
Code:
void GetCommand(int aIndex,char* Message)
{
    if(VerifyGM(aIndex) == false)
    {
        return;
    }

    if(!_strcmpi("/get",Message))
    {
        GCServerMsgStringSend("Usage: /get <name>",aIndex,1);
        return;
    }

    if(strlen(Message) < 1)
    {
        GCServerMsgStringSend("Usage: /get <name>",aIndex,1);
        return;
    }

    int Spaces = 0;

    for(int i = 0; i < strlen(Message); i++)
    {
        if(Message[i] == ' ')
        {
            Spaces++;
        }
    }

    if(Spaces != 1)
    {
        GCServerMsgStringSend("Error, please re-check the string you gave.",aIndex,1);
        return;
    }

    char Target[11];
    sscanf(Message,"%s",&Target);
    
    if(strlen(Target) > 10)
    {
        GCServerMsgStringSend("Error, name can be only 10 characters long.",aIndex,1);
        return;
    }

    int tIndex = gObjGetIndex(Target);

    if(tIndex == 0)
    {
        GCServerMsgStringSend("Error, character not found or is offline.",aIndex,1);
        return;
    }

    gObjTeleport(aIndex , gObj[tIndex].MapNumber , gObj[tIndex].X, gObj[tIndex].Y);

    MsgOutput(aIndex,"You successfully teleported to %s's location.",Target);
            
    if(OnlineStatus(tIndex))
    {
        MsgOutput(tIndex,"%s teleported you your location..",gObj[aIndex].Name);
    }

    Log.AddTime("Use GM Command -> [ %s ]\t[ %s ]\t[ %s ] : %s",gObj[aIndex].Ip_addr,gObj[aIndex].AccountID,gObj[aIndex].Name,"Goto");
    Log.GM("Use GM Command -> [ %s ]\t[ %s ]\t[ %s ] : %s\n",gObj[aIndex].Ip_addr,gObj[aIndex].AccountID,gObj[aIndex].Name,"Goto");
}

Goto (Admin Only):
Code:
void GotoCommand(int aIndex,char* Message)
{
    if(VerifyGM(aIndex) == false)
    {
        return;
    }

    if(!_strcmpi("/goto",Message))
    {
        GCServerMsgStringSend("Usage: /goto <name>",aIndex,1);
        return;
    }

    if(strlen(Message) < 1)
    {
        GCServerMsgStringSend("Usage: /goto <name>",aIndex,1);
        return;
    }

    int Spaces = 0;

    for(int i = 0; i < strlen(Message); i++)
    {
        if(Message[i] == ' ')
        {
            Spaces++;
        }
    }

    if(Spaces != 1)
    {
        GCServerMsgStringSend("Error, please re-check the string you gave.",aIndex,1);
        return;
    }

    char Target[11];
    sscanf(Message,"%s",&Target);
    
    if(strlen(Target) > 10)
    {
        GCServerMsgStringSend("Error, name can be only 10 characters long.",aIndex,1);
        return;
    }

    int tIndex = gObjGetIndex(Target);

    if(tIndex == 0)
    {
        GCServerMsgStringSend("Error, character not found or is offline.",aIndex,1);
        return;
    }

    gObjTeleport(tIndex , gObj[aIndex].MapNumber , gObj[aIndex].X, gObj[aIndex].Y);

    MsgOutput(aIndex,"You successfully teleported %s to your location.",Target);
            
    if(OnlineStatus(tIndex))
    {
        MsgOutput(tIndex,"%s has teleported you to he's location.",gObj[aIndex].Name);
    }

    Log.AddTime("Use GM Command -> [ %s ]\t[ %s ]\t[ %s ] : %s",gObj[aIndex].Ip_addr,gObj[aIndex].AccountID,gObj[aIndex].Name,"Goto");
    Log.GM("Use GM Command -> [ %s ]\t[ %s ]\t[ %s ] : %s\n",gObj[aIndex].Ip_addr,gObj[aIndex].AccountID,gObj[aIndex].Name,"Goto");
}

Drop Bless (All Players):
Code:
void BlessCommand(int aIndex)
{
    int ItemType = 14, ItemNr = 13, ItemLevel = 0, ItemSkill = 0, ItemLuck = 0, ItemOpt = 0, ItemExc = 0;

    DWORD Item = ItemType * 512 + ItemNr;

    ItemSerialCreateSend(aIndex,gObj[aIndex].MapNumber,gObj[aIndex].X,gObj[aIndex].Y,Item,ItemLevel,0,ItemSkill,ItemLuck,ItemOpt,aIndex,ItemExc,0);
    
    GCServerMsgStringSend("Item created successfully.",aIndex,1);

    if(conf.commands.makesave == 1)
    {
        Log.Make("[Free] Creator: %s, Jewel: Bless\n",gObj[aIndex].Name);
    }
}

Drop Soul (All Players):
Code:
void SoulCommand(int aIndex)
{
    int ItemType = 14, ItemNr = 14, ItemLevel = 0, ItemSkill = 0, ItemLuck = 0, ItemOpt = 0, ItemExc = 0;

    DWORD Item = ItemType * 512 + ItemNr;

    ItemSerialCreateSend(aIndex,gObj[aIndex].MapNumber,gObj[aIndex].X,gObj[aIndex].Y,Item,ItemLevel,0,ItemSkill,ItemLuck,ItemOpt,aIndex,ItemExc,0);
    
    GCServerMsgStringSend("Item created successfully.",aIndex,1);

    if(conf.commands.makesave == 1)
    {
        Log.Make("[Free] Creator: %s, Jewel: Soul\n",gObj[aIndex].Name);
    }
}

Drop Life (All Players):
Code:
void LifeCommand(int aIndex)
{
    int ItemType = 14, ItemNr = 16, ItemLevel = 0, ItemSkill = 0, ItemLuck = 0, ItemOpt = 0, ItemExc = 0;

    DWORD Item = ItemType * 512 + ItemNr;

    ItemSerialCreateSend(aIndex,gObj[aIndex].MapNumber,gObj[aIndex].X,gObj[aIndex].Y,Item,ItemLevel,0,ItemSkill,ItemLuck,ItemOpt,aIndex,ItemExc,0);
    
    GCServerMsgStringSend("Item created successfully.",aIndex,1);

    if(conf.commands.makesave == 1)
    {
        Log.Make("[Free] Creator: %s, Jewel: Life\n",gObj[aIndex].Name);
    }
}

Drop Chaos (All Players):
Code:
void ChaosCommand(int aIndex)
{
    int ItemType = 12, ItemNr = 15, ItemLevel = 0, ItemSkill = 0, ItemLuck = 0, ItemOpt = 0, ItemExc = 0;

    DWORD Item = ItemType * 512 + ItemNr;

    ItemSerialCreateSend(aIndex,gObj[aIndex].MapNumber,gObj[aIndex].X,gObj[aIndex].Y,Item,ItemLevel,0,ItemSkill,ItemLuck,ItemOpt,aIndex,ItemExc,0);
    
    GCServerMsgStringSend("Item created successfully.",aIndex,1);

    if(conf.commands.makesave == 1)
    {
        Log.Make("[Free] Creator: %s, Jewel: Chaos\n",gObj[aIndex].Name);
    }
}

Drop Creation (All Players):
Code:
void CreationCommand(int aIndex)
{
    int ItemType = 14, ItemNr = 22, ItemLevel = 0, ItemSkill = 0, ItemLuck = 0, ItemOpt = 0, ItemExc = 0;

    DWORD Item = ItemType * 512 + ItemNr;

    ItemSerialCreateSend(aIndex,gObj[aIndex].MapNumber,gObj[aIndex].X,gObj[aIndex].Y,Item,ItemLevel,0,ItemSkill,ItemLuck,ItemOpt,aIndex,ItemExc,0);
    
    GCServerMsgStringSend("Item created successfully.",aIndex,1);

    if(conf.commands.makesave == 1)
    {
        Log.Make("[Free] Creator: %s, Jewel: Creation\n",gObj[aIndex].Name);
    }
}

Drop Guardian (All Players):
Code:
void GuardianCommand(int aIndex)
{
    int ItemType = 14, ItemNr = 31, ItemLevel = 0, ItemSkill = 0, ItemLuck = 0, ItemOpt = 0, ItemExc = 0;

    DWORD Item = ItemType * 512 + ItemNr;

    ItemSerialCreateSend(aIndex,gObj[aIndex].MapNumber,gObj[aIndex].X,gObj[aIndex].Y,Item,ItemLevel,0,ItemSkill,ItemLuck,ItemOpt,aIndex,ItemExc,0);
    
    GCServerMsgStringSend("Item created successfully.",aIndex,1);

    if(conf.commands.makesave == 1)
    {
        Log.Make("[Free] Creator: %s, Jewel: Guardian\n",gObj[aIndex].Name);
    }
}

Get 2b zen (All Players):
Code:
void ZenCommand(int aIndex)
{
    gObjWrite(aIndex, gObjZen, 2000000000);
    GCMoneySend(aIndex, 2000000000);

    MsgOutput(aIndex, "You modified your money to 2,000,000,000.");

    if(conf.commands.makesave == 1)
    {
        Log.Add("[Zen] Requested: %s\n",gObj[aIndex].Name);
    }
}

Credits:
Shatter - for the great project.
Xerwell - me ;D (For wrting all that ****)
 
Last edited:
Code:
void ZenCommand(int aIndex) //Add zen to user
{    
 gObjWrite(aIndex, gObjZen, 2000000000);  // I do not know what make this function
 GCMoneySend(aIndex, 2000000000); //Is a pointer to func that take money if cmd is used
 MsgOutput(aIndex, "You modified your money to 2,000,000,000."); //Is user function that output message into screen
  if(conf.commands.makesave == 1) //Struct member that is initialized by GetPrivateProfileInt. GetPrivateProfileInt is bla bla.
 {      
  Log.Add("[Zen] Requested: %s\n",gObj[aIndex].Name);  //Logger console or game screen
 }
}

Did you think that the beginner is aware that GCMoneySend is a pointer to function for example? Where is declaration? Where is structure declaration? The same **** applies to other functions... If you want to teach a beginner, try to explain more detailed about these code.
 
Code:
void ZenCommand(int aIndex) //Add zen to user
{    
 gObjWrite(aIndex, gObjZen, 2000000000);  // I do not know what make this function
 GCMoneySend(aIndex, 2000000000); //Is a pointer to func that take money if cmd is used
 MsgOutput(aIndex, "You modified your money to 2,000,000,000."); //Is user function that output message into screen
  if(conf.commands.makesave == 1) //Struct member that is initialized by GetPrivateProfileInt. GetPrivateProfileInt is bla bla.
 {      
  Log.Add("[Zen] Requested: %s\n",gObj[aIndex].Name);  //Logger console or game screen
 }
}

Did you think that the beginner is aware that GCMoneySend is a pointer to function for example? Where is declaration? Where is structure declaration? The same **** applies to other functions... If you want to teach a beginner, try to explain more detailed about these code.
For example how to start computer and visual studio.

We have many open source emulators and decompilations. Code is useless for everyone who doesn't know basics of cpp coding so there is no reason for explaining how to use this code.
 
Back