A new HP system ?

Hi, just wondering how to set a string flag on a player such the HP example 150 and show it on the screen !

Thanks.

Re: A new HP system ?

if(playerenters){
if(!setup){
insertstring client.hp,0,150; //max hp
insertstring client.hp,1,150; //cur hp
set setup;
}
}

In bold is an example of setting a string list(a bunch of strings stuck together under 1 name), the number 1 being the 2nd string in the list.

Another way to set only 1 string to a name is
setstring client.hp,150;
And unlike the example I continue below, instead of using #I(client.hp,1) which grabs the 2nd location of the string list. You would use
#s(client.hp); Which would return 150. (though some scripts can't interpret that because a string is in words and variables are in numbers. To get past this you use strtofloat(#s(client.hp)); Which just means String to Float, and Float means a number with a decimal point. Aka it turns words into a number.)

Healing item example:

if(playertouchsme){
 message Picked up Berry!;
 if(!strequals(#I(client.hp,0),#I(client.hp,1))){
 this.hp = strtofloat(#I(client.hp,0))+1;
 replacestring client.hp,1,#v(this.hp); 
 }
}

in player hud npc:

if(playerenters){
toweapons -hud;
}

if(isweapon||playerenters){
timeout = 0.05;
}

if(washit){
 if(strequals(#I(client.hp,1),1)){
 playerhearts = 0;
 replacestring client.hp,1,strtofloat(#I(client.hp,0));
 }else{
 this.hp = strtofloat(#I(client.hp,0))-1; // you can change the -1 to dmg.
 replacestring client.hp,1,#v(this.hp); 
 }
}

if(timeout){
 showtext 201,15,5,Arial,,#I(client.hp,0); // 15 being the x, 5 the y position.
 timeout = 0.05;
}

Re: A new HP system ?

0.05 timeout? Ugly :stuck_out_tongue:

Re: A new HP system ?

Change all timeouts to = 0.2; (for agret)

Re: A new HP system ?

Timeout is for the GUI, which sadly hides itself when a status change happens like dieing or getting hurt. But unfortunatly theres many more things that are more passive and don't have triggers, healing in a bed, grabbing a heart, getting your props re-saved by RC.

Re: A new HP system ?

thanks a lots ![br][br]Double Posted on: March 28, 2008, 03:30:05 PM_________________________________________________[br]There is a problem through… i replaced :

if(washit){
if(strequals(#I(client.hp,1),1)){
playerhearts = 0;
replacestring client.hp,1,strtofloat(#I(client.hp,0));
}else{
this.hp = strtofloat(#I(client.hp,1))-1; // you can change the -1 to dmg.
replacestring client.hp,1,#v(this.hp);
}
}

by…

if(playerhurt){
if(strequals(#I(client.hp,1),1)){
playerhearts = 0;
replacestring client.hp,1,strtofloat(#I(client.hp,0));
}else{
this.hp = strtofloat(#I(client.hp,1))-1; // you can change the -1 to dmg.
replacestring client.hp,1,#v(this.hp);
}
}

When i get hit … its supposed to take only 1 hp… but it take 2… why?

Re: A new HP system ?

Not sure exactly, maybe try putting
this.hp = ;
After replacestring client.hp,1,#v(this.hp);

Or you could always just go
this.hp = strtofloat(#I(client.hp,1))-0.5;

Or if you still have problems just replace everything after else{ with.
this.dmg = playerhurtdpower;
this.oldhp=strtofloat(#I(client.hp,1));
this.newhp=this.oldhp-this.dmg;
replacestring client.hp,#v(this.newhp);
playerhearts=playerfullhearts;
}
}

and I forgot to mention, you should put something to stop the player from dieing when his normal hearts run out. Which is what the playerhearts=playerfullhearts; is for.