|
Title: Tryed Making a Heal ultimate Post by: Martin Texno 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: 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); } } } Title: Re: Tryed Making a Heal ultimate Post by: Anthony Iacono on December 01, 2009, 05:31:40 PM Hey,
First off: Code: new health_level=War3_GetSkillLevel(client,race,1); Should be:Code: new health_level=War3_GetSkillLevel(client,race,3); Since 0==skill 1, 1==skill 2, 2==skill 3, 3==ultimateThere actually isn't a built in system for health. This is how I would do it: Code: 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: iHealthAdded[client]=0; fLastUsed[client]=0.0; Let me know if you don't understand. Title: Re: Tryed Making a Heal ultimate Post by: stinkyfax 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. Title: Re: Tryed Making a Heal ultimate Post by: Anthony Iacono 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.
|