AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Unapproved/Old Plugins (https://forums.alliedmods.net/forumdisplay.php?f=27)
-   -   Resupplied (https://forums.alliedmods.net/showthread.php?t=49659)

Trent-Resnor 01-10-2007 00:46

Resupplied
 
1 Attachment(s)
RESUPPLIED
Version 0.8

Changes:
0.8 - Recoded around ResetHUD Loop - Thanks Teame06 and VEN
0.7 - Properly declared precache sound. - Thanks DoomBringer
0.6 - Corrected Code accordingly. - Thanks DoomBringer & Emp`
0.5 - Initial Post and release.

Test Resupplied Plugin:
209.160.72.191:27035 >> Sven-Coop Server

Running with AMX Mod X 1.76c... Earlier versions might be supported.

Modules:

Fun
Amxmodx

Purpose:
The purpose of resupplied, is to provide admins and or users with a new gameplay style. With resupplied, the admin will be able to turn on Spawn protection, which in many cases would help in those sven coop maps where the monsters and mobs spawn right beside or are camping in spawn. Not only is Spawn Protection a feature, but so is the Resupplying of ammo to the players. The resupply method is carried out the same way but instead of spawn protection, players will be able to get ammo bonuses on the field before spawn, to give them that extra kick to survive a little longer. The resupply code goes by a random number that is generated every time its called (by the timer). The players have 16 distinct chances to what they need, such as extra health, and extra ammo.

Cvars:
spawnprotection_timer <0 - 255> Default: 10.0
resupply_timer <0 - 255> Default: 60.0
----
Note: The timers can go higher then 255 (more like float values) it's just a suggested max :) and 0 disables the timer, meaning it will and would be turned off.

Note: Cleaned up the code abit according to emps` & Doombringers suggestions.


Emp` 01-10-2007 01:24

Re: Resupplied
 
clean up code a bit (use switches and don't set a task of 0.0)

also for resupply (not sure how SC works, if there are more than 1 resethud events) you should either A: check if the task exists already for that player and don't make a new task or B: check if the task exists for that player and remove the old task

edit: also doesn't look like you need to include amxmisc

Trent-Resnor 01-10-2007 07:41

Re: Resupplied
 
There we go, re uploaded. Not sure if I corrected the A: check if the task exists already for that player and don't make a new task. But I did fix the rest of the code according to your suggestions emp`, switch instead of if statements and thanks for pointing out that i didn't need amxmisc :D also the task of 0.0 should be changed to 1.0. Thanks.

Deviance 01-10-2007 08:21

Re: Resupplied
 
Code:
public spawn_protection_on(id) {     if(is_user_alive(id)) {         set_user_godmode(id,1)         set_hudmessage(212, 255, 255, 0.58, 0.0, 0, 6.0, get_cvar_float("spawnprotection_timer"), 2.0)         show_hudmessage(id, "SPAWN PROTECTION")         set_task(get_cvar_float("spawnprotection_timer"),"spawn_protection_off",id)         set_user_rendering(id,kRenderFxGlowShell,0,255,0,kRenderNormal,25)     } }
Should be
Code:
public spawn_protection_on(id) {     if(is_user_alive(id)) {         set_user_godmode(id,1)         set_hudmessage(212, 255, 255, 0.58, 0.0, 0, 6.0, get_pcvar_float(spawn_protect), 2.0)         show_hudmessage(id, "SPAWN PROTECTION")         set_task(get_pcvar_float(spawn_protect),"spawn_protection_off",id)         set_user_rendering(id,kRenderFxGlowShell,0,255,0,kRenderNormal,25)     } }
Also you can't call precache_sound() inside plugin_init(), you need to use plugin_precache().

Trent-Resnor 01-10-2007 08:31

Re: Resupplied
 
Thanks for pointing those out. Greatly appreciated ! :D

Deviance 01-10-2007 10:30

Re: Resupplied
 
Code:
public spawn_protection_off(id) {     if(is_user_alive(id)) {         precache_sound("items/suitchargeok1.wav")         set_user_godmode(id,0)         set_user_rendering(id,kRenderFxNone,0,0,0,kRenderNormal,25)         emit_sound(0,CHAN_AUTO,"items/suitchargeok1.wav",1.0,ATTN_NORM,0,PITCH_NORM)     } }
You can't use precache_sound() like this. You have to use it in plugin_precache()

Code:
public plugin_precache() {     precache_sound("items/suitchargeok1.wav") }

Trent-Resnor 01-10-2007 12:39

Re: Resupplied
 
Thanks for that correction :D !

VEN 01-10-2007 15:29

Re: Resupplied
 
  1. Do you aware that for every alive player every HUD reset you creating an additional loop task?
  2. Why would you want to emit a sound on all clients while your protection function is for a specific client?

Trent-Resnor 01-10-2007 16:46

Re: Resupplied
 
Thanks for pointing that out ven.

Emp` 01-10-2007 19:53

Re: Resupplied
 
you should just do
Code:

        new health=get_user_health(id)
//..skip a few lines
                        case 15: { set_user_health(id, health+10); }
                        case 16: { set_user_health(id, health+5); }

instead of getting their health twice


All times are GMT -4. The time now is 20:32.

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