
17.08.2018, 01:20
|
|
Участник форума
Регистрация: 19.01.2017
Сообщений: 130
С нами:
4901705
Репутация:
98
|
|
Сообщение от Revalto
Код:
Код:
float GetDistance(D3DXVECTOR3 target)
{
D3DXVECTOR3 player(PEDSELF->GetPosition()->fX, PEDSELF->GetPosition()->fY, PEDSELF->GetPosition()->fZ);
return sqrt((player.x - target.x) * (player.x - target.x) + (player.y - target.y) * (player.y - target.y) + (player.z - target.z) * (player.z - target.z));
}
Example:
Код:
Код:
sprintf(szMsg, "%.0f m.", GetDistance(D3DXVECTOR3(x, y, z)));
thank you very much !
here is the full code if someone need
float GetDistance(D3DXVECTOR3 target)
{
actor_info * playerR = actor_info_get(ACTOR_SELF, NULL);
CPed *pPedSelf = pGameInterface->GetPools()->GetPed((DWORD*)playerR);
D3DXVECTOR3 player(pPedSelf->GetPosition()->fX, pPedSelf->GetPosition()->fY, pPedSelf->GetPosition()->fZ);
return sqrt((player.x - target.x) * (player.x - target.x) + (player.y - target.y) * (player.y - target.y) + (player.z - target.z) * (player.z - target.z));
}
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 !
|
|
|

17.08.2018, 12:32
|
|
Постоянный
Регистрация: 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?
|
|
|

17.08.2018, 13:44
|
|
Участник форума
Регистрация: 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 );
|
|
|

17.08.2018, 13:49
|
|
Постоянный
Регистрация: 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
|
|
|

17.08.2018, 15:09
|
|
Участник форума
Регистрация: 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
)
;
}
}
}
|
|
|

17.08.2018, 15:19
|
|
Постоянный
Регистрация: 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)
|
|
|

17.08.2018, 22:08
|
|
Участник форума
Регистрация: 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
|
|
|

17.08.2018, 22:26
|
|
Флудер
Регистрация: 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
)
;
}
}
|
|
|

18.08.2018, 00:25
|
|
Постоянный
Регистрация: 13.02.2016
Сообщений: 532
С нами:
5392682
Репутация:
93
|
|
Так то оно так, но лучше такую проверку:
Код:
[CODE]
if (my_veh->hitpoints
Ведь у нас не всегда именно 200 хп будет)
|
|
|

18.08.2018, 02:30
|
|
Участник форума
Регистрация: 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 !
|
|
|
|
 |
|
|
Здесь присутствуют: 1 (пользователей: 0 , гостей: 1)
|
|
|
|