Thread: Cant find the error

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    110

    Cant find the error

    Hi, can someone help me find the error?

    My function is:

    Code:
    void Command_Place(char **Arg, int ArgCount)
    {
    
    char OverflowHue[25] = {0};
    stHouseItem HouseItem = {0};
    POINT PLocal;
    POINT HLocal;
    PLocal.x = ArgToInt(Arg[1]);
    PLocal.y = ArgToInt(Arg[2]);
    
    HLocal.x = PLocal.x - Center.x;
    HLocal.y = PLocal.y - Center.y;
    
    
    ClientPrint("%s %d", "HOUSE X ",HLocal.x);
    ClientPrint("%s %i", "HOUSE Y ",HLocal.y);
    
    HouseItem.cmd = 0xD7;
    HouseItem.size[1] = 0x19;
    HouseItem.serial[2] = 0x15;
    HouseItem.serial[3] = 0xC9;
    HouseItem.cmdsend[1] = 0x06;
    HouseItem.artid[2] = 0x05;
    HouseItem.artid[3] = 0x22;
    HouseItem.posx[3] = char(9);
    HouseItem.posy[3] = char(-3);
    HouseItem.unkown4 = 0x0A;
    memcpy(OverflowHue,&HouseItem,sizeof(OverflowHue));
    SendToServer(OverflowHue,25);
    }
    Im not sure if im using C++ and shouldnt be, or im initalizing wrong, but does anyone know?

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Quote Originally Posted by Coder87C
    Hi, can someone help me find the error?
    What's the problem?
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Registered User
    Join Date
    Jul 2003
    Posts
    110
    these are my errors

    in summary I think it has to do with the way I initizalied but not sure
    Code:
    C:\Documents and Settings\Rick.STUDENT-4AF1JJ8\Desktop\IRW\L33t_Tiles\Main.c(174): error C2144: syntax error : '<Unknown>' should be preceded by '<Unknown>'
    C:\Documents and Settings\Rick.STUDENT-4AF1JJ8\Desktop\IRW\L33t_Tiles\Main.c(174): error C2146: syntax error : missing ';' before identifier 'PLocal'
    C:\Documents and Settings\Rick.STUDENT-4AF1JJ8\Desktop\IRW\L33t_Tiles\Main.c(174): error C2275: 'POINT' : illegal use of this type as an expression
    C:\Documents and Settings\Rick.STUDENT-4AF1JJ8\Desktop\IRW\L33t_Tiles\Main.c(175): error C2065: 'HLocal' : undeclared identifier
    C:\Documents and Settings\Rick.STUDENT-4AF1JJ8\Desktop\IRW\L33t_Tiles\Main.c(175): error C2143: syntax error : missing ';' before 'identifier'
    C:\Documents and Settings\Rick.STUDENT-4AF1JJ8\Desktop\IRW\L33t_Tiles\Main.c(175): error C2144: syntax error : '<Unknown>' should be preceded by '<Unknown>'
    C:\Documents and Settings\Rick.STUDENT-4AF1JJ8\Desktop\IRW\L33t_Tiles\Main.c(175): error C2144: syntax error : '<Unknown>' should be preceded by '<Unknown>'
    C:\Documents and Settings\Rick.STUDENT-4AF1JJ8\Desktop\IRW\L33t_Tiles\Main.c(175): error C2146: syntax error : missing ';' before identifier 'HLocal'
    C:\Documents and Settings\Rick.STUDENT-4AF1JJ8\Desktop\IRW\L33t_Tiles\Main.c(175): error C2275: 'POINT' : illegal use of this type as an expression
    C:\Documents and Settings\Rick.STUDENT-4AF1JJ8\Desktop\IRW\L33t_Tiles\Main.c(176): error C2224: left of '.x' must have struct/union type
    C:\Documents and Settings\Rick.STUDENT-4AF1JJ8\Desktop\IRW\L33t_Tiles\Main.c(177): error C2224: left of '.y' must have struct/union type
    C:\Documents and Settings\Rick.STUDENT-4AF1JJ8\Desktop\IRW\L33t_Tiles\Main.c(179): error C2224: left of '.x' must have struct/union type
    C:\Documents and Settings\Rick.STUDENT-4AF1JJ8\Desktop\IRW\L33t_Tiles\Main.c(179): error C2224: left of '.x' must have struct/union type
    C:\Documents and Settings\Rick.STUDENT-4AF1JJ8\Desktop\IRW\L33t_Tiles\Main.c(180): error C2224: left of '.y' must have struct/union type
    C:\Documents and Settings\Rick.STUDENT-4AF1JJ8\Desktop\IRW\L33t_Tiles\Main.c(180): error C2224: left of '.y' must have struct/union type
    C:\Documents and Settings\Rick.STUDENT-4AF1JJ8\Desktop\IRW\L33t_Tiles\Main.c(183): error C2224: left of '.x' must have struct/union type
    C:\Documents and Settings\Rick.STUDENT-4AF1JJ8\Desktop\IRW\L33t_Tiles\Main.c(184): error C2224: left of '.y' must have struct/union type
    C:\Documents and Settings\Rick.STUDENT-4AF1JJ8\Desktop\IRW\L33t_Tiles\Main.c(186): error C2224: left of '.cmd' must have struct/union type
    C:\Documents and Settings\Rick.STUDENT-4AF1JJ8\Desktop\IRW\L33t_Tiles\Main.c(187): error C2224: left of '.size' must have struct/union type
    C:\Documents and Settings\Rick.STUDENT-4AF1JJ8\Desktop\IRW\L33t_Tiles\Main.c(188): error C2224: left of '.serial' must have struct/union type
    C:\Documents and Settings\Rick.STUDENT-4AF1JJ8\Desktop\IRW\L33t_Tiles\Main.c(189): error C2224: left of '.serial' must have struct/union type
    C:\Documents and Settings\Rick.STUDENT-4AF1JJ8\Desktop\IRW\L33t_Tiles\Main.c(190): error C2224: left of '.cmdsend' must have struct/union type
    C:\Documents and Settings\Rick.STUDENT-4AF1JJ8\Desktop\IRW\L33t_Tiles\Main.c(191): error C2224: left of '.artid' must have struct/union type
    C:\Documents and Settings\Rick.STUDENT-4AF1JJ8\Desktop\IRW\L33t_Tiles\Main.c(192): error C2224: left of '.artid' must have struct/union type
    C:\Documents and Settings\Rick.STUDENT-4AF1JJ8\Desktop\IRW\L33t_Tiles\Main.c(193): error C2059: syntax error : 'type'
    C:\Documents and Settings\Rick.STUDENT-4AF1JJ8\Desktop\IRW\L33t_Tiles\Main.c(193): error C2224: left of '.posx' must have struct/union type
    C:\Documents and Settings\Rick.STUDENT-4AF1JJ8\Desktop\IRW\L33t_Tiles\Main.c(194): error C2059: syntax error : 'type'
    C:\Documents and Settings\Rick.STUDENT-4AF1JJ8\Desktop\IRW\L33t_Tiles\Main.c(194): error C2224: left of '.posy' must have struct/union type
    C:\Documents and Settings\Rick.STUDENT-4AF1JJ8\Desktop\IRW\L33t_Tiles\Main.c(195): error C2224: left of '.unkown4' must have struct/union type

  4. #4
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Where is POINT, et al, defined?
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  5. #5
    Registered User
    Join Date
    Jul 2003
    Posts
    110
    POINT is standard I believe due to the fact I have no definition for it and it compiles. If I comment out the HouseItem stuff it compiles. So its this is the struct for houseitem

    Code:
    struct stHouseItem
    {
    	char cmd; 
    	char size[2];
    	unsigned char serial[4];
    	char cmdsend[2];
    	char unkown1;
    	char artid[4];
    	char unkown2;
    	unsigned char posx[4];
    	char unkown3;
    	unsigned char posy[4];
    	char unkown4;
    };

  6. #6
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Quote Originally Posted by Coder87C
    POINT is standard I believe due to the fact I have no definition for it and it compiles.
    It is not.

    Quote Originally Posted by Coder87C
    If I comment out the HouseItem stuff it compiles. So its this is the struct for houseitem

    Code:
    struct stHouseItem
    {
    	char cmd; 
    	char size[2];
    	unsigned char serial[4];
    	char cmdsend[2];
    	char unkown1;
    	char artid[4];
    	char unkown2;
    	unsigned char posx[4];
    	char unkown3;
    	unsigned char posy[4];
    	char unkown4;
    };
    Where is struct stHouseItem defined?
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  7. #7
    Registered User
    Join Date
    Jul 2003
    Posts
    110
    this is where stHouseItem is defined.

    Code:
    /******************************************************************************\
    * 
    * 
    * 
    * 
    *  This program is free software; you can redistribute it and/or modify
    *  it under the terms of the GNU General Public License as published by
    *  the Free Software Foundation; either version 2 of the License, or
    *  (at your option) any later version.
    * 
    *  This program is distributed in the hope that it will be useful,
    *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    *  GNU General Public License for more details.
    * 
    * 	Feb 25th, 2005 -- Stupid Print Plugin to handle Sysmessages and Exmessage
    * 
    \******************************************************************************/
    
    #include <windows.h>
    #include <string.h>
    #include "Main.h"
    #include "irw.h"
    
     
    struct stHouseItem
    {
    	char cmd; 
    	char size[2];
    	unsigned char serial[4];
    	char cmdsend[2];
    	char unkown1;
    	char artid[4];
    	char unkown2;
    	unsigned char posx[4];
    	char unkown3;
    	unsigned char posy[4];
    	char unkown4;
    };    
    
    HINSTANCE DLLInst = NULL;
    BOOL Inited = FALSE;
    POINT Center;
    unsigned int Pserial;
    
              
    BOOL APIENTRY DllMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID lpvReserved)
    {
        switch(fdwReason)
        {
            case DLL_PROCESS_ATTACH:
    		{
    			DisableThreadLibraryCalls(hDLLInst);
    			DLLInst = hDLLInst;
    		}break;
            case DLL_PROCESS_DETACH:
    		{
    			/* to make sure the dll wasn't simply loaded and InitPlugin() wasnt called */
    			if(Inited == TRUE)
    				UnloadPlugin();
    		}break;
            case DLL_THREAD_ATTACH:		break;
            case DLL_THREAD_DETACH:		break;
        }
        return TRUE;
    }
    
    
    int InitPlugin(void)
    {
    	if(Inited == TRUE)
    		return FALSE;
    
    	Inited = TRUE;
    	
    	AddCommand("print", Command_Print);
    	AddCommand("place", Command_Place);
    	AddCommand("makechar", MakeChar);
    	AddCommand("printabove", Command_PrintAbove);
    	AddCommand("center", Command_center);
    
    	return TRUE;
    }
    
    void UnloadPlugin(void)
    {
    	if(Inited == FALSE)
    		return;	
    
    	return;
    }
    void Command_center(char **Arg, int ArgCount)
    {
    
    
    Center.x = ArgToInt(Arg[1]);
    Center.y = ArgToInt(Arg[2]);
    Pserial = GetPlayerSerial();
    ClientPrint("%s %d", "Player X ",Center.x);
    ClientPrint("%s %d", "Player Y ",Center.y);
    ClientPrint("%s %i", "Player Serial ",Pserial);
    }
    void MakeChar()
    {
    		
    	CreateThread(
    					NULL,  
    					NULL,                        
    					(LPTHREAD_START_ROUTINE ) &TempThread,     
    					NULL,          
    					NULL,									
    					NULL
    					);
    	
    }
    void TempThread()
    {
    
    unsigned char MakeChar[104] = {0x00 ,0xED ,0xED ,0xED ,0xED ,0xFF ,0xFF ,0xFF ,0xFF ,0x00 ,0x31 ,0x32 ,0x68 ,0x79 ,0x6D ,0x33,   
    							  0x35,0x00,0x72,0x00 ,0x00 ,0x00 ,0x00 ,0x00  ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,  
    							  0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00  ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x0F ,0x00 ,0x00,   
    							  0x00 ,0x01 ,0x00 ,0x00 ,0x01 ,0x53 ,0x00 ,0x00  ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,  
    							  0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x22  ,0x24 ,0x0A ,0x2A ,0x32 ,0x11 ,0x32 ,0x00 ,0x00,   
    							  0x03 ,0xEA ,0x20 ,0x44 ,0x04 ,0x4E ,0x20 ,0x4D ,0x04 ,0x4E ,0x00 ,0x03 ,0x00 ,0x00 ,0x00 ,0x01,   
    							  0xC0 ,0xA8 ,0x01 ,0x66 ,0x00 ,0xDF ,0x03 ,0x54 };
    int i;
    for(i =0;i<15;i++)
    {
    Sleep(1000);
    ClientPrint("%s %d", "Hi ",i);
    }
    	SendToServer(MakeChar,104);
    
    }
    void GetPluginInfo(char *Text, int Size)
    {
    	strncpy(Text, "Print Plugin by Boydon", Size);
    	return;
    }
    
    
    void Command_Print(char **Arg, int ArgCount)
    {
    	if(ArgCount<2)
    	{
    		ClientPrint("Usage: print <text> [color] [font]");
    		return;
    	}
    	if(ArgCount==2)
    		ClientPrint("%s", Arg[1]);
    	
    	if(ArgCount==3)
    		//ClientPrintColor(unsigned short Color, unsigned short Font, char *Text, ...);
    		ClientPrintColor(ArgToInt( Arg[2] ), 3, "%s", Arg[1]);
    	
    	if(ArgCount==4)
    		ClientPrintColor(ArgToInt( Arg[2] ), ArgToInt( Arg[3] ), "%s", Arg[1]);
    	
    	return;
    }
    
    void Command_PrintAbove(char **Arg, int ArgCount)
    {
    	if(ArgCount<2)
    	{
    		ClientPrint("Usage: printabove <text> [color] [font]");
    		return;
    	}
    	if(ArgCount==2)
    		ClientPrintAbove(GetPlayerSerial(), "%s", Arg[1]);
    	
    	if(ArgCount==3)
    		//void ClientPrintAboveColor(unsigned int Serial, unsigned short Color, unsigned short Font, char *Text, ...);
    		ClientPrintAboveColor(GetPlayerSerial(), ArgToInt( Arg[2] ), 3, "%s", Arg[1]);
    	
    	if(ArgCount==4)
    		ClientPrintAboveColor(GetPlayerSerial(), ArgToInt( Arg[2] ), ArgToInt( Arg[3] ), "%s", Arg[1]);
    	
    	return;
    }
    
    void Command_Place(char **Arg, int ArgCount)
    {
    POINT PLocal;
    POINT HLocal;
    char OverflowHue[25] = {0};
    stHouseItem HouseItem = {0};
    
    PLocal.x = ArgToInt(Arg[1]);
    PLocal.y = ArgToInt(Arg[2]);
    
    HLocal.x = PLocal.x - Center.x;
    HLocal.y = PLocal.y - Center.y;
    
    
    ClientPrint("%s %d", "HOUSE X ",HLocal.x);
    ClientPrint("%s %i", "HOUSE Y ",HLocal.y);
    
    HouseItem.cmd = 0xD7;
    HouseItem.size[1] = 0x19;
    HouseItem.serial[2] = 0x15;
    HouseItem.serial[3] = 0xC9;
    HouseItem.cmdsend[1] = 0x06;
    HouseItem.artid[2] = 0x05;
    HouseItem.artid[3] = 0x22;
    HouseItem.posx[3] = char(9);
    HouseItem.posy[3] = char(-3);
    HouseItem.unkown4 = 0x0A;
    memcpy(OverflowHue,&HouseItem,sizeof(OverflowHue));
    SendToServer(OverflowHue,25);
    }

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Code:
    > stHouseItem HouseItem = {0};
    This is C, you need to say
    struct stHouseItem HouseItem = {0};
    
    or make it a typedef as well.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  9. #9
    ---
    Join Date
    May 2004
    Posts
    1,379
    POINT is standard I believe due to the fact I have no definition for it and it compiles
    But it isn't compiling!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  2. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM
  3. using c++ in c code
    By hannibar in forum C Programming
    Replies: 17
    Last Post: 10-28-2005, 09:09 PM
  4. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 04:49 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM