Click here to Skip to main content
15,037,662 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C++
{
    const int MAX_INDEX_WEAPON = 1;
    const int MAX_INDEX_RECOIL = 29;
    int recoilTableY[MAX_INDEX_WEAPON][MAX_INDEX_RECOIL] = {
    { 40, 48, 48, 48, 33, 33, 28, 24, 16, 13, 18, 22, 24, 29, 33, 33, 33, 29, 22, 20, 17, 17, 17, 17, 20, 27, 27, 27, 26 }
    };
    int recoilTableX[MAX_INDEX_WEAPON][MAX_INDEX_RECOIL] = {
    { -36, 5, -59, -49, 3, 20, 25, 45, 43, 32, 82, 8, 43, -32, -25, -40, -35, -32, -43 , -42, -42, -55, -25, 15, 20, 35, 50, 62, 40 }
    };
}
 
bool bRecoilscript = true;
if (bRecoilscript)
{
    intiCount = 0, fireRate  = 134; //Fire rate = 1000 / (RPM / 60). You can find the RPM on Rust Labs
    while (GetAsyncKeyState(1) < 0)
    {
        if (iCount < AssaultRifle::MAX_INDEX_RECOIL)
        {
            mouse_event(1u, AssaultRifle::recoilTableX[0][iCount], AssaultRifle::recoilTableY[0][iCount], 0, 3u);
            if (iCount < AK::MAX_INDEX_RECOIL) iCount++;
        }
        Sleep(fireRate);
    }
}<pre>

What I have tried:

don't know much about coding please help
Posted
Updated 1-Aug-21 19:01pm
v2

You have omitted enough of the code that it is difficult to guess where the problem is. Such as there is probably a namespace AK statement at the top. Otherwise the last if condition is not valid. In addition, intiCount and fireRate are not defined anywhere so they could cause the error. On top of all that none of this code makes sense, such as it is. There has to be an enclosing function scope somewhere to make it valid. The recoil tables can exist externally in the AK namespace but from the bool statement on down has to be within a function or class method.
   
Comments
merano99 2-Aug-21 20:13pm
   
hihi;) intiCount is missing a space: int iCount
Most likely, you don't have a function defined: remove the curly brackets around your data definitions:
C++
{  <<<--- Remove this 
    const int MAX_INDEX_WEAPON = 1;
    const int MAX_INDEX_RECOIL = 29;
    int recoilTableY[MAX_INDEX_WEAPON][MAX_INDEX_RECOIL] = {
    { 40, 48, 48, 48, 33, 33, 28, 24, 16, 13, 18, 22, 24, 29, 33, 33, 33, 29, 22, 20, 17, 17, 17, 17, 20, 27, 27, 27, 26 }
    };
    int recoilTableX[MAX_INDEX_WEAPON][MAX_INDEX_RECOIL] = {
    { -36, 5, -59, -49, 3, 20, 25, 45, 43, 32, 82, 8, 43, -32, -25, -40, -35, -32, -43 , -42, -42, -55, -25, 15, 20, 35, 50, 62, 40 }
    };
}  <<<--- Remove this

And ensure that the rest of the code is inside a function:
C++
void myFunction()
{
    bool bRecoilscript = true;
    if (bRecoilscript)
    {
        intiCount = 0, fireRate  = 134; //Fire rate = 1000 / (RPM / 60). You can find the RPM on Rust Labs
        while (GetAsyncKeyState(1) < 0)
        {
            if (iCount < AssaultRifle::MAX_INDEX_RECOIL)
            {
                mouse_event(1u, AssaultRifle::recoilTableX[0][iCount], AssaultRifle::recoilTableY[0][iCount], 0, 3u);
                if (iCount < AK::MAX_INDEX_RECOIL) iCount++;
            }
            Sleep(fireRate);
        }
    }
}
   
Comments
CPallini 2-Aug-21 2:03am
   
5.
Rick York 2-Aug-21 4:48am
   
Those braces can NOT be removed because they part of one of two name spaces - AK and AssaultRifle. Both are referred to in the code and one is likely to be wrong.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900