AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   allow only to heal up to 100? (https://forums.alliedmods.net/showthread.php?t=12500)

Bone 04-16-2005 23:18

allow only to heal up to 100?
 
i successfulyl added medic into my rp plug in so they heal by 50 and gotta wait 30 seconds to heal someone again

but how do i make it so that lets say someone has 90 health and u heal em instead of haveing 140 it only goes to 100?

v3x 04-16-2005 23:22

Code:
if(get_user_health(id) >= 100) {     if(get_user_health(id) > 100 {         set_user_health(id,100)     }     remove_task(player)     return PLUGIN_HANDLED }

Bone 04-16-2005 23:28

damn was alot easier then i thougt

v3x 04-16-2005 23:32

Hehe .. :P

Bone 04-16-2005 23:34

ummm damn i thoughti had it but guess not i get

invalid expression assumned zero

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

v3x 04-16-2005 23:40

Code:
    if(get_user_health(id) > 100 {
Missing a ). Also, use my method.. ;)

Bone 04-17-2005 12:29

what do you mean im missing a }.. where

and i dont get how to do your method, here ill post my code i had ebfore that worked that just healed by 50, and can u add ur code into it so that it works?

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; }

thanks tons if you can

BioHazardousWaste 04-17-2005 13:30

Hey man, i'm a nub too, just wrote a healing script last night, so this SHOULD work, but again i'm a nub so forgive me if it doesn't, and please someone correct me if i'm wrong.. anyways, your code:

Code:
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; }
hmm, obviously you've ripped this out of the middle of you code because you are missing variable and stuff. Nice idea btw with the timer, didn't know how that works, but i like it :D OK, my code (ps, sorry I learned vb first so I still tend to use vb convieniences, which are a tad different then most):

Code:
//Include files #include <amxmodx> #include <fun> new CanHeal[32] //Initializing Plugin (main) public plugin_init() {     register_plugin("MedicHeal", "1.00", "Steve0")//Register plugin     register_concmd("S_MedicHeal", "MedicHeal") //S_Heal is a console command that calls the MedicHeal function.         for (new i=0; i<32; i++)         CanHeal[i] = 1     } public MedicHeal(id) //passes in ID of player who called command {     //vars     new OldHealth, NewHealth         //If player can heal     if(CanHeal[id])     {         //get old health, add 50, set new health         OldHealth = get_user_health(id)         NewHealth = OldHealth + 50         set_user_health(id, NewHealth)         //Make sure user doesn't have over 100 health         if(get_user_health(id) > 100)             set_user_health(id, 100)         //set heal as unusable, set timer to enable heal         CanHeal[id]=0         set_task(30.0, "SpawnHeal", id)         return PLUGIN_HANDLED     }     return PLUGIN_HANDLED } public SpawnHeal(id) {       CanHeal[id] = 1//set heal as usuable     client_print(id, print_chat, "Healing ability now available!")//Alert user that heal is available }

Should work as is, compiled fine.


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

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