absolutely noob question

good day

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
bool __stdcall cs_aim::cs_aim ( usercmd_s *cmd )
{
    cl_entity_s *ent;
    float flDistance = 32;
    int iEntity;
    pmtrace_t gVis;
    vec3_t vForward, vecEnd;

    gEngfuncs.pfnAngleVectors ( gClient.flAimAngles, vForward, NULL, NULL );

    for ( int iCount = 1; iCount <= 2; iCount++ )
    {
        vecEnd[0] = gClient.flEyePos[0] + vForward[0] * flDistance;
        vecEnd[1] = gClient.flEyePos[1] + vForward[1] * flDistance;
        vecEnd[2] = gClient.flEyePos[2] + vForward[2] * flDistance;

        gEngfuncs.pEventAPI->EV_SetTraceHull ( 2 );
        gEngfuncs.pEventAPI->EV_PlayerTrace ( gClient.flEyePos, vecEnd, PM_STUDIO_BOX, -1, &gVis );

        iEntity = gEngfuncs.pEventAPI->EV_IndexFromTrace ( &gVis );

        ent = gEngfuncs.GetEntityByIndex ( iEntity );
                
        if ( ent->player )
        {
            if ( Aimbot.bIsEnemy ( iEntity ) )
            {
                if ( iCount == 1 )
                {
                    cmd->buttons |= IN_ATTACK2;

                    return true;
                }
                else if ( iCount == 2 )
                {
                    cmd->buttons |= IN_ATTACK;

                    return true;
                }
            }
            else
            {
                if ( iCount == 2 )
                    return false;
            }
        }
        else
        {
            if ( iCount == 2 )
                return false;
        }

        flDistance += 16.0f;
    }

    return false;
}


this code is supposed to become a pluggin for a game, and it is supposed to be correct. so I downloaded cfree and started to compile it, but it gave an error in every line. when I asked why is it happens like this, people said: read some books. but you know it will take years if I don't understand nothing. if you are not interested to work with it, atleast explain what questions are essential for compiling this code. because I got like 30 errors and it was like about ";" , "," ":" signs in this code. I am sure that for advanced c++ programmer this code is ready and is very easy to compile

all the best






Line 1 can't be right:

bool __stdcall cs_aim::cs_aim ( usercmd_s *cmd )

cs_aim::cs_aim says one of two things:

1) This is a constructor for a class named cs_aim, in which case constructors cannot have return values (bool)
2) There is a function named cs_aim in a namespace called cs_aim, in which case you cannot have a
function named the same as a namespace.

Start by fixing this problem and see what errors, if any, remain.
thanks jsmith

I changed it to

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
bool __stdcall CS_Knife_s::bAutoKnife ( usercmd_s *cmd )
{
    cl_entity_s *ent;
    float flDistance = 32;
    int iEntity;
    pmtrace_t gVis;
    vec3_t vForward, vecEnd;

    gEngfuncs.pfnAngleVectors ( gClient.flAimAngles, vForward, NULL, NULL );

    for ( int iCount = 1; iCount <= 2; iCount++ )
    {
        vecEnd[0] = gClient.flEyePos[0] + vForward[0] * flDistance;
        vecEnd[1] = gClient.flEyePos[1] + vForward[1] * flDistance;
        vecEnd[2] = gClient.flEyePos[2] + vForward[2] * flDistance;

        gEngfuncs.pEventAPI->EV_SetTraceHull ( 2 );
        gEngfuncs.pEventAPI->EV_PlayerTrace ( gClient.flEyePos, vecEnd, PM_STUDIO_BOX, -1, &gVis );

        iEntity = gEngfuncs.pEventAPI->EV_IndexFromTrace ( &gVis );

        ent = gEngfuncs.GetEntityByIndex ( iEntity );
                
        if ( ent->player )
        {
            if ( Aimbot.bIsEnemy ( iEntity ) )
            {
                if ( iCount == 1 )
                {
                    cmd->buttons |= IN_ATTACK2;

                    return true;
                }
                else if ( iCount == 2 )
                {
                    cmd->buttons |= IN_ATTACK;

                    return true;
                }
            }
            else
            {
                if ( iCount == 2 )
                    return false;
            }
        }
        else
        {
            if ( iCount == 2 )
                return false;
        }

        flDistance += 16.0f;
    }

    return false;
}


but still got errors

again: ";" "," signs
I can't help any further unless you post the compiler's output. I can only guess
as to which semicolon and comma the compiler is complaining about.

I assume CS_Knife_s is a class or namespace and bAutoKnife is a function
declared in the class or namespace?
I guess bAutoKnife is a name of this code

what is CS_Knife_s I have no idea, perhaps it is a file that is taken from usercmd_s.cmd

or is usercmd_s.cmd is an output file, or is it going to be .exe

I have no idea






1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
bool __stdcall CS_Knife_s::bAutoKnife ( usercmd_s *cmd )
{
	cl_entity_s *ent;
	float flDistance = 32;
	int iEntity;
	pmtrace_t gVis;
	vec3_t vForward, vecEnd;

	gEngfuncs.pfnAngleVectors ( gClient.flAimAngles, vForward, NULL, NULL );

	for ( int iCount = 1; iCount <= 2; iCount++ )
	{
		vecEnd[0] = gClient.flEyePos[0] + vForward[0] * flDistance;
		vecEnd[1] = gClient.flEyePos[1] + vForward[1] * flDistance;
		vecEnd[2] = gClient.flEyePos[2] + vForward[2] * flDistance;

		gEngfuncs.pEventAPI->EV_SetTraceHull ( 2 );
		gEngfuncs.pEventAPI->EV_PlayerTrace ( gClient.flEyePos, vecEnd, PM_STUDIO_BOX, -1, &gVis );

		iEntity = gEngfuncs.pEventAPI->EV_IndexFromTrace ( &gVis );

		ent = gEngfuncs.GetEntityByIndex ( iEntity );
				
		if ( ent->player )
		{
			if ( Aimbot.bIsEnemy ( iEntity ) )
			{
				if ( iCount == 1 )
				{
					cmd->buttons |= IN_ATTACK2;

					return true;
				}
				else if ( iCount == 2 )
				{
					cmd->buttons |= IN_ATTACK;

					return true;
				}
			}
			else
			{
				if ( iCount == 2 )
					return false;
			}
		}
		else
		{
			if ( iCount == 2 )
				return false;
		}

		flDistance += 16.0f;
	}

	return false;
}


--------------------Configuration: mingw2.95 - LIB Debug, Builder Type: MinGW (Old)--------------------

Compiling *\Untitled1.cpp...
[Error] *\Untitled1.cpp:1: syntax error before `::'
[Error] *\Untitled1.cpp:6: syntax error before `;'
[Error] *\Untitled1.cpp:7: syntax error before `,'
[Error] *\Untitled1.cpp:9: syntax error before `.'
[Error] *\Untitled1.cpp:11: syntax error before `<='
[Error] *\Untitled1.cpp:11: syntax error before `++'
[Error] *\Untitled1.cpp:14: ANSI C++ forbids declaration `vecEnd' with no type
[Error] *\Untitled1.cpp:14: `gClient' was not declared in this scope
[Error] *\Untitled1.cpp:14: `vForward' was not declared in this scope
[Error] *\Untitled1.cpp:15: ANSI C++ forbids declaration `vecEnd' with no type
[Error] *\Untitled1.cpp:15: conflicting types for `int vecEnd[2]'
[Error] *\Untitled1.cpp:14: previous declaration as `int vecEnd[1]'
[Error] *\Untitled1.cpp:15: `gClient' was not declared in this scope
[Error] *\Untitled1.cpp:15: `vForward' was not declared in this scope
[Error] *\Untitled1.cpp:17: syntax error before `.'
[Error] *\Untitled1.cpp:18: syntax error before `.'
[Error] *\Untitled1.cpp:20: ANSI C++ forbids declaration `iEntity' with no type
[Error] *\Untitled1.cpp:20: redefinition of `int iEntity'
[Error] *\Untitled1.cpp:5: `int iEntity' previously declared here
[Error] *\Untitled1.cpp:20: `gEngfuncs' was not declared in this scope
[Error] *\Untitled1.cpp:20: `gVis' was not declared in this scope
[Error] *\Untitled1.cpp:22: ANSI C++ forbids declaration `ent' with no type
[Error] *\Untitled1.cpp:22: `gEngfuncs' was not declared in this scope
[Error] *\Untitled1.cpp:24: parse error before `if'
[Error] *\Untitled1.cpp:53: syntax error before `+='

Complete Compile *\Untitled1.cpp: 25 error(s), 0 warning(s)


that is what happens if you put the code in cfree and compile






so you got something on this issue






isn't that a compiler output you was asking
Topic archived. No new replies allowed.