This topic was marked solved by its starter, on September 17th, 2015, 04:16 PM
Sprite
null »

FinchDon

  • Sr. Member
  • Posts: 252
Sprite
« on September 14th, 2015, 04:35 PM »
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

  • Jr. Member
  • Posts: 62

FinchDon

  • Sr. Member
  • Posts: 252
Re: Sprite
« Reply #2, on September 14th, 2015, 04:43 PM »
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

  • VC:MP Beta Tester
  • Infinite loops defy infinity by overflowing memory
  • Posts: 1,168
Re: Sprite
« Reply #3, on September 14th, 2015, 04:47 PM »
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

  • Sr. Member
  • Posts: 252
Re: Sprite
« Reply #4, on September 14th, 2015, 04:53 PM »
@Doom_Killer i add that on PlayerHealthChange

Code: [Select]
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

Code: [Select]
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

  • VC:MP Beta Tester
  • Infinite loops defy infinity by overflowing memory
  • Posts: 1,168
Re: Sprite
« Reply #5, on September 14th, 2015, 05:09 PM »
That's because you are just setting the sprite relative for all, you need to use .ShowForPlayer( player )

FinchDon

  • Sr. Member
  • Posts: 252
Re: Sprite
« Reply #6, on September 14th, 2015, 05:18 PM »
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

  • VC:MP Beta Tester
  • Infinite loops defy infinity by overflowing memory
  • Posts: 1,168
Re: Sprite
« Reply #7, on September 14th, 2015, 05:23 PM »
Quote from FinchDon on September 14th, 2015, 05:18 PM
i 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

  • Sr. Member
  • Posts: 252
Re: Sprite
« Reply #8, on September 14th, 2015, 05:30 PM »
:/ what do you mean?
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

KAKAN

  • Wiki Contributor
  • Posts: 3,343
You can contact me using Discord, at Developers.CPP( check off-board to find the invite link )
Github: https://github.com/theKAKAN

Thijn

  • VC:MP Beta Tester
  • Posts: 1,688
Re: Sprite
« Reply #10, on September 14th, 2015, 06:53 PM »
The solution has been explained. Read it. Understand it. Make it.

FinchDon

  • Sr. Member
  • Posts: 252
Re: Sprite
« Reply #11, on September 16th, 2015, 05:43 PM »
Where is it? I can't See Because i add some sprite on ScriptLoad

Code: [Select]
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

Code: [Select]
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

  • Full Member
  • Posts: 167
Re: Sprite
« Reply #12, on September 16th, 2015, 05:48 PM »
You created the Sprite, but never showed it to a player.
a.ShowForPlayer( player )

FinchDon

  • Sr. Member
  • Posts: 252
Re: Sprite
« Reply #13, on September 16th, 2015, 05:56 PM »
a.ShowForPlayer(player); i add it :/
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

soulshaker

  • Full Member
  • RIP
  • Posts: 134
Re: Sprite
« Reply #14, on September 16th, 2015, 11:51 PM »

null »