HOME FORUMS MEMBERS RECENT POSTS LOG IN  
× Авторизация
Имя пользователя:
Пароль:
Нет аккаунта? Регистрация
Баннер 1   Баннер 2
НОВЫЕ ТОРГОВАЯ НОВОСТИ ЧАТ
loading...
Скрыть
Вернуться   ANTICHAT > ПРОГРАММИРОВАНИЕ > С/С++, C#, Rust, Swift, Go, Java, Perl, Ruby
   
Ответ
 
Опции темы Поиск в этой теме Опции просмотра

  #2801  
Старый 17.08.2018, 12:32
Revalto
Постоянный
Регистрация: 13.02.2016
Сообщений: 532
С нами: 5392682

Репутация: 93


По умолчанию

Цитата:
Сообщение от _=Gigant=_  

sprintf(ctarget_ping_score, "{8cff00}Ping{FFFFFF} %d{007bff} Score{FFFFFF} %d ", g_Players>pRemotePlayer[Informer_Target_PlayerID]>iPing, g_Players->pRemotePlayer[Informer_Target_PlayerID]->iScore);

this code you see should display player ping and score, it does sometimes but not always what's wrong with this ? here you can see that player score and ping is 0 and sometimes it displays correct value idk what's wrong



thanks for help !
Lesson number 1:

Код:





Код:
void CALLBACK cmd_show_info_player( std::string param )
{
   if ( param.empty() ) return;
   int    i = std::stoi( param );

   char buf[128];

   stRemotePlayer *pPlayer = SF->getSAMP()->getPlayers()->pRemotePlayer[ i ];

   if(!pPlayer) return;

   sprintf( buf, "Nickname - %s, Ping - %d, Score - %d, isNPC - %d, AFKState - %d",
       pPlayer->szPlayerName,
       pPlayer->iPing,
       pPlayer->iScore,
       pPlayer->iIsNPC,
       pPlayer->pPlayerData->iAFKState == 2 );

   SF->getSAMP()->getChat()->AddChatMessage( -1, buf );
};

And in Mainloop:
SF->getSAMP()->registerChatCommand( "showinfo", cmd_show_info_player );


Expample for you:

Код:





Код:
stRemotePlayer *pPlayer = SF->getSAMP()->getPlayers()->pRemotePlayer[ Informer_Target_PlayerID ];
if(!pPlayer) return;
sprintf(ctarget_ping_score, "{8cff00}Ping{FFFFFF} %d{007bff} Score{FFFFFF} %d ", pPlayer->iPing, pPlayer->iScore);


What kind of font do you use?
 
Ответить с цитированием

  #2802  
Старый 17.08.2018, 13:44
_=Gigant=_
Участник форума
Регистрация: 19.01.2017
Сообщений: 130
С нами: 4901705

Репутация: 98
По умолчанию

Цитата:
Сообщение от Revalto  

Lesson number 1:

Код:





Код:
void CALLBACK cmd_show_info_player( std::string param )
{
   if ( param.empty() ) return;
   int    i = std::stoi( param );

   char buf[128];

   stRemotePlayer *pPlayer = SF->getSAMP()->getPlayers()->pRemotePlayer[ i ];

   if(!pPlayer) return;

   sprintf( buf, "Nickname - %s, Ping - %d, Score - %d, isNPC - %d, AFKState - %d",
       pPlayer->szPlayerName,
       pPlayer->iPing,
       pPlayer->iScore,
       pPlayer->iIsNPC,
       pPlayer->pPlayerData->iAFKState == 2 );

   SF->getSAMP()->getChat()->AddChatMessage( -1, buf );
};

And in Mainloop:
SF->getSAMP()->registerChatCommand( "showinfo", cmd_show_info_player );


Expample for you:

Код:





Код:
stRemotePlayer *pPlayer = SF->getSAMP()->getPlayers()->pRemotePlayer[ Informer_Target_PlayerID ];
if(!pPlayer) return;
sprintf(ctarget_ping_score, "{8cff00}Ping{FFFFFF} %d{007bff} Score{FFFFFF} %d ", pPlayer->iPing, pPlayer->iScore);


What kind of font do you use?
im using

pD3DFont_sampStuff

CD3DFont *pD3DFont_sampStuff = new CD3DFont( "Tahoma", 10, FCR_BORDER );
 
Ответить с цитированием

  #2803  
Старый 17.08.2018, 13:49
CleanLegend
Постоянный
Регистрация: 28.03.2013
Сообщений: 495
С нами: 6908018

Репутация: 213
По умолчанию

Цитата:
Сообщение от _=Gigant=_  

sprintf(ctarget_ping_score, "{8cff00}Ping{FFFFFF} %d{007bff} Score{FFFFFF} %d ", g_Players>pRemotePlayer[Informer_Target_PlayerID]>iPing, g_Players->pRemotePlayer[Informer_Target_PlayerID]->iScore);

this code you see should display player ping and score, it does sometimes but not always what's wrong with this ? here you can see that player score and ping is 0 and sometimes it displays correct value idk what's wrong



thanks for help !
you need send update scoreboard
 
Ответить с цитированием

  #2804  
Старый 17.08.2018, 15:09
_=Gigant=_
Участник форума
Регистрация: 19.01.2017
Сообщений: 130
С нами: 4901705

Репутация: 98
По умолчанию

Цитата:
Сообщение от CleanLegend  

you need send update scoreboard
how can i do that i took a look at FYP screen info code and i included same stuff as him in that code still ping and score shows 0 here full code

C++:





Код:
void
renderPlayerInfo
(
)
{
traceLastFunc
(
"renderPlayerInfo()"
)
;
if
(
gta_menu_active
(
)
)
return
;
if
(
cheat_state
->
_generic
.
cheat_panic_enabled
)
return
;
if
(
!
g_dwSAMP_Addr
||
!
g_SAMP
||
!
g_Players
)
return
;
// don't run if the CGameSA doesn't exist
if
(
!
pGameInterface
)
return
;
// don't run if we don't exist
if
(
isBadPtr_GTA_pPed
(
pPedSelf
)
)
return
;
if
(
g_Scoreboard
->
iIsEnabled
)
return
;
for
(
int
i
=
0
;
i

base
.
matrix
[
4
*
3
]
;
player_pos
.
x
=
f_pos
[
0
]
;
player_pos
.
y
=
f_pos
[
1
]
;
player_pos
.
z
=
f_pos
[
2
]
;
CalcScreenCoors
(
&
player_pos
,
&
screenposs
)
;
char
pos
[
256
]
,
ping
[
256
]
,
hparmw
[
256
]
,
pnameid
[
256
]
,
skin
[
256
]
;
if
(
screenposs
.
z

iIsListed
[
i
]
!=
1
)
continue
;
stRemotePlayer
*
pPlayer
=
g_SAMP
->
pPools
->
pPlayer
->
pRemotePlayer
[
i
]
;
const
char
*
playerName
=
getPlayerName
(
i
)
;
if
(
Informer
)
{
_snprintf_s
(
pnameid
,
sizeof
(
pnameid
)
-
1
,
"{C235DD}Player{FFFFFF} %s {00FF00} Distance{FFFFFF} %.0f m"
,
playerName
,
i
,
GetDistance
(
D3DXVECTOR3
(
player_pos
.
x
,
player_pos
.
y
,
player_pos
.
z
)
)
)
;
pD3DFont_sampStuff
->
PrintShadow
(
screenposs
.
x
,
screenposs
.
y
-
38
,
COLOR_WHITE
(
255
)
,
pnameid
)
;
_snprintf_s
(
hparmw
,
sizeof
(
hparmw
)
-
1
,
"{FF0F0F}Health{FFFFFF} %0.0f Armour %0.0f{FFA00F} Weapon{FFFFFF} %u"
,
g_Players
->
pRemotePlayer
[
i
]
->
pPlayerData
->
fActorHealth
,
g_Players
->
pRemotePlayer
[
i
]
->
pPlayerData
->
fActorArmor
,
g_Players
->
pRemotePlayer
[
i
]
->
pPlayerData
->
onFootData
.
byteCurrentWeapon
)
;
//, g_Players->pRemotePlayer[i]->szPlayerName, i);
pD3DFont_sampStuff
->
PrintShadow
(
screenposs
.
x
,
screenposs
.
y
-
26
,
COLOR_WHITE
(
255
)
,
hparmw
)
;
_snprintf_s
(
ping
,
sizeof
(
ping
)
-
1
,
"{F0FF0F}Skin{FFFFFF} %d{00FF00} Ping{FFFFFF} %d Score %d"
,
actor
->
base
.
model_alt_id
,
pPlayer
->
iPing
,
pPlayer
->
iScore
)
;
pD3DFont_sampStuff
->
PrintShadow
(
screenposs
.
x
,
screenposs
.
y
-
14
,
COLOR_WHITE
(
255
)
,
ping
)
;
_snprintf_s
(
pos
,
sizeof
(
pos
)
-
1
,
"Pos X %0.02f Y %0.02f Z %0.02f"
,
player_pos
.
x
,
player_pos
.
y
,
player_pos
.
z
)
;
//, g_Players->pRemotePlayer[i]->szPlayerName, i);
pD3DFont_sampStuff
->
PrintShadow
(
screenposs
.
x
,
screenposs
.
y
,
COLOR_WHITE
(
255
)
,
pos
)
;
}
}
}
 
Ответить с цитированием

  #2805  
Старый 17.08.2018, 15:19
ALF
Постоянный
Регистрация: 14.11.2017
Сообщений: 319
С нами: 4472205

Репутация: 163
По умолчанию

Цитата:
Сообщение от _=Gigant=_  

how can i do that i took a look at FYP screen info code and i included same stuff as him in that code still ping and score shows 0 here full code

C++:





Код:
void
renderPlayerInfo
(
)
{
traceLastFunc
(
"renderPlayerInfo()"
)
;
if
(
gta_menu_active
(
)
)
return
;
if
(
cheat_state
->
_generic
.
cheat_panic_enabled
)
return
;
if
(
!
g_dwSAMP_Addr
||
!
g_SAMP
||
!
g_Players
)
return
;
// don't run if the CGameSA doesn't exist
if
(
!
pGameInterface
)
return
;
// don't run if we don't exist
if
(
isBadPtr_GTA_pPed
(
pPedSelf
)
)
return
;
if
(
g_Scoreboard
->
iIsEnabled
)
return
;
for
(
int
i
=
0
;
i

base
.
matrix
[
4
*
3
]
;
player_pos
.
x
=
f_pos
[
0
]
;
player_pos
.
y
=
f_pos
[
1
]
;
player_pos
.
z
=
f_pos
[
2
]
;
CalcScreenCoors
(
&
player_pos
,
&
screenposs
)
;
char
pos
[
256
]
,
ping
[
256
]
,
hparmw
[
256
]
,
pnameid
[
256
]
,
skin
[
256
]
;
if
(
screenposs
.
z

iIsListed
[
i
]
!=
1
)
continue
;
stRemotePlayer
*
pPlayer
=
g_SAMP
->
pPools
->
pPlayer
->
pRemotePlayer
[
i
]
;
const
char
*
playerName
=
getPlayerName
(
i
)
;
if
(
Informer
)
{
_snprintf_s
(
pnameid
,
sizeof
(
pnameid
)
-
1
,
"{C235DD}Player{FFFFFF} %s {00FF00} Distance{FFFFFF} %.0f m"
,
playerName
,
i
,
GetDistance
(
D3DXVECTOR3
(
player_pos
.
x
,
player_pos
.
y
,
player_pos
.
z
)
)
)
;
pD3DFont_sampStuff
->
PrintShadow
(
screenposs
.
x
,
screenposs
.
y
-
38
,
COLOR_WHITE
(
255
)
,
pnameid
)
;
_snprintf_s
(
hparmw
,
sizeof
(
hparmw
)
-
1
,
"{FF0F0F}Health{FFFFFF} %0.0f Armour %0.0f{FFA00F} Weapon{FFFFFF} %u"
,
g_Players
->
pRemotePlayer
[
i
]
->
pPlayerData
->
fActorHealth
,
g_Players
->
pRemotePlayer
[
i
]
->
pPlayerData
->
fActorArmor
,
g_Players
->
pRemotePlayer
[
i
]
->
pPlayerData
->
onFootData
.
byteCurrentWeapon
)
;
//, g_Players->pRemotePlayer[i]->szPlayerName, i);
pD3DFont_sampStuff
->
PrintShadow
(
screenposs
.
x
,
screenposs
.
y
-
26
,
COLOR_WHITE
(
255
)
,
hparmw
)
;
_snprintf_s
(
ping
,
sizeof
(
ping
)
-
1
,
"{F0FF0F}Skin{FFFFFF} %d{00FF00} Ping{FFFFFF} %d Score %d"
,
actor
->
base
.
model_alt_id
,
pPlayer
->
iPing
,
pPlayer
->
iScore
)
;
pD3DFont_sampStuff
->
PrintShadow
(
screenposs
.
x
,
screenposs
.
y
-
14
,
COLOR_WHITE
(
255
)
,
ping
)
;
_snprintf_s
(
pos
,
sizeof
(
pos
)
-
1
,
"Pos X %0.02f Y %0.02f Z %0.02f"
,
player_pos
.
x
,
player_pos
.
y
,
player_pos
.
z
)
;
//, g_Players->pRemotePlayer[i]->szPlayerName, i);
pD3DFont_sampStuff
->
PrintShadow
(
screenposs
.
x
,
screenposs
.
y
,
COLOR_WHITE
(
255
)
,
pos
)
;
}
}
}

BlastHackNet/mod_s0beit_sa(https://github.com/BlastHackNet/mod_s0beit_sa/blob/master/src/samp.cpp#L841)
 
Ответить с цитированием

  #2806  
Старый 17.08.2018, 22:08
_=Gigant=_
Участник форума
Регистрация: 19.01.2017
Сообщений: 130
С нами: 4901705

Репутация: 98
По умолчанию

why this crashing i wanted to automatically exit car when car is about to explode

C++:





Код:
vehicle_info
*
my_veh
=
vehicle_info_get
(
VEHICLE_SELF
,
NULL
)
;
float
*
coord
=
new
float
[
3
]
;
coord
[
0
]
=
pPedSelf
->
GetPosition
(
)
->
fX
;
coord
[
1
]
=
pPedSelf
->
GetPosition
(
)
->
fY
-
2.0f
;
coord
[
2
]
=
pPedSelf
->
GetPosition
(
)
->
fZ
;
if
(
my_veh
->
hitpoints
==
200
)
// if vehicle hp is 200 then exit from car
{
GTAfunc_RemoveActorFromCarAndPutAt
(
coord
)
;
}


thanks for help
 
Ответить с цитированием

  #2807  
Старый 17.08.2018, 22:26
Dark_Knight
Флудер
Регистрация: 18.03.2013
Сообщений: 4,080
С нами: 6921957

Репутация: 183


По умолчанию

C++:





Код:
vehicle_info
*
my_veh
=
vehicle_info_get
(
VEHICLE_SELF
,
NULL
)
;
if
(
my_veh
)
{
float
coord
[
3
]
;
coord
[
0
]
=
pPedSelf
->
GetPosition
(
)
->
fX
;
coord
[
1
]
=
pPedSelf
->
GetPosition
(
)
->
fY
-
2.0f
;
coord
[
2
]
=
pPedSelf
->
GetPosition
(
)
->
fZ
;
if
(
my_veh
->
hitpoints
==
200
)
// if vehicle hp is 200 then exit from car
{
GTAfunc_RemoveActorFromCarAndPutAt
(
&
coord
)
;
}
}
 
Ответить с цитированием

  #2808  
Старый 18.08.2018, 00:25
Revalto
Постоянный
Регистрация: 13.02.2016
Сообщений: 532
С нами: 5392682

Репутация: 93


По умолчанию

Так то оно так, но лучше такую проверку:

Код:





[CODE]
if (my_veh->hitpoints



Ведь у нас не всегда именно 200 хп будет)
 
Ответить с цитированием

  #2809  
Старый 18.08.2018, 02:30
_=Gigant=_
Участник форума
Регистрация: 19.01.2017
Сообщений: 130
С нами: 4901705

Репутация: 98
По умолчанию

how to get player current weapon name, here what i did

Код:





Код:
const struct weapon_entry    *weapon = weapon_list;

            sprintf(ctarget_wep, "{31f8ff}Weapon{FFFFFF} %s{FFFFFF} %u", gta_weapon_get_by_name(weapon->name), g_Players->pRemotePlayer[Target_PlayerID]->pPlayerData->onFootData.byteCurrentWeapon);

const struct weapon_entry    weapon_list[] =
{
    { 0, 0, -1, "Fist" },
    { 1, 0, 331, "Brass Knuckles" },
    { 2, 1, 333, "Golf Club" },
    { 3, 1, 334, "Nitestick" },
    { 4, 1, 335, "Knife" },
    { 5, 1, 336, "Baseball Bat" },
    { 6, 1, 337, "Shovel" },
    { 7, 1, 338, "Pool Cue" },
    { 8, 1, 339, "Katana" },
    { 9, 1, 341, "Chainsaw" },
    { 22, 2, 346, "Pistol" },
    { 23, 2, 347, "Silenced Pistol" },
    { 24, 2, 348, "Desert Eagle" },
    { 25, 3, 349, "Shotgun" },
    { 26, 3, 350, "Sawn-Off Shotgun" },
    { 27, 3, 351, "SPAZ12" },
    { 28, 4, 352, "Micro UZI" },
    { 29, 4, 353, "MP5" },
    { 32, 4, 372, "Tech9" },
    { 30, 5, 355, "AK47" },
    { 31, 5, 356, "M4" },
    { 33, 6, 357, "Country Rifle" },
    { 34, 6, 358, "Sniper Rifle" },
    { 35, 7, 359, "Rocket Launcher" },
    { 36, 7, 360, "Heat Seeking RPG" },
    { 37, 7, 361, "Flame Thrower" },
    { 38, 7, 362, "Minigun" },
    { 16, 8, 342, "Grenade" },
    { 17, 8, 343, "Teargas" },
    { 18, 8, 344, "Molotov Cocktail" },
    { 39, 8, 363, "Remote Explosives" },
    { 41, 9, 365, "Spray Can" },
    { 42, 9, 366, "Fire Extinguisher" },
    { 43, 9, 367, "Camera" },
    { 10, 10, 321, "Dildo 1" },
    { 11, 10, 322, "Dildo 2" },
    { 12, 10, 323, "Vibe 1" },
    { 13, 10, 324, "Vibe 2" },
    { 14, 10, 325, "Flowers" },
    { 15, 10, 326, "Cane" },
    { 44, 11, 368, "NV Goggles" },
    { 45, 11, 369, "IR Goggles" },
    { 46, 11, 371, "Parachute" },
    { 40, 12, 364, "Detonator" },
    { -1, -1, -1, NULL }
};


but this shows
















thanks for help !
 
Ответить с цитированием

  #2810  
Старый 18.08.2018, 03:16
Babayka2016
Познающий
Регистрация: 19.01.2017
Сообщений: 51
С нами: 4901705

Репутация: 98
По умолчанию

Приветствую. Столкнулся с такой проблемой:

К примеру, есть координаты множества чекпоинтов, они расположены хаотично.

Есть координаты машины и поворот персонажа в ней:

Поворот персонажа:

public float Get_Rotation() {

int base_address = mem.ReadInt(0xB6F5F0);

float angel = mem.ReadFloat(base_address + 0x558);

return angel * 6;

}

Координаты машины:

public float[] Get_Car_Coord()

{

float[] Position = new float[2];

int car_offset = mem.ReadInt(0xBA18FC);

int offset_to_matrix_car = mem.ReadInt(car_offset + 0x14);

Position[0] = mem.ReadFloat(offset_to_matrix_car + 0x30);

Position[1] = mem.ReadFloat(offset_to_matrix_car + 0x34);

return Position;

}

Как мне сделать так, чтобы она могла проехать по маршруту чекпоинтов?

Мне нужно как-то взять тот угол, на который она должна повернуться.

Типа... Есть координаты чекпоинта:

x: 1141.513916

y: -1162.998169

И координаты машины:

x: 1162.112061

y: -1199.149658

Как сделать так, чтобы она туда приехала? Как вычислить тот угол, на который она должна повернуть?

Вообще, видел, что реализуют через функцию lua - getHeadingFromVector2d.

Как она вообще устроена? Как её перевести на другой язык, к примеру?

P.S НУЖНО БЕЗ SAMPFUNCS и SAMP LUA.

Заранее спасибо)
 
Ответить с цитированием
Ответ





Здесь присутствуют: 1 (пользователей: 0 , гостей: 1)
 


Быстрый переход




ANTICHAT ™ © 2001- Antichat Kft.