Author Topic: Script_Revive (UPDATED)  (Read 8025 times)

You should probably make sure that the target's player doesn't exist before reviving them.
This is what I was suggesting before.

die in dm as host or admin
revive self
kill people
win round
repeat
Or you just... F7 (or F8 can't remember)

You should probably make sure that the target's player doesn't exist before reviving them.
alright, once I get home from vacation I'll add this

I asked you to reopen you Coding Help topic for a reason..
« Last Edit: March 28, 2015, 06:55:14 PM by Greek2me »

Congrats on your first addon, lets take a look at the code for a moment:

function servercmdrevive(%client, %tar) {
   %tar = findclientbyname(%tar);
   //we want to check if the player is admin so he can't go apestuff and revive his whole team
   // Try to steer away from ugly looking code, just use four-spaced tabs, and make a new line before & after braces
   if(!%client.isAdmin) {
      return; }
      //is the target even existent? are we even existent? are we a dream?
   if(!isObject(%tar)){
      messageclient(%client,'',"<color:ff0000>Target is invalid");
      return;
   }
   // An easier, and better method is to just use %tar.player.instantRespawn()
   %tar.setdead(0);
   %tar.setlives(-1);
   %tar.spawnplayer();
   // Its best to try to use \cN, where N can be anything from 0-9 for some pre-defined colors
   // For example: \c0 is red and \c3 is green. You should only use hexadecimal color values for very specify colors.
   // You can type /colortest in-game to see all the color codes.

   messageall('',"<color:ffffff>" @ %tar.name SPC "<color:00ff00>was revived by<color:ffffff>" SPC %client.name);
   //anti-abuse measure
   echo(%client.name SPC "revived" SPC %tar.name);
}

My comments are bolded. Just keep practicing, and don't make bad habits. Good luck.

This is pretty cool and all. But I need something like an item you can equip to revive dead players in a minigame...or something

Please don't copy this, but here is an example of your code I made as a copy, I just want to show you how this functions. Works like yours but has some explainations for most of the things.

wait holdup why do you need 3+ people to fix syntax errors

So i can now revive a bud when he is shot.


I am ze medic

wait holdup why do you need 3+ people to fix syntax errors
There were no syntax errors. They were just helping him out, telling him some better ways to do some things and some better coding practice in general.


Added impede command and a check to see if the target is dead. You can no longer revive players who are still alive.
Usage of impede: /impede targetname amount

In the code, not sure if %tar.player.addhealth("-" @ %dmg); would work as a string

but, you could also try %tar.player.addhealth(-mAbs(%dmg));
This automatically makes the number become positive no matter what. The "-" will automatically make it negative.

It works, I've tested it.
I'm kind of surprised it actually worked.
Also, I don't want to remove the possibility of adding health to players by doing /impede setro -10

You can still do /impede Viso -100 and it will still do it from my code, same as /impede Viso 100, this will just turn it to -100 still.
Well from what I see in your code, what if someone goes /impede viso -100, then the add health stuff is now %player.addHealth(--100);