Raised This Month: $ Target: $400
 0% 

regen help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mini_Midget
Veteran Member
Join Date: Jan 2006
Location: It's a mystery.
Old 06-29-2006 , 08:45   regen help
Reply With Quote #1

i'm pretty sure this works but ingame, nothing happens...
what i'm trying to do is have an armour regen which regens ur armour every 4 seconds, and everyone 4 seconds it regens 7 ap with a .wav and the screen having a teal hud
(the precaching part wouldn't be needed to show as i know it will work)
Code:
public client_putinserver(id)     {     if(task_exists(id)) {         remove_task(id)     }     set_task(4.0 , "add_armour" , id , _ , _ , "b") } public add_armour(id)     {     if(!is_user_alive(id)) {         return PLUGIN_CONTINUE     }     if(id != 0) {         new ap = get_user_armor(id) + 7)         if(hp >= 100) {             set_user_armor(id , 100)             } else {                         set_user_armor(id , ap);             emit_sound(id,CHAN_VOICE,"misc/recharge.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)             message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, id)             write_short(1<<10)             write_short(1<<10)             write_short(0x0000)             write_byte(0)             write_byte(175)             write_byte(175)             write_byte(75)             message_end()         }     }     return PLUGIN_CONTINUE }
__________________
It's a mystery.
Mini_Midget is offline
Willmaker
Senior Member
Join Date: Dec 2004
Location: Sydney, Australia
Old 06-29-2006 , 11:56   Re: regen help
Reply With Quote #2

You could try:
Code:
public client_putinserver(id)     {     if(task_exists(id)) {         remove_task(id)     }     set_task(4.0 , "add_armour" , id , _ , _ , "b") } public add_armour(id)     {     if(!is_user_alive(id)) {         return PLUGIN_CONTINUE     }     if(id != 0) {         new ap = get_user_armor(id)         if(hp >= 100) {             set_user_armor(id , 100)         } else {             ap += 7             set_user_armor(id , ap);             emit_sound(id,CHAN_VOICE,"misc/recharge.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)             message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, id)             write_short(1<<10)             write_short(1<<10)             write_short(0x0000)             write_byte(0)             write_byte(175)             write_byte(175)             write_byte(75)             message_end()         }     }     return PLUGIN_CONTINUE }

What I changed was:
Code:
new ap = get_user_armor(id) + 7)
as it had a closing bracket, but not an opening one.

And with:
Code:
if(hp >= 100) {
Did you only players to regen when they had 100 health or more, or did you want to limit the armor to a max of 100?
__________________
GargStudios.net - Australian SvenCoop/Ent Server with Time Based Rewards
Willmaker is offline
Send a message via ICQ to Willmaker Send a message via AIM to Willmaker Send a message via MSN to Willmaker Send a message via Yahoo to Willmaker
Mini_Midget
Veteran Member
Join Date: Jan 2006
Location: It's a mystery.
Old 06-29-2006 , 23:03   Re: regen help
Reply With Quote #3

cheers man, works now
the max regen limit was 100, i might set it lower like 75
a bug i found was if you had 97 armor
it would regen it to 104 but then it will go back to 100 for the next regen time
but i don't mind this bug
__________________
It's a mystery.
Mini_Midget is offline
Willmaker
Senior Member
Join Date: Dec 2004
Location: Sydney, Australia
Old 06-29-2006 , 23:14   Re: regen help
Reply With Quote #4

Code:
public client_putinserver(id)     {     if(task_exists(id)) {         remove_task(id)     }     set_task(4.0 , "add_armour" , id , _ , _ , "b") } public add_armour(id)     {     if(!is_user_alive(id)) {         return PLUGIN_CONTINUE     }     if(id != 0) {         new ap = get_user_armor(id)         if(hp >= 100) {             set_user_armor(id , 100)         } else {             ap += 7             if(ap >= 100){                 ap = 100             }             set_user_armor(id , ap);             emit_sound(id,CHAN_VOICE,"misc/recharge.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)             message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, id)             write_short(1<<10)             write_short(1<<10)             write_short(0x0000)             write_byte(0)             write_byte(175)             write_byte(175)             write_byte(75)             message_end()         }     }     return PLUGIN_CONTINUE }

This will eliminate that bug. It will check if the new ap value is over 100, and if it is, will set it back to 100. So armor will never go past 100.
__________________
GargStudios.net - Australian SvenCoop/Ent Server with Time Based Rewards
Willmaker is offline
Send a message via ICQ to Willmaker Send a message via AIM to Willmaker Send a message via MSN to Willmaker Send a message via Yahoo to Willmaker
Mini_Midget
Veteran Member
Join Date: Jan 2006
Location: It's a mystery.
Old 06-30-2006 , 04:08   Re: regen help
Reply With Quote #5

thxs man, works nicely
it compiles with no errors, what i want to do is only regen above 20ap
so if my armor is 15, it stops the regen
i'm not the best scripter so just do a little check of it as i can't be fucked
getting shot down to less than 20ap just to see if it works
(there was this cool plugin where it drains ur armor first than your health so its like you have 200 hp, i'm trying to do that but having errors, i'll post it later)
Code:
public client_putinserver(id)     {         if(task_exists(id)) {         remove_task(id)     }     set_task(4.0 , "add_armour" , id , _ , _ , "b") } public add_armour(id)     {     if(!is_user_alive(id) && !is_user_connected(id)) {         return PLUGIN_CONTINUE     }     if(id != 0) {         new ap = get_user_armor(id)         if(ap >= 100) {             set_user_armor(id , 100)             } else {             ap += 7             if(ap >= 100){                 ap = 100             }             set_user_armor(id , ap);             emit_sound(id,CHAN_VOICE,"misc/recharge.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)             message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, id)             write_short(1<<10)             write_short(1<<10)             write_short(0x0000)             write_byte(0)             write_byte(175)             write_byte(175)             write_byte(75)             message_end()         }         if(ap <= 20) {             set_user_armor(id, ap)             emit_sound(id,CHAN_VOICE,"ambience/sparks.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)             client_print(id, print_chat, "[AMXX] Your armor can't recharge now")         }             }     return PLUGIN_CONTINUE }
__________________
It's a mystery.
Mini_Midget is offline
Willmaker
Senior Member
Join Date: Dec 2004
Location: Sydney, Australia
Old 06-30-2006 , 04:23   Re: regen help
Reply With Quote #6

Code:
public client_putinserver(id)     {         if(task_exists(id)) {         remove_task(id)     }     set_task(4.0 , "add_armour" , id , _ , _ , "b") } public add_armour(id)     {     if(!is_user_alive(id) && !is_user_connected(id)) {         return PLUGIN_CONTINUE     }     if(id != 0) {         new ap = get_user_armor(id)         if(ap >= 100) {             set_user_armor(id , 100)         }         else if(ap <= 20) {             emit_sound(id,CHAN_VOICE,"ambience/sparks.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)             client_print(id, print_chat, "[AMXX] Your armor can't recharge now")         }else{             ap += 7             if(ap >= 100){                 ap = 100             }             set_user_armor(id , ap);             emit_sound(id,CHAN_VOICE,"misc/recharge.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)             message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, id)             write_short(1<<10)             write_short(1<<10)             write_short(0x0000)             write_byte(0)             write_byte(175)             write_byte(175)             write_byte(75)             message_end()         }             }     return PLUGIN_CONTINUE }

That should do it, but I think it will keep saying "Your armor can't recharge now" every 4 secs.
__________________
GargStudios.net - Australian SvenCoop/Ent Server with Time Based Rewards
Willmaker is offline
Send a message via ICQ to Willmaker Send a message via AIM to Willmaker Send a message via MSN to Willmaker Send a message via Yahoo to Willmaker
Mini_Midget
Veteran Member
Join Date: Jan 2006
Location: It's a mystery.
Old 06-30-2006 , 05:53   Re: regen help
Reply With Quote #7

thxs man

i just found another bug with the script
in some maps like aim_sk_ak_m4, you're stripped with nothing and then it equips you with crap
you always have 0ap at every new round and the msg pops up
but this happens 2/5 of the time
i was think if it is possible to do something like
Code:
else if(ap <= 20 || ap >= 5) {
just to avoid the small bug

EDIT
nvm... that just made it worse...
a few post ago you said that the msg will come up every 4 second
yeah, it does when you have less than 20ap
__________________
It's a mystery.

Last edited by Mini_Midget; 06-30-2006 at 19:29.
Mini_Midget is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:58.


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