Другое SAMPFUNCS | API C++

Dark_Knight

Me, me and me.
Друг
4,065
2,079
Как правильно юзать таймер, чтобы после нажатия клавиши допустим F8 пошел отсчет, а после 5 секунд произошло какое-нибудь действие.
C++:
static DWORD timer = 0;
void mainloop(){
if{!init}{
}
if(GetTickCount - timer > 5000){
SF->log("Таймер работает раз в 5 секунд");
timer = GetTickCount();
}

}
Пробовал делать так, но он срабатывает сразу и потом каждые 5 секунд
Добавить буллевую переменную
 

CarLCas

Известный
161
118
Как правильно юзать таймер, чтобы после нажатия клавиши допустим F8 пошел отсчет, а после 5 секунд произошло какое-нибудь действие.
C++:
static DWORD timer = 0;
void mainloop(){
if{!init}{
}
if(GetTickCount - timer > 5000){
SF->log("Таймер работает раз в 5 секунд");
timer = GetTickCount();
}

}
Пробовал делать так, но он срабатывает сразу и потом каждые 5 секунд
C++:
static bool init, screen;
static DWORD timer=0;
/*
code
*/
if (SF->getGame()->isKeyPressed(119))//разница KeyDown и KeyPressed, в том что Pressed 1 раз выполнит код когда ты нажмешь на клавишу, а KeyDown всегда пока кнопка нажата
        {
            stServerPresets *setting = SF->getSAMP()->getInfo()->pSettings;
            if (setting->byteNoNametagsBehindWalls == 1)
            {
                setting->byteNoNametagsBehindWalls = 0;
                screen=true;
                timer=GetTickCount();
            }
        }
if ((GetTickCount()-timer>1500) && screen)
{
          stServerPresets *setting = SF->getSAMP()->getInfo()->pSettings;
            if (setting->byteNoNametagsBehindWalls == 0)
            {
                setting->byteNoNametagsBehindWalls = 1;
                screen=false;
            }
}
 
  • Нравится
Реакции: Frixen

Frixen

Известный
131
8
Добрые люди, может у кого есть код аймбота обычного под SF??
 

CarLCas

Известный
161
118
Добрые люди, может у кого есть код аймбота обычного под SF??
Тут не под сф конечно, но работать и в сф плагине будет. Если нужно будет, сам переведешь под сф там не сложно
C++:
#define CAMERA_X    *(float *)0xB6F258



DWORD* pActor = (DWORD*)0xB6F5F0;
            if (*pActor > 0)
            {
                if (GetAsyncKeyState(0x01)) // можешь заменить на  SF->getGame()->isKeyPressed(0x01)
                {
                    DWORD* pTarget = (DWORD*)0xB6F3B8;
                    DWORD* pPed = (DWORD*)((*pTarget) + 0x79C);
                    if (*pPed > 0)
                    {
                        float mult1 = 35.0f;
                        float mult2 = 17.0f;
                        mult2 /= 360.0f;
                        DWORD* vPos = (DWORD*)((*pPed) + 0x14);
                        CVector vecSpeed = *(CVector*)((*pPed) + 0x44);
                        vecSpeed.fX *= mult2;
                        vecSpeed.fY *= mult2;
                        vecSpeed.fZ *= mult2;
                        vecSpeed.fX *= mult1;
                        vecSpeed.fY *= mult1;
                        vecSpeed.fZ *= mult1;
                        CVector vecPos;
                        vecPos.fX = *(float*)(*vPos + 0x30);
                        vecPos.fY = *(float*)(*vPos + 0x34);
                        vecPos.fZ = *(float*)(*vPos + 0x38);
                        vecPos.fX += vecSpeed.fX;
                        vecPos.fY += vecSpeed.fY;
                        vecPos.fZ += vecSpeed.fZ;
                        CVector newVecPos = vecPos;
                        CVector vecCameraPos;
                        vecCameraPos.fX = *(float*)(0xB6F9CC);
                        vecCameraPos.fY = *(float*)(0xB6F9D0);
                        vecCameraPos.fZ = *(float*)(0xB6F9D4);
                        CVector newVecOrigin;
                        DWORD* vPos2 = (DWORD*)((*pActor) + 0x14);
                        newVecOrigin.fX = *(float*)(*vPos2 + 0x30);
                        newVecOrigin.fY = *(float*)(*vPos2 + 0x34);
                        newVecOrigin.fZ = *(float*)(*vPos2 + 0x38);
                        vecCameraPos.fX -= newVecPos.fX;
                        vecCameraPos.fY -= newVecPos.fY;
                        if (vecCameraPos.fX < 0.0f) vecCameraPos.fX = -vecCameraPos.fX;
                        if (vecCameraPos.fY < 0.0f) vecCameraPos.fY = -vecCameraPos.fY;
                        float camerax = vecCameraPos.fX;
                        float cameray = vecCameraPos.fY;
                        camerax *= camerax;
                        cameray *= cameray;
                        camerax += cameray;
                        camerax = sqrt(camerax);
                        cameray = vecCameraPos.fX;
                        float ccamx = camerax;
                        cameray /= ccamx;
                        ccamx = asinf(cameray);
                        float ccamy = acosf(cameray);

                        byte weapon_slot = *(byte*)(*pActor + 0x718);
                        if (weapon_slot != 2 && weapon_slot != 3 && weapon_slot != 4 && weapon_slot != 5
                            && weapon_slot != 6 && weapon_slot != 7)
                            ;
                        else
                        {
                            float cam_x;
                            float unk7[4];
                            if (weapon_slot == 5)
                            {
                                unk7[0] = 0.01f;
                                unk7[1] = 0.01f;
                                unk7[2] = 1.5607f;
                                unk7[3] = 1.5807f;
                            }
                            else if (weapon_slot == 6)
                            {
                                unk7[0] = 0.018f;
                                unk7[1] = 0.02f;
                                unk7[2] = 1.5507f;
                                unk7[3] = 1.5907f;
                            }
                            else
                            {
                                unk7[0] = 0.0f;
                                unk7[1] = 0.0f;
                                unk7[2] = 1.5707f;
                                unk7[3] = 1.5707f;
                            }
                            if (newVecOrigin.fX > newVecPos.fX && newVecOrigin.fY > newVecPos.fY)
                            {
                                ccamy -= unk7[1];
                                cam_x = ccamy;
                            }
                            else if (newVecOrigin.fX > newVecPos.fX && newVecOrigin.fY < newVecPos.fY)
                            {
                                ccamy *= -1.0f;
                                ccamy -= unk7[0];
                                cam_x = ccamy;
                            }
                            else if (newVecOrigin.fX < newVecPos.fX && newVecOrigin.fY > newVecPos.fY)
                            {
                                ccamx += unk7[2];
                                cam_x = ccamx;
                            }
                            else if (newVecOrigin.fX < newVecPos.fX && newVecOrigin.fY < newVecPos.fY)
                            {
                                ccamx *= -1.0f;
                                ccamx -= unk7[3];
                                cam_x = ccamx;
                            }
                            float cam_xx = CAMERA_X;
                            cam_xx -= cam_x;
                            if (cam_xx < 0.18f && cam_xx > -0.18f)
                            {
                                cam_x += 0.0389f;
                                CAMERA_X = cam_x;
                            }
                        }
                    }
                }
            }
 

Frixen

Известный
131
8
В собейте получение камеры выглядит следующим образом:
C++:
            // get the camera
            CCamera *pCamera = pGame->GetCamera();

            // grab the active cam
            CCamSAInterface *pCam = (CCamSAInterface *)((CCamSA *)pCamera->GetCam(pCamera->GetActiveCam()))->GetInterface();
Как это будет выглядеть в SF API
 

Frixen

Известный
131
8
0BAF: samp 6@ = get_input_info_ptr
0C0C: 6@ = struct 6@ offset {pDXUTEditBox}0x8 size 4
0C0C: 10@ = struct 6@ offset {dwPosChatInput1}0x8 size 4 // X
0C0C: 11@ = struct 6@ offset {dwPosChatInput2}0xC size 4 // Y
через callopcode это можно реализовать?
 

itsLegend

Фонд борьбы за жуков 🐞
Администратор
2,696
1,460
Перед этим память выдели только.