Author Topic: Tryed Making a Heal ultimate  (Read 3553 times)

Martin Texno

  • Newbie
  • *
  • Posts: 22
  • I'm Constructive ?
    • MSN Messenger - martinkongerule@hotmail.com
    • Yahoo Instant Messenger - martinmikalsen@yahoo.com
    • View Profile
    • Zombie-Asylum !
    • Email
Tryed Making a Heal ultimate
« on: December 01, 2009, 04:08:31 PM »
Hello, i tryed making a health Ultimate, Still can't test it  :D

So here's the code
I feel there is something wrong ?


Code: [Select]
new Float:fLastUsed[65];
new iHealthAdded[65];

#define HEALTH_COOLDOWN 20
public OnUltimateCommand(client,race,bool:pressed)
{
if(pressed && race==raceID)
{
new health_level=War3_GetSkillLevel(client,race,3);
  new old_health=GetClientHealth(client);
new current_time=GetEngineTime();
if(health_level>0 && (current_time>=(fLastUsed[client]+HEALTH_COOLDOWN) || fLastUsed[client]==0.0))
{
switch(health_level)
{
case 1:
iHealthAdded[client]=20;
case 2:
iHealthAdded[client]=30;
case 3:
iHealthAdded[client]=40;
case 4:
iHealthAdded[client]=50;
}
SetEntityHealth(client,old_health+iHealthAdded[client]);
fLastUsed[client]=current_time;
CreateTimer(5.0,FinishHealth,GetClientUserId(client));
}
}
}

public Action:FinishHealth(Handle:timer,any:userid)
{
new client=GetClientOfUserId(userid);
if(client>0)
{
new new_hp=GetClientHealth(client)-iHealthAdded[client];
if(new_hp<1)
{
FakeClientCommand(client,"kill\n");
}
else
{
SetEntityHealth(client,new_hp);
}
}
}
« Last Edit: December 02, 2009, 11:04:51 AM by Martin Texno »
Support ?

Anthony Iacono

  • Lead Developer
  • Administrator
  • Full Member
  • *****
  • Posts: 136
  • Lets make it better.
    • MSN Messenger - anthonyiacono@gmail.com
    • View Profile
    • My Blog
    • Email
Re: Tryed Making a Heal ultimate
« Reply #1 on: December 01, 2009, 05:31:40 PM »
Hey,

First off:
Code: [Select]
new health_level=War3_GetSkillLevel(client,race,1);Should be:
Code: [Select]
new health_level=War3_GetSkillLevel(client,race,3);Since 0==skill 1, 1==skill 2, 2==skill 3, 3==ultimate

There actually isn't a built in system for health. This is how I would do it:
Code: [Select]
new Float:fLastUsed[65];
new iHealthAdded[65];

#define HEALTH_COOLDOWN 20
public OnUltimateCommand(client,race,bool:pressed)
{
if(pressed && race==raceID)
{
new health_level=War3_GetSkillLevel(client,race,3);
  new old_health=GetClientHealth(client);
new current_time=GetEngineTime();
if(health_level>0 && (current_time>=(fLastUsed[client]+HEALTH_COOLDOWN) || fLastUsed[client]==0.0))
{
switch(health_level)
{
case 1:
iHealthAdded[client]=20;
case 2:
iHealthAdded[client]=30;
case 3:
iHealthAdded[client]=40;
case 4:
iHealthAdded[client]=50;
}
SetEntityHealth(client,old_health+iHealthAdded[client]);
fLastUsed[client]=current_time;
CreateTimer(5.0,FinishHealth,GetClientUserId(client));
}
}
}

public Action:FinishHealth(Handle:timer,any:userid)
{
new client=GetClientOfUserId(userid);
if(client>0)
{
new new_hp=GetClientHealth(client)-iHealthAdded[client];
if(new_hp<1)
{
FakeClientCommand(client,"kill\n");
}
else
{
SetEntityHealth(client,new_hp);
}
}
}

You would also put this in player spawn:
Code: [Select]
iHealthAdded[client]=0;
fLastUsed[client]=0.0;

Let me know if you don't understand.

stinkyfax

  • Full Member
  • ***
  • Posts: 120
    • View Profile
    • Email
Re: Tryed Making a Heal ultimate
« Reply #2 on: December 05, 2009, 07:57:05 AM »
native ForcePlayerSuicide(client);
use it instead. fake client command is cheaty way of escaping difficulties which might fail. Ex: there are server side plugins blocking kill command.

Anthony Iacono

  • Lead Developer
  • Administrator
  • Full Member
  • *****
  • Posts: 136
  • Lets make it better.
    • MSN Messenger - anthonyiacono@gmail.com
    • View Profile
    • My Blog
    • Email
Re: Tryed Making a Heal ultimate
« Reply #3 on: December 05, 2009, 10:16:12 AM »
Yeah you're right, I actually changed to that after I wrote the tutorial, I just wasn't thinking clearly during it. But if you look at the races it should say ForcePlayerSuicide.