Sprite

Started by FinchDon, Sep 14, 2015, 03:35 PM

Previous topic - Next topic

FinchDon

Hello i make a sprite of player health body The file is in .png I add this on PlayerMove

if ( player.Health < 100 || player.Health == 100  )
{
b.ShowForPlayer( player );
}

and This on ScriptLoad

b <- CreateSprite("80%.png", 900, 160, 0, 0, 0, 255);

but when i go n server spawn or set my hp no sprite appear what is problem ???
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

Debian


FinchDon

ahm @Debian I think with this function it will shown to all peoples right? But i am Making a Body Sprite i Mean if player having health under 100 the sprite will appear with 100 % if he has under 90 the sprite of under 90 health appear i don't want to show it for everyone
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

DizzasTeR

I think you should use onPlayerHealthChange instead of onPlayerMove. Also you have to declare all the sprites of different health separately and show them accordingly.

FinchDon

@Doom_Killer i add that on PlayerHealthChange

if ( player.Health < 100 )
{
a.SetRelativeForAll( true );
}
if ( player.Health == 100 )
{
a.ShowForPlayer(player);
}
if ( player.Health < 90 )
{
b.SetRelativeForAll( true );
}
if ( player.Health < 80 )
{
c.SetRelativeForAll( true );
}
if ( player.Health < 70 )
{
d.SetRelativeForAll( true );
}
if ( player.Health < 60 )
{
e.SetRelativeForAll( true );
}
if ( player.Health < 50 )
{
f.SetRelativeForAll( true );
}
if ( player.Health < 40 )
{
g.SetRelativeForAll( true );
}
if ( player.Health < 30 )
{
h.SetRelativeForAll( true );
}
if ( player.Health < 20 )
{
i.SetRelativeForAll( true );
}
if ( player.Health < 10 )
{
j.SetRelativeForAll( true );
}
if ( player.Health == 0 )
{
k.SetRelativeForAll( true );
}

and this on playerDeath

if ( player.Health == 0 ) k.ShowForPlayer( player );

When i type /kill it show correct Sprite but when my health change no sprite appear
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

DizzasTeR

That's because you are just setting the sprite relative for all, you need to use .ShowForPlayer( player )

FinchDon

i now set all of them for showforplayer but no one show now also of playerdeath one
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

DizzasTeR

Quote from: FinchDon on Sep 14, 2015, 04:18 PMi now set all of them for showforplayer but no one show now also of playerdeath one

Fine then welldone, there is no more guide to be provided after such explanation.

FinchDon

:/ what do you mean?
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

KAKAN

Quote from: FinchDon on Sep 14, 2015, 04:30 PM:/ what do you mean?
A thing which a human can understand, go learn english
oh no

Thijn

The solution has been explained. Read it. Understand it. Make it.

FinchDon

Where is it? I can't See Because i add some sprite on ScriptLoad

a <- CreateSprite("100%.png", 900, 160, 0, 0, 0, 255);
b <- CreateSprite("90%.png", 900, 160, 0, 0, 0, 255);
c <- CreateSprite("80%.png", 900, 160, 0, 0, 0, 255);
d <- CreateSprite("70%.png", 900, 160, 0, 0, 0, 255);
e <- CreateSprite("60%.png", 900, 160, 0, 0, 0, 255);
f <- CreateSprite("50%.png", 900, 160, 0, 0, 0, 255);
g <- CreateSprite("40%.png", 900, 160, 0, 0, 0, 255);
h <- CreateSprite("30%.png", 900, 160, 0, 0, 0, 255);
i <- CreateSprite("20%.png", 900, 160, 0, 0, 0, 255);
j <- CreateSprite("10%.png", 900, 160, 0, 0, 0, 255);
k <- CreateSprite("0%.png", 900, 160, 0, 0, 0, 255);

and Use this on PlayerHealth Change

function onPlayerHealthChange( player, lastHP, newHP )
{
if ( player.Health < 100 )
{
a.ShowForPlayer(player);
f.HideFromPlayer( player );
c.HideFromPlayer( player );
d.HideFromPlayer( player );
e.HideFromPlayer( player );
g.HideFromPlayer( player );
i.HideFromPlayer( player );
h.HideFromPlayer( player );
j.HideFromPlayer( player );
k.HideFromPlayer( player );
b.HideFromPlayer( player );
}
if ( player.Health == 100 )
{
f.HideFromPlayer( player );
c.HideFromPlayer( player );
d.HideFromPlayer( player );
e.HideFromPlayer( player );
g.HideFromPlayer( player );
i.HideFromPlayer( player );
h.HideFromPlayer( player );
j.HideFromPlayer( player );
k.HideFromPlayer( player );
b.HideFromPlayer( player );
a.ShowForPlayer(player);
}
if ( player.Health < 90 )
{
a.HideFromPlayer( player );
f.HideFromPlayer( player );
c.HideFromPlayer( player );
d.HideFromPlayer( player );
e.HideFromPlayer( player );
g.HideFromPlayer( player );
i.HideFromPlayer( player );
h.HideFromPlayer( player );
j.HideFromPlayer( player );
k.HideFromPlayer( player );
b.ShowForPlayer(player);
}
if ( player.Health < 80 )
{
a.HideFromPlayer( player );
b.HideFromPlayer( player );
f.HideFromPlayer( player );
d.HideFromPlayer( player );
e.HideFromPlayer( player );
g.HideFromPlayer( player );
i.HideFromPlayer( player );
h.HideFromPlayer( player );
j.HideFromPlayer( player );
k.HideFromPlayer( player );
c.ShowForPlayer(player);
}
if ( player.Health < 70 )
{
a.HideFromPlayer( player );
b.HideFromPlayer( player );
c.HideFromPlayer( player );
f.HideFromPlayer( player );
e.HideFromPlayer( player );
g.HideFromPlayer( player );
i.HideFromPlayer( player );
h.HideFromPlayer( player );
j.HideFromPlayer( player );
k.HideFromPlayer( player );
d.ShowForPlayer(player);
}
if ( player.Health < 60 )
{
a.HideFromPlayer( player );
b.HideFromPlayer( player );
c.HideFromPlayer( player );
d.HideFromPlayer( player );
f.HideFromPlayer( player );
g.HideFromPlayer( player );
i.HideFromPlayer( player );
h.HideFromPlayer( player );
j.HideFromPlayer( player );
k.HideFromPlayer( player );
e.ShowForPlayer(player);
}
if ( player.Health < 50 )
{
a.HideFromPlayer( player );
b.HideFromPlayer( player );
c.HideFromPlayer( player );
d.HideFromPlayer( player );
e.HideFromPlayer( player );
g.HideFromPlayer( player );
i.HideFromPlayer( player );
h.HideFromPlayer( player );
j.HideFromPlayer( player );
k.HideFromPlayer( player );
f.ShowForPlayer(player);
}
if ( player.Health < 40 )
{
a.HideFromPlayer( player );
b.HideFromPlayer( player );
c.HideFromPlayer( player );
d.HideFromPlayer( player );
e.HideFromPlayer( player );
f.HideFromPlayer( player );
i.HideFromPlayer( player );
h.HideFromPlayer( player );
j.HideFromPlayer( player );
k.HideFromPlayer( player );
g.ShowForPlayer(player);
}
if ( player.Health < 30 )
{
a.HideFromPlayer( player );
b.HideFromPlayer( player );
c.HideFromPlayer( player );
d.HideFromPlayer( player );
e.HideFromPlayer( player );
f.HideFromPlayer( player );
g.HideFromPlayer( player );
i.HideFromPlayer( player );
j.HideFromPlayer( player );
k.HideFromPlayer( player );
h.ShowForPlayer(player);
}
if ( player.Health < 20 )
{
a.HideFromPlayer( player );
b.HideFromPlayer( player );
c.HideFromPlayer( player );
d.HideFromPlayer( player );
e.HideFromPlayer( player );
f.HideFromPlayer( player );
g.HideFromPlayer( player );
h.HideFromPlayer( player );
j.HideFromPlayer( player );
k.HideFromPlayer( player );
i.ShowForPlayer(player);
}
if ( player.Health < 10 )
{
a.HideFromPlayer( player );
b.HideFromPlayer( player );
c.HideFromPlayer( player );
d.HideFromPlayer( player );
e.HideFromPlayer( player );
f.HideFromPlayer( player );
g.HideFromPlayer( player );
h.HideFromPlayer( player );
i.HideFromPlayer( player );
k.HideFromPlayer( player );
j.ShowForPlayer(player);
}
if ( player.Health == 0 )
{
a.HideFromPlayer( player );
b.HideFromPlayer( player );
c.HideFromPlayer( player );
d.HideFromPlayer( player );
e.HideFromPlayer( player );
f.HideFromPlayer( player );
g.HideFromPlayer( player );
h.HideFromPlayer( player );
i.HideFromPlayer( player );
j.HideFromPlayer( player );
k.ShowForPlayer( player );
}
}
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

aXXo

You created the Sprite, but never showed it to a player.
a.ShowForPlayer( player )

FinchDon

a.ShowForPlayer(player); i add it :/
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

soulshaker