PDA

View Full Version : Health System


Knightmare1
02-09-2008, 05:47 AM
im creating a health system for my server, and i was wondering, how do you make sure that when you damage a player that you can tell you killed them. this is what i have so far. I only spent a couple of minutes, and i was wondering, can anyone help me? i am not to good at scripting. and the server is gonna have a ranking system ( like ranks for each class. ) and class system. im still working on everything, because i have no staff xD

function onActionServerSide()
{
if (params[0] == "hurt")
{
clientr.hp -= clientr.weapon_damage;
}
elseif (params[0] == "dead")
{
clientr.hp = 0;
clientr.deaths += 1;
}
elseif (params[0] == "kill")
{
[email protected] += 1;
clientr.exp += 4;
clientr.message = "You have killed " @temp.player_hit;
}
elseif (params[0] == "revive")
{
clientr.hp = clientr.hp_max;
setlevel2("final_osl.nw", 30, 30);
}
}

//#CLIENTSIDE
function onCreated()
{
clientr.hp = 100;
clientr.hp_max = 100;
clientr.deaths = 0;
clientr.kills = 0;
setTimer( 0.05 );
}

oo_jazz_oo
02-09-2008, 05:51 AM
Well, you could just do
if (params[0] == "hurt")
{
clientr.hp -= clientr.weapon_damage;
if (clientr.hp <= 0)
{
clientr.dead = 1;
clientr.deaths += 1;
}
}
And have a timeout check for clientr.dead in the clientside part of the script, and if it equals 1, then freeze the player or w/e for when hes dead.
And btw, you need to set the clientr. flags serverside.

Edit: I worded it wrong, sorry

Knightmare1
02-09-2008, 03:13 PM
Jazz, i meant how do i find the player whos im attacking. like if i attack some player, how would i make them get hurt.
this is what i have so far:
function onActionServerSide()
{
if (params[0] == "hurt")
{
clientr.hp -= temp.player.clientr.weapon_damage;
}
elseif (params[0] == "dead")
{
clientr.hp = 0;
clientr.dead = 1;
clientr.deaths += 1;
}
elseif (params[0] == "kill")
{
[email protected] += 1;
clientr.kills += 1;
clientr.exp += 4;
clientr.message = "You have killed " @temp.player_hit;
}
elseif (params[0] == "revive")
{
clientr.hp = clientr.hp_max;
setlevel2("final_osl.nw", 30, 30);
}
elseif (params[0] == "attack")
{
temp.player.clientr.hp -= clientr.weapon_damage;
}
}

//#CLIENTSIDE
function onCreated()
{
clientr.hp = 100;
clientr.hp_max = 100;
clientr.deaths = 0;
clientr.kills = 0;
clientr.dead = 0;
setTimer( 0.05 );
}

function onTimeOut()
{
if (keydown(s))
{
setAni("clientr.ani_attack","");
if (temp.player.x = player.x + 1.5 && temp.player.y = player.y + 1.5 && temp.player.x = player.x - 1.5 && temp.player.y = player.y -1.5)
{
triggerserver(gui,this.name,temp.player.account,"attack");
if (temp.player.clientr.hp == 0)
{
triggerserver(gui,this.name,player.account,"kill");
}
}
}
if (clientr.dead = 1)
{
if (keydown(r))
{
triggerserver(gui,this.name,"revive");
}
}
}

Chompy
02-09-2008, 05:06 PM
Well, you can't access other player's clientr. flags tho..

So, instead of checking for a player clientside, you would simple do a triggeraction()

Then if a player is hit (not the one swinging the sword), you check in.. for example 'onActionHit()' and in there, set anis and trigger serverside to remove some of their health

Knightmare1
02-09-2008, 06:03 PM
Well, you can't access other player's clientr. flags tho..

So, instead of checking for a player clientside, you would simple do a triggeraction()

Then if a player is hit (not the one swinging the sword), you check in.. for example 'onActionHit()' and in there, set anis and trigger serverside to remove some of their health
i don't understand what you mean...

The_Kez
02-11-2008, 01:46 AM
Take your onCreated function and move it to the serverside. Also for important flags like that, regardless of the fact that they are clientr. it' a good idea to base64encode them when you're finished with testing.

For checking if a player will die:

temp.dmg = 5; //replace 5 with desired damage
if ( clientr.hp - temp.dmg <= 0 ) //If this is true the player will die.
clientr.hp -= temp.dmg;

Tigairius
02-11-2008, 02:54 AM
Jazz, i meant how do i find the player whos im attacking. like if i attack some player, how would i make them get hurt.
this is what i have so far:



He means to send a triggeraction when you press S, and then have it detect it, probably something like this:


function onActionServerSide()
{
if (params[0] == "hurt")
{
clientr.hp -= temp.player.clientr.weapon_damage;
}
elseif (params[0] == "dead")
{
clientr.hp = 0;
clientr.dead = 1;
clientr.deaths += 1;
}
elseif (params[0] == "kill")
{
[email protected] += 1;
clientr.kills += 1;
clientr.exp += 4;
clientr.message = "You have killed " @temp.player_hit;
}
elseif (params[0] == "revive")
{
clientr.hp = clientr.hp_max;
setlevel2("final_osl.nw", 30, 30);
}
elseif (params[0] == "attack")
{
temp.player.clientr.hp -= clientr.weapon_damage;
}
}
function onCreated()
{
clientr.hp = 100;
clientr.hp_max = 100;
clientr.deaths = 0;
clientr.kills = 0;
clientr.dead = 0;
}
function onActionHit(acct) {
player.chat = "I've been hit by" SPC acct;
clientr.hp -= temp.player.clientr.weapon_damage;
}
//#CLIENTSIDE
function onKeyPressed() {
if (keydown(5)) {
setAni(clientr.ani_attack, "");
triggeraction(player.x + 1 + vecx(player.dir) * 1.5, player.y + 2 + vecy(player.dir) * 1.5, "Hit", player.account);
}
}

Inverness
02-11-2008, 03:15 AM
Take your onCreated function and move it to the serverside. Also for important flags like that, regardless of the fact that they are clientr. it' a good idea to base64encode them when you're finished with testing.No, you don't need to be encoding clientr. flags.

xAndrewx
02-11-2008, 10:01 AM
if (min(clientr.hp - [temp.damage]) =< 0) {
//Is dead
} else {
clientr.hp -= temp.damage;
}


You shouldn't use a timeout either...

The_Kez
02-12-2008, 08:20 AM
No, you don't need to be encoding clientr. flags.
All it takes is one corrupt staffer, especially when it's being stored where he's storing it.
Maloria had problems with staffers leveling up the first time simply by editing clientr. flags and not being caught, and could have easily prevented this with encryption.

Twinny
02-12-2008, 08:51 AM
All it takes is one corrupt staffer, especially when it's being stored where he's storing it.
Maloria had problems with staffers leveling up the first time simply by editing clientr. flags and not being caught, and could have easily prevented this with encryption.

That's what they get for putting the actual value where RC could easily edit it.

The_Kez
02-12-2008, 09:03 AM
That's what they get for putting the actual value where RC could easily edit it.

I don't even think the MUD system was available back in that day. And callstacks definitely weren't. Even so, there were better places to store it back then then in an available clientr. var.

cbk1994
02-12-2008, 05:23 PM
If you're that paranoid, encode it ... but why?

If someone wants to they can delete the whole server with access to a single level. base64encode would be incredibly easy to break anyway.

Just don't give any staff edit attributes.

The_Kez
02-12-2008, 08:48 PM
If you're that paranoid, encode it ... but why?

If someone wants to they can delete the whole server with access to a single level. base64encode would be incredibly easy to break anyway.

Just don't give any staff edit attributes.


That was not the problem. Anyone with access to a single test level can edit clientr flags if they are not encoded. Not everyone with a single test level has access to delete the entire server. It has nothing to do with edit attributes.

Callstacks also solve this problem, but back then callstack access was not available.

Also, there are ways to use base64encode that are more difficult to break then simply saying var = base64encode(var).

xAndrewx
02-12-2008, 09:01 PM
Solution: not to hire someone that resonates as corrupt!

The_Kez
02-12-2008, 09:13 PM
Solution: not to hire someone that resonates as corrupt!
Haha, in a perfect world right =p

cbk1994
02-12-2008, 10:59 PM
That was not the problem. Anyone with access to a single test level can edit clientr flags if they are not encoded. Not everyone with a single test level has access to delete the entire server. It has nothing to do with edit attributes.

Callstacks also solve this problem, but back then callstack access was not available.

Also, there are ways to use base64encode that are more difficult to break then simply saying var = base64encode(var).
Skyld made an encryption example, look around.
Solution: not to hire someone that resonates as corrupt!
Not true. Their brother could get on. Or you yourself could be corrupt. I think the only solution is suicide.

The_Kez
02-12-2008, 11:38 PM
Skyld made an encryption example, look around.

True, I saw it. I would probably use it to say...encrypt my insecure clientr. variables so said staffer's brother doesn't come on and start adding people tons of experience/max hp.

cbk1994
02-13-2008, 12:21 AM
True, I saw it. I would probably use it to say...encrypt my insecure clientr. variables so said staffer's brother doesn't come on and start adding people tons of experience/max hp.

Paranoid one. clientr variables don't need encryption. Just focus on a system of detecting cheating. Much easier.

zokemon
02-13-2008, 12:33 AM
How about you just use clientr vars for reading and not for storing? Much simpler.

Inverness
02-13-2008, 02:37 AM
True, I saw it. I would probably use it to say...encrypt my insecure clientr. variables so said staffer's brother doesn't come on and start adding people tons of experience/max hp.
Uh, hello in there?

Changes like that are logged in logs/rclog.txt

The_Kez
02-13-2008, 04:25 AM
How about you just use clientr vars for reading and not for storing? Much simpler.
Exactly. I wouldn't use clientr. variables to store things such as experience or health power.

The_Kez
02-13-2008, 04:29 AM
Uh, hello in there?

Changes like that are logged in logs/rclog.txt
Again, I'm talking about scripts that edit clientr. variables, not editing attributes via RC.

Either way, if you want to store important information the old fasion way, and then not secure it, be my guest. Your data, not mine. Again, I wouldn't even store this sort of information in a clientr. in the first place.

cbk1994
02-13-2008, 04:35 AM
I wouldn't even store this sort of information in a clientr. in the first place.

Good for you >.<

The_Kez
02-13-2008, 04:57 AM
Paranoid one. clientr variables don't need encryption. Just focus on a system of detecting cheating. Much easier.
Encryption is a tool in that box. No one said you have to keep your data secure. If you want to bank on cheat detection methods because writing an encryption that takes 6-7 lines is too hard or isn't worth your time, it's your data.

Inverness
02-13-2008, 05:07 AM
Ideally, you shouldn't have to worry about staff even making scripts to edit clientr variables.

The_Kez
02-13-2008, 05:12 AM
Ideally, you shouldn't have to worry about staff even making scripts to edit clientr variables.
Ideally, yeah. ;[
But unfortunately after what happend on Maloria I don't think that if you're gonna store this sort of thing in a clientr. variable, that it's worth the risk of leaving it decryted.

zokemon
02-13-2008, 08:24 AM
Ideally, only server administrators should have access to RC on classic servers and all other staff should work on Dev servers.

The_Kez
02-13-2008, 09:07 AM
Ideally, only server administrators should have access to RC on classic servers and all other staff should work on Dev servers.
Yeah. Though, one of the people editing clientr. flags on maloria back in the GS1 days was a department Chief. =(
So ideally everyone's data NPCs would be scripted securely. :p

zokemon
02-13-2008, 09:52 AM
Yeah. Though, one of the people editing clientr. flags on maloria back in the GS1 days was a department Chief. =(
So ideally everyone's data NPCs would be scripted securely. :p

Department Chiefs aren't server administrators. Believe me, I know all about the history of Maloria. I have first-hand experience.

Tigairius
02-13-2008, 09:56 AM
Ideally, only server administrators should have access to RC on classic servers and all other staff should work on Dev servers.

Lol, Ol' West isn't even classic and that's how we do it.

cbk1994
02-13-2008, 01:50 PM
You forget that someone scripts the encryption, and, face it, more scripters are corrupt than any other group of developers ;)

Atleast the ones I've seen.

zokemon
02-13-2008, 05:33 PM
You forget that someone scripts the encryption, and, face it, more scripters are corrupt than any other group of developers ;)

Atleast the ones I've seen.

Actually, I was always more worried about level designers. But that was probably do to the fact that on almost every project I work on, I almost never hire another scripter to work on the project besides my self.

So if scripters are corrupt and you want a good solid encryption system, the only solution seems that only servers created by a scripter would solve this issue since a server creater probably wouldn't screw the economy up or cheat on the server that he/she created.

At least, I know I wouldn't.

cbk1994
02-13-2008, 06:49 PM
Actually, I was always more worried about level designers. But that was probably do to the fact that on almost every project I work on, I almost never hire another scripter to work on the project besides my self.

So if scripters are corrupt and you want a good solid encryption system, the only solution seems that only servers created by a scripter would solve this issue since a server creater probably wouldn't screw the economy up or cheat on the server that he/she created.

At least, I know I wouldn't.

Except that generally levelers don't know much code except the basics -- hide(), show(), sleep(), drawunderplayer(), message(), etc.

The_Kez
02-13-2008, 08:18 PM
Except that generally levelers don't know much code except the basics -- hide(), show(), sleep(), drawunderplayer(), message(), etc.
clientr.exp += 20;
That's all they have to know how to write lol. What's awesome is it's just those types of people who you're normally protecting from. People who only know how to do simple commands aren't going to bother trying to decode your protected data, even if it's a simple one line encryption.