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

Dark_Knight

Me, me and me.
Друг
4,078
2,095
PHP:
#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS

#include <windows.h>
#include <string>
#include <assert.h>
#include <process.h>

#include "SAMPFUNCS_API.h"
#include "game_api\game_api.h"

SAMPFUNCS *SF = new SAMPFUNCS();
FILE *f1;
stFontInfo *pFont;
char fs, fp, gna[25];
const short int count_arr = 26;
char nick_arr[count_arr][30] = { "Darksoul_Paradise", "Exile_Paradise", "Solid_Paradise",
"Zeref_Paradise", "Raiden_Paradise", "Keef_Grasso", "Peskar Ivanovich", "Sergo_Paradise", "Sergio_Paradise", "Sergio_Lini",
"Neko_Paradise", "Picachy_Paradise", "Funtik_Paradise", "Apollon_Paradise", "Tadjik_Yurarak", "Tadjik_Yraloh", "Kalipso_Saavedra", "Yura_Lini",
"Kalipso_Saavedra", "Snake_Paradise", "Neal_Paradise", "Rentaro_Paradise", "Gleb_Richbeech", "Blood_Hunter", "Elik_Paradise", "Sfgx_Paradise" };
int online_arr[count_arr];
int count_online;
bool zaa;




bool CALLBACK incomingRPC(stRakNetHookParams *params)

{

    if (params->packetId == ScriptRPCEnumeration::RPC_ScrServerJoin)
    {
        short int sPlayerID;
        D3DCOLOR D3DPlayerColor;
        byte isNPC, nameLen;
        char szPlayerName[26];



        params->bitStream->ResetReadPointer();
        params->bitStream->Read(sPlayerID); // ID игрока
        params->bitStream->Read(D3DPlayerColor); // цвет ника
        params->bitStream->Read(isNPC); //  NPC это или нет.
        params->bitStream->Read(nameLen); // длина ника
        params->bitStream->Read(szPlayerName, nameLen); // ник
        szPlayerName[nameLen] = '\0'; //
        params->bitStream->ResetReadPointer();
        for (int ind = 0; ind < 26; ind++)
        {
            if (strcmp(szPlayerName, nick_arr[ind]) == 0)
            {
                SF->getSAMP()->getChat()->AddChatMessage(-1, "{CD853F}[Paradise Family] | {00868B}В сети: %s", szPlayerName, sPlayerID);
                online_arr[count_online] = sPlayerID;
                count_online++;
            }
        }



    }

    return true;
}



bool CALLBACK Present(CONST RECT pSourceRect, CONST RECT pDestRect, HWND hDestWindowOverride,
    CONST RGNDATA *pDirtyRegion)
{
    if (SUCCEEDED(SF->getRender()->BeginRender()) && zaa == true)
    {


        char buff[256];
        char rend_onl[1024];
        rend_onl[0] = '\0';
        if (count_online == 0)
        {
            sprintf(buff, "{CD853F}[Paradise Family]");
            sprintf(rend_onl, "{CD853F}[Paradise Family] {a52a2a}Членов семьи нету online.");
            //pFont->Print(rend_onl, D3DCOLOR_ARGB(255, 255, 255, 0), 10, 260, false);
        }
        else
        {
            for (int ind = 0; ind < count_online; ind++)
            {
                sprintf(buff, "{CD853F}[Paradise Family]");
                sprintf(rend_onl, "%s%s[%d]\n", rend_onl, SF->getSAMP()->getPlayers()->GetPlayerName(online_arr[ind]), online_arr[ind]);
                rend_onl[strlen(rend_onl)] = '\0';
            }


        }
        pFont->Print(rend_onl, D3DCOLOR_ARGB(255, 255, 255, 0), 10, 260, false);
        pFont->Print(buff, D3DCOLOR_ARGB(255, 255, 255, 0), 10, 220, false);
        SF->getRender()->EndRender();

    }
    return true;
};


void CALLBACK cmd_show_info_player(std::string param)

{



    zaa ^= true;

}




void CALLBACK mainloop()
{
    static bool init = false;
    if (!init)
    {
        if (GAME == nullptr)
            return;
        if (GAME->GetSystemState() != eSystemState::GS_PLAYING_GAME)
            return;


        if (!SF->getSAMP()->IsInitialized())
            return;


        SF->getRender()->registerD3DCallback(eDirect3DDeviceMethods::D3DMETHOD_PRESENT, Present);
        SF->getRakNet()->registerRakNetCallback(RakNetScriptHookType::RAKHOOK_TYPE_INCOMING_RPC, incomingRPC);
        SF->getSAMP()->registerChatCommand("fam", cmd_show_info_player);
        pFont = SF->getRender()->CreateNewFont("Arial", 10, FCR_BORDER);
        f1 = fopen("file.txt", "r"); init = true;
 
    for (int fi = 0; fi<20; fi++)
        {
            fgets(gna, 25, f1);
            fs = gna;

            fp = strstr(fs, " \n");
            if (fp == NULL)
                fp = strchr(fs, '\n');
            if (fp != NULL)
                strncat(ign_nm[fi], fs, strlen(fs) - strlen(fp));
            else
                strcat(ign_nm[fi], fs);
            if (feof(f1))
                break;
        }
        fclose(f1);
        delete f1, fs, fp;
 
    }
}

BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved)
{
    switch (dwReasonForCall)
    {
    case DLL_PROCESS_ATTACH:
        SF->initPlugin(mainloop, hModule);
        break;
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
    case DLL_PROCESS_DETACH:
        break;
    }
    return TRUE;
}

Почему подчеркнуты красным strstr, ign_mm, fs и fp
Код:
#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS

#include <windows.h>
#include <string>
#include <assert.h>
#include <process.h>
#include <vector>
#include <fstream>;

#include "SAMPFUNCS_API.h"
#include "game_api\game_api.h"

SAMPFUNCS *SF = new SAMPFUNCS();
stFontInfo *pFont;
stPlayerPool *players;
//---------------------
bool render;
//---------------------

std::vector <std::string> FamNicks = { "Darksoul_Paradise", "Exile_Paradise", "Solid_Paradise",
"Zeref_Paradise", "Raiden_Paradise", "Keef_Grasso", "Peskar Ivanovich", "Sergo_Paradise", "Sergio_Paradise", "Sergio_Lini",
"Neko_Paradise", "Picachy_Paradise", "Funtik_Paradise", "Apollon_Paradise", "Tadjik_Yurarak", "Tadjik_Yraloh", "Kalipso_Saavedra", "Yura_Lini",
"Kalipso_Saavedra", "Snake_Paradise", "Neal_Paradise", "Rentaro_Paradise", "Gleb_Richbeech", "Blood_Hunter", "Elik_Paradise", "Sfgx_Paradise" };
float fHeight;

bool FindNickFamily(std::string nick){
    for (auto &iter : FamNicks)
    {
        if (iter == nick)
            return true;
    }
    return false;
}


bool CALLBACK Present(CONST RECT pSourceRect, CONST RECT pDestRect, HWND hDestWindowOverride,
    CONST RGNDATA *pDirtyRegion)
{
    if (render && SUCCEEDED(SF->getRender()->BeginRender()))
    {
        int count = 0;
        for (int i = 0; i < SAMP_MAX_ACTORS; i++){
            if (players->IsPlayerDefined(i, false)){
                const char *name = players->GetPlayerName(i);
                if (FindNickFamily(name)){
                    count++;
                    if (count == 0)
                    {
                        pFont->Print("{CD853F}[Paradise Family]\n{a52a2a}Членов семьи нету online.", -1, 10, 260, false);
                    }
                    else
                    {
                        pFont->Print("{CD853F}[Paradise Family]", -1, 10, 260, false);
                        pFont->Print(name, -1, 10, 260 + fHeight + fHeight*i, false, false);
                    }
                }
            }
        }
        SF->getRender()->EndRender();
    }
    return true;
};


void CALLBACK cmd_show_info_player(std::string param){
    render != render;
}


void CALLBACK mainloop()
{
    static bool init = false;
    if (!init)
    {
        if (GAME == nullptr)
            return;
        if (GAME->GetSystemState() != eSystemState::GS_PLAYING_GAME)
            return;
        if (!SF->getSAMP()->IsInitialized())
            return;
        SF->getRender()->registerD3DCallback(eDirect3DDeviceMethods::D3DMETHOD_PRESENT, Present);
        SF->getSAMP()->registerChatCommand("fam", cmd_show_info_player);
        pFont = SF->getRender()->CreateNewFont("Arial", 10, FCR_BORDER);
        players = SF->getSAMP()->getPlayers();
        fHeight = pFont->DrawHeight();
        init = true;
    }
}

BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved)
{
    switch (dwReasonForCall)
    {
    case DLL_PROCESS_ATTACH:
        SF->initPlugin(mainloop, hModule);
        break;
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
    case DLL_PROCESS_DETACH:
        break;
    }
    return TRUE;
}
 

return

Новичок
82
5
Как правильно записать?
А то компилятор ругается.
C++:
vehicle_info *vehinfo = SF->getSAMP()->getVehicles()->GetSAMPVehicleIDFromGTAHandle(411);
 

leonard228

Новичок
35
1
ребят скинте кто нибудь стрелку вверх которая на кнопке 6 у вас а то у меня ее нету
 

return

Новичок
82
5
Да эт я тут не правильно написал, я туда передаю инт с хендлом.

Ошибку выдаёт, невозможно преобразовать "int" в "vehicle_info *
 

FordeD

Участник
98
11
Запихни весь код команды в трай кетч и и отлогируй че выдает
try
{
char buf[128];
//code
}
catch(std::extension &e) {//Точно название не помню. Найдешь сам.
SF->Log(e.what());
}

invalid stoi argument ...
Вот где он может быть тут ?

C++:
CVector fPos = { 12.0, 13.2 , 0.0 };
GAME->Get3DMarkers()->CreateMarker(square, MARKER3D_TUBE, &fPos, 40.0, 1.0, 3, 52, 227, 255);
 

Dark_Knight

Me, me and me.
Друг
4,078
2,095
Я же тебе это описал же
char square = std::stoi(param); // Возвращает число, а не буквы. Так же, если в строке будут буквы вызовит краш.
 

return

Новичок
82
5
Ошибку выдаёт, невозможно преобразовать "int" в "vehicle_info *
Как это исправить?
C++:
void CALLBACK cmd_takecar(std::string param)
{
    if ( param.empty() ) return;
    int    iParam = std::stoi( param );

    int vehid = SF->getSAMP()->getPlayers()->GetActorHandleFromSAMPPlayerID(iParam);
    struct vehicle_info *vehinfo = SF->getSAMP()->getVehicles()->GetSAMPVehicleIDFromGTAHandle(vehid);
    if(vehinfo)
    {
        SF->getSAMP()->sendEnterVehicle(vehid, 0);
        GTAfunc_PutActorInCar(vehinfo);
        GAME->GetCamera()->RestoreWithJumpCut();
    }
}