AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   healing by 50? (https://forums.alliedmods.net/showthread.php?t=12468)

Bone 04-16-2005 14:36

healing by 50?
 
I am adding medic into my rp plug in i got it working except instead of makign people health automatically 100 i want it to heal by 50 but when i changed

Code:
public medicheal(id) {         set_user_health(id,100)       return 1; }


into

Code:
public medicheal(id) {         set_user_health(player,id + 10)       return 1; }

I get a few errors.. i dont get whats wrong with it anyone know?

Belsebub 04-16-2005 14:41

post what errors you get

Bone 04-16-2005 14:42

i get

undefined symbol health

expected tokenn ; but found )

Belsebub 04-16-2005 14:46

you gotta do like this:

Code:
new health = get_user_health(id) set_user_health(id,health + 10)

v3x 04-16-2005 16:40

Or, you can make it even shorter.
Code:
set_user_health(id, get_user_health(id) + 10)

PS: I showed you how to do this in your other topic you posted. :P

Bone 04-16-2005 20:07

thanks worked perfect :-D

yeah i know you showed me.. but it was the new health thing i was putting it at wrong spot :-/ thanks thou,

now how could i go about making it so like he can only heal every minute i was thinking of going bout it and make like

Code:
new canheal = 1;

Code:
public medicheal(id) { if(canheal = 0) {             client_print(id,print_chat,"* [MCMD] You must wait to heal again^n");         }         else {  new health = get_user_health(id)    set_user_health(id,health + 50)  set_task(0.1,"abletoheal",player);       return 1; }

Code:
public abletoable(id) {     canheal = 1; }         return PLUGIN_HANDLED; }

would something like that be correct im not quite sure if that would work or not.

v3x 04-16-2005 20:15

Something like this. I'm not that great with set_task() yet, so don't yell at me if I'm wrong! :P
Code:
new canheal[33] public myFunction(id) {     // ..     canheal[id] = 0     set_task(60.0,"abletoheal",id)     return PLUGIN_HANDLED } public abletoheal(id) {     canheal[id] = 1     return PLUGIN_HANDLED }

Bone 04-16-2005 20:20

i think i figured it out, i just formatted so gotta wait to test it but here is what i did

Code:
 //heal again  new canheal = 1;

Code:
 ////////////////////////////////////////////////////////////////////  // Medical  //////////////////////////////////////////////////////////////////  public handlesaytwo(id) {     new arg[64], arg1[32], arg2[32];     read_args(arg,63); // get text     remove_quotes(arg); // remove quotes     strtok(arg,arg1,255,arg2,255,' ',1); // split text into parts     // eliminate extra spaces from the text     trim(arg2); // our right side     // if player is dead     if(is_user_alive(id) == 0) {         return PLUGIN_CONTINUE;     }     //     // Medic     //     if(equali(arg1,"") == 1) {         if(is_user_alive(id) == 0) {             client_print(id,print_chat,"* [MCMD] You must be alive to use this command^n");             return PLUGIN_HANDLED;         }         if(isMedic(id) == 0) { // if player is not a Medic             client_print(id,print_chat,"* [MCMD] Only Medics can heal other players^n");             return PLUGIN_HANDLED;         }         new player, body, Float:dist = get_user_aiming(id,player,body,9999);         if(player <= 0) { // no entity or is world entity             client_print(id,print_chat,"* [MCMD] Player is invalid or non-existant^n");             return PLUGIN_HANDLED;         }         // if player isn't connected (what happened here?) or player is dead         if(!is_user_connected(player) || !is_user_alive(player)) {             client_print(id,print_chat,"* [MCMD] Player is invalid or non-existant^n");             return PLUGIN_HANDLED;         }         // gotta wait to heal foo'         if(canheal <= 0) {             client_print(id,print_chat,"* [MCMD] You must wait to heal again^n");             return PLUGIN_HANDLED;         }         // not close enough         if(dist > CUFFDIST) {             client_print(id,print_chat,"* [MCMD] You are not close enough to the player^n");             return PLUGIN_HANDLED;         }         if(get_user_health(player) >= 100) { // player at max health             //client_print(id,print_chat,"* [MCMD] This user is already Fully Healed^n");             return PLUGIN_HANDLED;         }         new playername[256];         get_user_name(player,playername,255);         client_print(id,print_chat,"* [MCMD] %s is now healed^n",playername);         client_print(player,print_chat,"* [MCMD] You have been healed^n");         set_task(1.0,"medicheal",player); // delayed heal         return PLUGIN_HANDLED;     }     return PLUGIN_CONTINUE; }

Code:
//////////////////////////////////////////////////////////////////// // Medic Heal ////////////////////////////////////////////////////////////////// public medicheal(id) {        new health = get_user_health(id)    set_user_health(id,health + 50)  canheal = 0;  set_task(30.0, "healagain", id);       return 1; } //////////////////////////////////////////////////////////////////// // Heal Again ////////////////////////////////////////////////////////////////// public healagain(id) {  canheal = 1;  return PLUGIN_HANDLED; }

it all compiled and that so hopefully it works.


All times are GMT -4. The time now is 09:51.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.