.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Bot Coding (http://forums.bots-united.com/forumdisplay.php?f=24)
-   -   Metamod: setting player health (http://forums.bots-united.com/showthread.php?t=724)

InternetNightmare 12-02-2004 20:30

Metamod: setting player health
 
Hello!
Well I'm coding a MetaMOD plugin and hmmm... I don't know how to set health or armor... Well it's easy to do it with AMX, but I want my MOD to be "AMX-free" :) Help!
:)


InternetNightmare
(someone who wants to know everythings in the world! Really!)

InternetNightmare 12-02-2004 21:01

Re: Metamod: setting player health
 
Oh! Its pent->v.health==200;
:)

Austin 13-02-2004 04:38

Re: Metamod: setting player health
 
1) make sure you also set max_health or it may ignore your changes.

2) Be sure to do this inSpawm_post.
If you try it in Spawn() your changes will be overwritten.
Here is a little code that maxes out the health of the hostages.


int Spawn_post(edict_t *pent)
{
// are we spawning a hostage ?
if (strcmp (STRING (pent->v.classname), "hostage_entity") == 0)
{
// Max out the health of the hostages
pent->v.max_health = 0x0FFFFFFF;
pent->v.health = 0x0FFFFFFF;
}
RETURN_META_VALUE (MRES_IGNORED, 0);
}

Pierre-Marie Baty 13-02-2004 14:13

Re: Metamod: setting player health
 
As Austin says, unless setting the health or armor at spawn time, the problem with forcing a player's health or armor server-side without notifying the client of the changes is that the client's data will be wrong compared to the server's. This can lead to bizarre behaviour, such as the client believing the player is dead, and starting playing the death animation, then receiving an update from the server telling it that this player is still moving and shooting stuff. You will then see a wandering corpse farting bullets. :D

When you set the health or armor of a client arbitrarily, don't forget to send him a "Health" or "Armor" network message. The shape of such messages is generally standard between all MODs.

InternetNightmare 13-02-2004 17:53

Re: Metamod: setting player health
 
I will have to read about messages... If you know some good links, feel free to tell... :)

Pierre-Marie Baty 13-02-2004 18:28

Re: Metamod: setting player health
 
The functions in the game DLL to engine interface that are used for sending network messages are:

pfnMessageBegin()
pfnWriteByte()
pfnWriteString()
pfnWriteAnythingTheCrapElseOrWhateverAndTheLikes()
pfnMessageEnd()

Every message must begin with a call to pfnMessageBegin() - or the MESSAGE_BEGIN macro - and end with a call to MESSAGE_END. These functions tell the engine to build a header and a footer for the message before and after sending bytes on the wire. Then, according to the syntax of the message, you either send a byte, a string, a float, whatever, provided it's shaped like a genuine game message so that the client, at the other end of the wire, will understand it. To learn about the syntax of the different network messages, look for examples of them through the SDK.


BTW. I believe there's a typo in your signature ;)

InternetNightmare 13-02-2004 19:02

Re: Metamod: setting player health
 
Pierre-Marie Baty thanks!
Oh yes there is! Thanks! And now I have to get the list of messages... :)

Onno Kreuzinger 13-02-2004 19:38

Re: Metamod: setting player health
 
oh i though he came from barain (ouch that would have had an extra h in)


All times are GMT +2. The time now is 17:41.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.