AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Can't figure this out (https://forums.alliedmods.net/showthread.php?t=5441)

Razor 09-01-2004 15:03

Can't figure this out
 
I seem to be having some difficulty with my code, i've tested it with many different methods, and yet still it doesn't work. All i'd like for it to do is speak Danger.wav when hp is below 20. Take a look at the following code

Code:

#include <amxmodx>
#include <fun>

#define MAX_PLAYERS 32


public plugin_init() {
        register_plugin("Environment Status","0.1","Lloyd Banks")
        set_task(1.0,"check_status")
}


public check_status(id)
{
        new iPlayer
        new iPlayers[MAX_PLAYERS]
        new iNumPlayers
        get_players(iPlayers,iNumPlayers)
        if (get_user_health(iPlayer) < 20)
                {
                        new name[33]
                        get_user_name(0, name, 32)
                        client_print(id, print_chat, "Careful %s, Your hp is low!", name)
                        client_cmd(id, "spk fvox/danger.wav")
                }
       
   
}

Anybody see something I don't ?

Razor 09-01-2004 15:44

Also I seem to have posted a glitch on the
Code:

set_task(1.0,"check_status")
I've corrected and compiled that as
Code:

set_task(1.0,"check_status",846,"",0,"b")
Now i've compiled it as this, but when run in the server, every second it speaks fvox/danger.wav, I do not want it to do this, I want it to do this whenever the hp is BELOW 20. [/code]

Freecode 09-01-2004 15:56

Code:
public check_status() {    new players[32],inum    get_players(players,inum)    for(new x = 0; x < inum; x++)    {       if (get_user_health(players[x]) < 20)       {          new name[33]          get_user_name(players[x], name, 32)          client_print(players[x], print_chat, "Careful %s, Your hp is low!", name)          client_cmd(players[x], "spk fvox/danger.wav")       }    } }

Razor 09-02-2004 15:08

Thank you Freecode, that works beautifully, I also have 1 more problem I come across when I'm trying to use set_task to time certain events.
In the following code, I'm trying to make a 2 second interval between functions :

Code:
#include <amxmodx> #include <fun> #define MAX_PLAYERS 32 //will be used later on public plugin_init() {      register_plugin("Environment Status","1.10","Lloyd Banks")      //register_event("Damage","event_damage","b") // Used in another part of script      set_task(12.0,"event_damage",846,"",0,"b")        register_event("DeathMsg","event_death","b") } public event_death(id) {     client_cmd(id, "spk fvox/beep.wav")     set_task(2.0,"do_beep2",849,"",0,"b")     return PLUGIN_CONTINUE } public do_beep2(id) {     client_cmd(id, "spk fvox/beep.wav")     set_task(2.0,"do_beep3",850,"",0,"b")     return PLUGIN_CONTINUE } public do_beep3(id) {     client_cmd(id, "spk fvox/beep.wav")     set_task(2.0,"do_flatline",851,"",0,"b")     return PLUGIN_CONTINUE } public do_flatline(id) {     client_cmd(id, "spk fvox/flatline.wav")     return PLUGIN_HANDLED }

I believe thats supposed to work, but whenever I've been killed, no sound is played. This is one problem that has plagued me for a while as well. Have any solutions?


All times are GMT -4. The time now is 17:13.

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