= ?

Hey :slight_smile:

I have a problem .
My character not got the 10 lifes.
Why ?

Here is my script :

if (created) {
  // Initialize the attributes
  showcharacter;
  setcharprop #3,head0.png;
  setcharprop #C0,orange;
  setcharprop #C1,white;
  setcharprop #C2,blue;
  setcharprop #C3,red;
  setcharprop #C4,black;
  setcharprop #n,Monstre test;
  setcharprop #2,shield1.gif;
  shieldpower = 1;
  dir = 2;
  setcharani idle,;
  message #s(char.life);
  this.o=strtofloat(#s(char.life));
  setstring char.life,#v(strtofloat(#s(char.life))==10);
}
if (washit&&strtofloat(#s(char.life))!=0) {
  setstring char.life,#v(strtofloat(#s(char.life))-1);
}
if (washit&&strtofloat(#s(char.life))=0) {
  setcharani dead,;
}

Hi Hi
“#v(strtofloat(#s(char.life))==10)” Are you intentionally making a comparison in there?
Just do setstring char.life,10;

Also, strings are not contained on the NPC, they are contained on the player.
If you don’t know what that means, wait till you put more than one NPC down.

Ok done thanks , but if i hit the char the life is not -1

if (washit&&strtofloat(#s(char.life))!=0) { setstring char.life,#v(strtofloat(#s(char.life))-1); } if (washit&&strtofloat(#s(char.life))=0) { setcharani dead,; }

Only on the message

Just for future reference, == is to compare, = is to assign.
Also I can’t see anything wrong with your snippet.

if(washit) { //Both contained 'washit', lets join 'em together if(strtofloat(#s(char.life)) > 0) { //greater than 0, In the case it could end up below 0 setstring char.life,#v(strtofloat(#s(char.life)) - 1); message ow [#s(char.life)]; //Debugger, why not? sleep 0.5; message; } if(strtofloat(#s(char.life)) <= 0) { //Less than or equal to 0 setcharani dead,; } }

“snippet” teehee

i have a new problem with my xp/level up system.
The script does no work

message level up system; if (playerenters) { toweapons levels/2; } if(strtofloat(#s(client.level)) >= 1 && strtofloat(#s(client.xp)) <= 1000) { setplayerprop #c,Level Up ! (2); setstring client.level,2; setstring client.xp,0; }

[QUOTE=Trakan;58684]
i have a new problem with my xp/level up system.
The script does no work

message level up system; if (playerenters) { toweapons levels/2; } if(strtofloat(#s(client.level)) >= 1 && strtofloat(#s(client.xp)) <= 1000) { setplayerprop #c,Level Up ! (2); setstring client.level,2; setstring client.xp,0; }
[/QUOTE]

message level up system; if (playerenters) { toweapons levels/2; } if(strtofloat(#s(client.level)) == 1 && strtofloat(#s(client.xp)) >= 1000) { setplayerprop #c,Level Up ! (2); setstring client.level,2; setstring client.xp,0; }
fixed…

Merged doublepost_______________

use a better script though for all levels like
[php]
if (playerenters){
if (!isweapon)toweapons levellingsystem;
if (strtofloat(#s(client.level))==0){
setstring client.xp,0;
setstring client.xpneeded,100;
setstring client.level,1;
}
timeout=0.05;
}

if (timeout){
if(strtofloat(#s(client.xp))>=strtofloat(#s(client.xpneeded))) {
setstring client.level,#v(strtofloat(#s(client.level))+1);
setstring client.xpneeded,strtofloat(#s(client.level))*strtofloat(#s(client.level));
setplayerprop #c,im now level #s(client.level);
}
timeout=1;
}
[/php]

there, thats a better way of doing it and it only took 3 mins to write if that :open_mouth:

New problem with my monster.
Here is the script :

[CODE]// By Trakan
if (created) {
setcharprop #P2,zodiac_dragonwhelp.png;
setcharani zodiac_dragonsmallidle,;
dir = 1;
swordpower = 1;
message [#s(char.life)];
setstring char.life,10;
}
if (playerenters || wasthrown) {
// Initialize the this. variables
message [#s(char.life)];
this.huntspeed = 0.4;
timeout = 0.05;
this.walkmode = 1;
if (wasthrown && this.walkmode>1) this.walkmode = 1;
this.x1 = 0;
this.x2 = 63;
this.y1 = 0;
this.y2 = 63;
this.speed = 0.3;
if (hearts<=0) {
this.mode = 5; // RESPAWN
this.runcounter = 0;
timeout = 5;
} else {
this.mode = 0;
setcharani zodiac_dragonsmallidle,;
this.runcounter = int(random(10,40));
}
}

// Walking stuff
if (timeout && this.mode==0) { // WALKING
setcharani zodiac_dragonsmallwalk,;
newx = x + vecx(dir)*this.speed;
newy = y + vecy(dir)*this.speed;
this.runcounter–;
if (this.walkmode==1) { // RANDOM
if (this.runcounter>0) {
testx = newx + 1.5 + vecx(dir);
testy = newy + 2 + vecy(dir);
if (onwall(testx,testy)) {
dir = (dir+2)%4;
this.runcounter = int(random(0,60));
} else {
x = newx;
y = newy;
}
} else {
this.runcounter = int(random(10,40));
dir = (dir+1+int(random(0,2))*2)%4;
}
} else if (this.walkmode==2) { // LEFTRIGHT
if (dir!=1 && dir!=3) dir = 3;
else {
x = newx;
y = newy;
if ((dir==1 && x<=this.x1) || (dir==3 && x>=this.x2))
dir = (dir+2)%4;
}
} else if (this.walkmode==3) { // UPDOWN
if (dir!=0 && dir!=2) dir = 2;
else {
x = newx;
y = newy;
if ((dir==0 && y<=this.y1) || (dir==2 && y>=this.y2))
dir = (dir+2)%4;
}
} else if (this.walkmode==4) { // RECTANGLE
x = newx;
y = newy;
if ((dir==0 && y<=this.y1) || (dir==1 && x<=this.x1) ||
(dir==2 && y>=this.y2) || (dir==3 && x>=this.x2))
dir = (dir+3)%4;
}
if (this.walkmode>1 && this.runcounter<=0)
this.runcounter = 20;
message [#s(char.life)];
timeout = 0.05;
}

// Sword attacking stuff
if (timeout && (this.mode==0 || this.mode==2)) {
// Look for players
mindist = 1000;
for (i=0; i<playerscount; i++)
if (players[i].hearts>0 && players[i].id>=0) {
dx = players[i].x - x;
dy = players[i].y - y;
if (abs(dx)>abs(dy)) {
if (dx>0) pdir=3; else pdir=1;
} else {
if (dy>0) pdir=2; else pdir=0;
}
if (pdir==dir) {
dist = (dxdx+dydy)^0.5;
if (dist<mindist) {
cansee = 1;
if (abs(dx)>abs(dy)) k = int(abs(dx));
else k = int(abs(dy));
for (j=0; j<=k-2; j++)
if (onwall(x+1.5+dxj/k,y+2+dyj/k)) cansee = 0;
if (cansee!=0) {
mindist = dist;
aimplayer = i;
this.aimx = players[i].x;
this.aimy = players[i].y;
}
}
}
}
if (mindist<=3) {
this.runcounter = -1;
this.mode = 3; // SLAYING
setcharani zodiac_dragonsmallattack,;
timeout = 0.05;
} else if (mindist<20) {
if (this.mode!=2) message [#s(char.life)];!;
this.runcounter = 100;
this.mode = 2; // HUNTING
} else timeout = 0.05;
}
if (timeout && this.mode==3) { // SLAYING
this.runcounter++;
if (this.runcounter>4) {
this.runcounter = 100;
this.mode = 2; // HUNTING
setcharani zodiac_dragonsmallidle,;
}
message [#s(char.life)];
timeout = 0.05;
}
if (timeout && this.mode==2) { // HUNTING
setcharani zodiac_dragonsmallwalk,;
this.runcounter–;
if (this.runcounter>0 && aimplayer<playerscount && players[aimplayer].hearts>0) {
// Get new direction
dx = players[aimplayer].x-x;
dy = players[aimplayer].y-y;
if (abs(dx)>abs(dy)) {
if (dx>0) dir=3; else dir=1;
} else {
if (dy>0) dir=2; else dir=0;
}

// Test if we can do a step
dx = this.aimx-x;
dy = this.aimy-y;
if (abs(dx)<=1 && abs(dy)<=1) {
  this.aimx = players[aimplayer].x;;
  this.aimy = players[aimplayer].y;
  dx = this.aimx-x;
  dy = this.aimy-y;
}
if (abs(dx)>abs(dy)) {
  if (dx>0) testdir=3; else testdir=1;
} else {
  if (dy>0) testdir=2; else testdir=0;
}
len = (dx*dx+dy*dy)^0.5;
addx = (dx/len)*this.huntspeed;
addy = (dy/len)*this.huntspeed;
testx = x + 1.5;
testy = y + 2;
if (!onwall(testx+addx,testy+addy)) {
  // Do a step
  x += addx;
  y += addy;
} else if (!onwall(testx+addx,testy)) x += addx;
else if (!onwall(testx,testy+addy)) y += addy;

} else {
this.mode = 0; // WALKING
this.walkmode = 1; // RANDOM
this.runcounter = int(random(10,40));
setcharani zodiac_dragonsmallidle,;
dir = (dir+2)%4;
message [#s(char.life)];
}
timeout = 0.05;
}

if ((hurtdx!=0 || hurtdy!=0) && isleader && this.mode!=4) {
this.hurtdx = hurtdx;
this.hurtdy = hurtdy;
hurtdx = 0;
hurtdy = 0;
if (hearts<=0) {
this.mode = 4; // DYING
message [#s(char.life)];
setcharani dead,;
timeout = 1.2;
}
}
if (timeout && this.mode==1) { // HURTED
this.runcounter–;
if (this.runcounter>10) {
testx = x + 1.5 + this.hurtdx2;
testy = y + 2 + this.hurtdy
2;
if (!onwall(testx,testy)) {
x += this.hurtdx;
y += this.hurtdy;
}
}
if (this.runcounter<=0) {
if (swordpower>0) this.mode = 2; // HUNTING
else this.mode = 0; // WALKING
this.runcounter = 100;
setcharani zodiac_dragonsmallidle,;
}
timeout = 0.05;
}
if (timeout && this.mode==5) { // RESPAWN
this.mode = 0;
this.runcounter = int(random(10,40));
timeout = 0.05;
setstring char.life,10;
setcharani zodiac_dragonsmallidle,;
this.walkmode = 1;
}
if(washit) { //Both contained ‘washit’, lets join 'em together
if(strtofloat(#s(char.life)) > 0) { //greater than 0, In the case it could end up below 0
setstring char.life,#v(strtofloat(#s(char.life)) - 1);
message [#s(char.life)]; //Debugger, why not?
sleep 0.5;
message;
}
if(strtofloat(#s(char.life)) <= 0) { //Less than or equal to 0
setstring client.xp,#v(strtofloat(#s(client.xp)) + 100);
setcharani dead,;
setplayerprop #c,+100xp;
this.mode = 5;
}
}
[/CODE]

1 Problem : If the char not got the same gani , he can’t attack me.
2 Problem : The monster can’t respawn.

2nd problem: when it respawns it asks for “hearts” which means it’s running on the Classic Hearts System and not Strings.

1st Problem I can’t even be assed to read your script, I am gonna let someone else solve that.

Ok thanks

[QUOTE=Trakan;58963]
New problem with my monster.
Here is the script :

[CODE]// By Trakan
if (created) {
setcharprop #P2,zodiac_dragonwhelp.png;
setcharani zodiac_dragonsmallidle,;
dir = 1;
swordpower = 1;
message [#s(char.life)];
setstring char.life,10;
}
if (playerenters || wasthrown) {
// Initialize the this. variables
message [#s(char.life)];
this.huntspeed = 0.4;
timeout = 0.05;
this.walkmode = 1;
if (wasthrown && this.walkmode>1) this.walkmode = 1;
this.x1 = 0;
this.x2 = 63;
this.y1 = 0;
this.y2 = 63;
this.speed = 0.3;
if (hearts<=0) {
this.mode = 5; // RESPAWN
this.runcounter = 0;
timeout = 5;
} else {
this.mode = 0;
setcharani zodiac_dragonsmallidle,;
this.runcounter = int(random(10,40));
}
}

// Walking stuff
if (timeout && this.mode==0) { // WALKING
setcharani zodiac_dragonsmallwalk,;
newx = x + vecx(dir)*this.speed;
newy = y + vecy(dir)*this.speed;
this.runcounter–;
if (this.walkmode==1) { // RANDOM
if (this.runcounter>0) {
testx = newx + 1.5 + vecx(dir);
testy = newy + 2 + vecy(dir);
if (onwall(testx,testy)) {
dir = (dir+2)%4;
this.runcounter = int(random(0,60));
} else {
x = newx;
y = newy;
}
} else {
this.runcounter = int(random(10,40));
dir = (dir+1+int(random(0,2))*2)%4;
}
} else if (this.walkmode==2) { // LEFTRIGHT
if (dir!=1 && dir!=3) dir = 3;
else {
x = newx;
y = newy;
if ((dir==1 && x<=this.x1) || (dir==3 && x>=this.x2))
dir = (dir+2)%4;
}
} else if (this.walkmode==3) { // UPDOWN
if (dir!=0 && dir!=2) dir = 2;
else {
x = newx;
y = newy;
if ((dir==0 && y<=this.y1) || (dir==2 && y>=this.y2))
dir = (dir+2)%4;
}
} else if (this.walkmode==4) { // RECTANGLE
x = newx;
y = newy;
if ((dir==0 && y<=this.y1) || (dir==1 && x<=this.x1) ||
(dir==2 && y>=this.y2) || (dir==3 && x>=this.x2))
dir = (dir+3)%4;
}
if (this.walkmode>1 && this.runcounter<=0)
this.runcounter = 20;
message [#s(char.life)];
timeout = 0.05;
}

// Sword attacking stuff
if (timeout && (this.mode==0 || this.mode==2)) {
// Look for players
mindist = 1000;
for (i=0; i<playerscount; i++)
if (players[i].hearts>0 && players[i].id>=0) {
dx = players[i].x - x;
dy = players[i].y - y;
if (abs(dx)>abs(dy)) {
if (dx>0) pdir=3; else pdir=1;
} else {
if (dy>0) pdir=2; else pdir=0;
}
if (pdir==dir) {
dist = (dxdx+dydy)^0.5;
if (dist<mindist) {
cansee = 1;
if (abs(dx)>abs(dy)) k = int(abs(dx));
else k = int(abs(dy));
for (j=0; j<=k-2; j++)
if (onwall(x+1.5+dxj/k,y+2+dyj/k)) cansee = 0;
if (cansee!=0) {
mindist = dist;
aimplayer = i;
this.aimx = players[i].x;
this.aimy = players[i].y;
}
}
}
}
if (mindist<=3) {
this.runcounter = -1;
this.mode = 3; // SLAYING
setcharani zodiac_dragonsmallattack,;
timeout = 0.05;
} else if (mindist<20) {
if (this.mode!=2) message [#s(char.life)];!;
this.runcounter = 100;
this.mode = 2; // HUNTING
} else timeout = 0.05;
}
if (timeout && this.mode==3) { // SLAYING
this.runcounter++;
if (this.runcounter>4) {
this.runcounter = 100;
this.mode = 2; // HUNTING
setcharani zodiac_dragonsmallidle,;
}
message [#s(char.life)];
timeout = 0.05;
}
if (timeout && this.mode==2) { // HUNTING
setcharani zodiac_dragonsmallwalk,;
this.runcounter–;
if (this.runcounter>0 && aimplayer<playerscount && players[aimplayer].hearts>0) {
// Get new direction
dx = players[aimplayer].x-x;
dy = players[aimplayer].y-y;
if (abs(dx)>abs(dy)) {
if (dx>0) dir=3; else dir=1;
} else {
if (dy>0) dir=2; else dir=0;
}

// Test if we can do a step
dx = this.aimx-x;
dy = this.aimy-y;
if (abs(dx)<=1 && abs(dy)<=1) {
  this.aimx = players[aimplayer].x;;
  this.aimy = players[aimplayer].y;
  dx = this.aimx-x;
  dy = this.aimy-y;
}
if (abs(dx)>abs(dy)) {
  if (dx>0) testdir=3; else testdir=1;
} else {
  if (dy>0) testdir=2; else testdir=0;
}
len = (dx*dx+dy*dy)^0.5;
addx = (dx/len)*this.huntspeed;
addy = (dy/len)*this.huntspeed;
testx = x + 1.5;
testy = y + 2;
if (!onwall(testx+addx,testy+addy)) {
  // Do a step
  x += addx;
  y += addy;
} else if (!onwall(testx+addx,testy)) x += addx;
else if (!onwall(testx,testy+addy)) y += addy;

} else {
this.mode = 0; // WALKING
this.walkmode = 1; // RANDOM
this.runcounter = int(random(10,40));
setcharani zodiac_dragonsmallidle,;
dir = (dir+2)%4;
message [#s(char.life)];
}
timeout = 0.05;
}

if ((hurtdx!=0 || hurtdy!=0) && isleader && this.mode!=4) {
this.hurtdx = hurtdx;
this.hurtdy = hurtdy;
hurtdx = 0;
hurtdy = 0;
if (hearts<=0) {
this.mode = 4; // DYING
message [#s(char.life)];
setcharani dead,;
timeout = 1.2;
}
}
if (timeout && this.mode==1) { // HURTED
this.runcounter–;
if (this.runcounter>10) {
testx = x + 1.5 + this.hurtdx2;
testy = y + 2 + this.hurtdy
2;
if (!onwall(testx,testy)) {
x += this.hurtdx;
y += this.hurtdy;
}
}
if (this.runcounter<=0) {
if (swordpower>0) this.mode = 2; // HUNTING
else this.mode = 0; // WALKING
this.runcounter = 100;
setcharani zodiac_dragonsmallidle,;
}
timeout = 0.05;
}
if (timeout && this.mode==5) { // RESPAWN
this.mode = 0;
this.runcounter = int(random(10,40));
timeout = 0.05;
setstring char.life,10;
setcharani zodiac_dragonsmallidle,;
this.walkmode = 1;
}
if(washit) { //Both contained ‘washit’, lets join 'em together
if(strtofloat(#s(char.life)) > 0) { //greater than 0, In the case it could end up below 0
setstring char.life,#v(strtofloat(#s(char.life)) - 1);
message [#s(char.life)]; //Debugger, why not?
sleep 0.5;
message;
}
if(strtofloat(#s(char.life)) <= 0) { //Less than or equal to 0
setstring client.xp,#v(strtofloat(#s(client.xp)) + 100);
setcharani dead,;
setplayerprop #c,+100xp;
this.mode = 5;
}
}
[/CODE]

1 Problem : If the char not got the same gani , he can’t attack me.
coughtriggeractions!
2 Problem : The monster can’t respawn.
[/QUOTE]

looks like your missing a timeout in there, I’ll leave you to guess where