Solved Problems using buttons in the system

Welcome to our Community
Wanting to join the rest of our members? Feel free to sign up today.
Sign up
Status
Not open for further replies.

unlimitzflyff

Member
Registered
Joined
Jul 19, 2024
Messages
48
Reaction score
19
Points
8
#ifdef __DEATH_ZONE
BOOL CMover::IsDeathZoneTarget(CMover* pMover)
{
CWorld* pWorld = GetWorld();
if (pWorld && pWorld->IsDeathZone())
{
if (IsRegionAttr(RA_SAFETY) || IsRegionAttr(RA_COLLECTING))
{
return FALSE;
}

if (GetAsyncKeyState(VK_CONTROL) & 0x8000)
{
return TRUE;
}
return FALSE;
}
return FALSE;
}
#endif

This is the system I'm learning to write. It's pvp in the exception map, in safezone and collecting. Of course it works fine.

Until I added the condition to press Ctrl before killing.

But of course it works fine on my computer.

After I run the server on my personal server

And enter the game through my own pc

The damage disappears after I press Ctrl and attack other players.
 
Solution
Everything from the post statements to the inherited 'ifs' are a bit confusing, but I'm going to assume it's a translation issue.

Your code is theoretically correct, but for GetAsyncKeyState to correctly return what you expect, it needs to be run on the Client side only . The server has no way of knowing whether a key is pressed or not unless you create and send a packet to inform it.

Without sending a extra packect , Maybe something like this can works:
Hey There!
Please login and(or) register to see this awesome content today.
Everything from the post statements to the inherited 'ifs' are a bit confusing, but I'm going to assume it's a translation issue.

Your code is theoretically correct, but for GetAsyncKeyState to correctly return what you expect, it needs to be run on the Client side only . The server has no way of knowing whether a key is pressed or not unless you create and send a packet to inform it.

Without sending a extra packect , Maybe something like this can works:
Hey There!
Please login and(or) register to see this awesome content today.
 
Last edited:
  • Like
Reactions: unlimitzflyff
Solution
Everything from the post statements to the inherited 'ifs' are a bit confusing, but I'm going to assume it's a translation issue.

Your code is theoretically correct, but for GetAsyncKeyState to correctly return what you expect, it needs to be run on the Client side only . The server has no way of knowing whether a key is pressed or not unless you create and send a packet to inform it.

Without sending a extra packect , Maybe something like this can works:
Hey There!
Please login and(or) register to see this awesome content today.
thank you very much It works well I didn't think I needed to write the client side either. Thanks for the knowledge.

The code has been slightly edited. to be compatible

return GetAsyncKeyState(VK_CONTROL) & 0x8000); to return GetAsyncKeyState(VK_CONTROL) & 0x8000;
 
thank you very much It works well I didn't think I needed to write the client side either. Thanks for the knowledge.

The code has been slightly edited. to be compatible

return GetAsyncKeyState(VK_CONTROL) & 0x8000); to return GetAsyncKeyState(VK_CONTROL) & 0x8000;
Thanks, I edited my post to correct that typo.
 
Status
Not open for further replies.