Results 1 to 17 of 17

Thread: Need little help

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    524

    Need little help

    Need little help fix this code
    i want to put all the objects in the .cpp file

    but i got some problems with the lpObj->PlayerID
    in User.h i had add
    #define gObjWarehouseSave 0xC70

    in my commands.cpp
    i have added
    #include "User.h"

    Code:
    //========================================================================================================================
    // Bau String
    //========================================================================================================================
    long int gObj_GetInt(int PlayerID, int gObjParam){
        return *(long int*)(PlayerID * gObjSize + gObjOffset + gObjParam);
    }  
    //========================================================================================================================
    // Bau Command
    //========================================================================================================================
    void TrocaBau(short aIndex,char * Cod){
    
    OBJECTSTRUCT *lpObj = (OBJECTSTRUCT*)OBJECT_POINTER(aIndex);
    
    int BauCod = atoi(Cod);
    char QueryBau[200],mensagem[200];
    
    int TotalBau = SQL.GetFieldInt("MuOnline.dbo.MEMB_INFO","BausExtra", "WHERE Memb___id = '%s'",lpObj->AccountID);
        if (BauCod < 0 ){
            GCServerMsgStringSend("Erro de Sintaxe : /bau <numero do baú>",aIndex,1);
            return ;    
        }
        else if(TotalBau < BauCod){
            sprintf(mensagem,"[Erro] : Você ultrapassou o limite de %d báus!",TotalBau);
            GCServerMsgStringSend(mensagem,aIndex,1);
            return;
        } else {
            if(gObj_GetInt(lpObj->PlayerID,gObjWarehouseSave) == 0){
                sprintf(QueryBau,"EXEC MuOnline.dbo.MUDAR_BAU %d,%s",BauCod,lpObj->AccountID);
                SQL.Execute(QueryBau);
                sprintf(mensagem,"Baú trocado com sucesso! Você está usando o baú nº %d",BauCod);
                GCServerMsgStringSend(mensagem,aIndex,1);
            } else {
                GCServerMsgStringSend("[Erro] : Feche o bau para usar esse comando!",aIndex,1);
                return;
            }
        }
    }

  2. #2
    Fanatic Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    996

    Re: Need little help

    Where is OBJECTSTRUCT defined and what is its definition?

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    524

    Re: Need little help

    here is my user.h file
    Attached Files Attached Files

  4. #4
    Fanatic Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    996

    Re: Need little help

    lpObj is a pointer to a type OBJECTSTRUCT which is a struct. The struct OBJECTSTRUCT doesn't have a member called PlayerId. Thats's why the compiler is complaining about lpObj->PlayerID

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    524

    Re: Need little help

    can you tell me how should add it to read normal everything
    what i need to add ?

  6. #6
    Fanatic Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    996

    Re: Need little help

    What is PlayerID supposed to be and how does it differ from AccountId which is present in OBJECTSTRUCT (but as a string not as an int).

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    524

    Re: Need little help

    PlayerID should be Player Name
    or to use AccountID

  8. #8
    Fanatic Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    996

    Re: Need little help

    PlayerID can't be Player Name as it is used as an int and not as a string. Is AccountID just a number or does it contain non-numeric chars?

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    524

    Re: Need little help

    AccountID contains account names (example: account : Test21 )

  10. #10
    Fanatic Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    996

    Re: Need little help

    Then where does PlayerID as an int come from? Where else in the program is this used? Sorry, but you are going to have to do some investigation work to find out what PlayerID (as a type int) is supposed to be, where it should be stored, where it should be set and where it is beibg used.

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    524

    Re: Need little help

    this is 1 example that i found in code
    Code:
    if((PlayerID>=OBJECT_MIN) && (PlayerID<=OBJECT_MAX))
    	{
    		OBJECTSTRUCT * pObj = (OBJECTSTRUCT*)OBJECT_POINTER(PlayerID);
    		
    			gObjTeleport(PlayerID,gObj->MapNumber,gObj->X,gObj->Y);
    			isFind = 1;
    	
    	}
    
    	if(isFind == 1)
    	{
    	}
    	else
    	{
    	MsgNormal(aIndex,"[Status] Player: %s  is offline",Player);
    	}
    }

  12. #12
    Fanatic Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    996

    Re: Need little help

    Where is PlayerID defined? Its not defined in the user.h file in post #3.
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  13. #13

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    524

    Re: Need little help

    yes its not defined in user.h
    i need to defined it so to work
    or to change the code to work with Name or AccountID to search

  14. #14
    Fanatic Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    996

    Re: Need little help

    The issue is not just defining PlayerID - the real issue is how it's used - where it is set etc. I can't really help you wth that. You are going to have to go through all the code and understand how it's used.

    To get the code to compile, just add this to the OBJECTSTRUCT struct in user.h at the end of the struct definiton.
    Code:
    int GreatDefBuff;
    int GreatDamBuff;
    int PlayerID;
    however, this won't mean that the program will work correctly because it won't as PlayerID isn't been set anywhere. You'll need to work out where and how to set it.
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  15. #15

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    524

    Re: Need little help

    other option is to add
    char Player[16] = {0};
    ?

  16. #16
    Fanatic Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    996

    Re: Need little help

    Quote Originally Posted by diablo21 View Post
    other option is to add
    char Player[16] = {0};
    ?
    Not really as the code requires PlayerID to be of type int as a member of OBJECTSTRUCT.
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  17. #17

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    524

    Re: Need little help

    Code:
    int CQuery::GetaIndexPlayer(char Name[11])
    {	
    	char SQLJob[0xFF];
    	char MSG2[200];
    	// ---
    	wsprintf(SQLJob, "SELECT aIndex FROM Character WHERE Name = '%s'", Name);
    	this->Execute(SQLJob);
    	SQLFetch(this->m_SQLSTMTHandle);
    	this->aIndexP = this->GetAsInteger("aIndex");
    	SQLFreeHandle(SQL_HANDLE_STMT, this->m_SQLSTMTHandle);
    	// ---
    	return aIndexP;
    }
    Code:
    DWORD PlayerID = SQL.GetaIndexPlayer(Player);
    OBJECTSTRUCT * pObj = (OBJECTSTRUCT*)OBJECT_POINTER(PlayerID);
    if(isFind == 0)
    	{
    	MsgNormal(aIndex,"[UnMute]: [%s] Is UnMuted",Player);
    	}
    this is other way that found how use PlayerID

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width