AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Nightvision Color (https://forums.alliedmods.net/showthread.php?t=51817)

SAMURAI16 02-24-2007 12:53

Nightvision Color
 
hi, i tryed to change the NightVision color, but i don't dunno 100 %
my code:
Code:

#include <amxmodx>
#include <amxmisc>


#define PLUGIN "Test nvg color"
#define VERSION "1.0"
#define AUTHOR "SAMURAI"

new pnumenable;
new pcolor;
new pnumradius
new pnumdecay

public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
   
    register_event("NVGToggle","open_nvg","be");
   
    pnumenable = register_cvar("custom_nvg","1");
    pcolor = register_cvar("custom_nvg_rgb","255 0 255");
    pnumradius = register_cvar("custom_nvg_radius","60");
    pnumdecay = register_cvar("custom_nvg_decay","70");
   
}

public open_nvg(id)
{
    if( (!id) || !is_user_connected(id))
    return PLUGIN_CONTINUE;
   
    if(!get_pcvar_num(pnumenable))
    return PLUGIN_CONTINUE;
   
    new origin[3];
    get_user_origin(id,origin,3)
   
    new color[17];
    get_pcvar_string(pcolor,color,16);
   
    new iRed[5], iGreen[7], iBlue[5]
    parse(color,iRed,4,iGreen,6,iBlue,4)
   
    message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
    write_byte(TE_DLIGHT);
   
    write_coord(origin[0]);
    write_coord(origin[1]);
    write_coord(origin[2]);
   
    write_byte(get_pcvar_num(pnumradius))
   
    write_byte(str_to_num(iRed))
    write_byte(str_to_num(iGreen))
    write_byte(str_to_num(iBlue))
   
    write_byte(7)
    write_byte(get_pcvar_num(pnumdecay))
   
    message_end();
   
    return PLUGIN_CONTINUE;
}

Problem: The Nighvision color won't changed, it's green but when i stop the nightvision appear for 1 second my TE_DLIGHT . Any ideia for what message type i should use to can change the nightvision color.

thanks

hip_hop_x 02-24-2007 19:19

Re: Nightvision Color
 
replace TE_DLIGHT from write_byte(TE_DLIGHT); with 27.
And will be: write_byte(27);


Te_DLIGHT
Code:
message_begin(MSG_ONE, SVC_TEMPENTITY, {0, 0, 0}, id) write_byte(27) // TE_DLIGHT write_coord(origin[0]) // X coord write_coord(origin[1]) // Y coord write_coord(origin[2]) // Z coord write_coord(radius) // radius write_byte(250) // red write_byte(0) // green write_byte(0) // blue write_byte(250) // brightness write_byte(10) // life write_coord(0) // decay rate message_end()
I tried to make a plugin but doesn't work :(. Maybe you will find a way to make it to work.

regalis 02-24-2007 21:12

Re: Nightvision Color
 
Hi, i have no idea to solve your problem.
But i have a source where you can probably find a solution ;)
Look at here: http://forums.alliedmods.net/showthr...ght=specialist
This superhero (from Superhero Mod, i hope you know that) have an blue NVG.
I have this one installed and it works very nice..

greetz regalis

SAMURAI16 02-25-2007 03:21

Re: Nightvision Color
 
hip_hop_x it's better to use TE_DLIGHT instead of "27" to prevent hardcode. TE_DLIGHT it's alearly defined in message_const "27" .

regalis thanks for information, i will try


Mini_Midget 03-01-2007 05:45

Re: Nightvision Color
 
Just wondering, did you fix this in the end SAMURAI16?
I could use this in the future if it works.

SAMURAI16 03-01-2007 08:07

Re: Nightvision Color
 
no.. i tryed new 3 ways to create this plugin but doesen't works correct

mogel 03-01-2007 11:46

Re: Nightvision Color
 
Moin,

Code:

public plugin_init() {
    register_clcmd("nightvision","ToggleNVG")
}
// ------------------------------------------------------------------------------
//
// weißes (!!) Nachtsichtgerät
// Idee von http://forums.alliedmods.net/showthread.php?t=51817
// dazu einfach lokal eine Lichtquelle alle 100ms erzeugen (oder weniger)
public ToggleNVG(player) {
    if (spieler[player][E_S_USENVG])
    {
        StopNVG(player)
    } else
    {
        StartNVG(player)
    }

    return PLUGIN_HANDLED
}
public StartNVG(player) {
    if ((roundstatus != RS_RUNNING) || (spieler[player][E_S_USENVG]) || !is_user_connected(player)) return PLUGIN_CONTINUE
   
    new name[32]
    get_user_name(player, name, 32)
   
    spieler[player][E_S_USENVG] = 1
   
    // anschalten
    set_task(0.2, "ShowNVG", player + 100, name, 32, "b")    // another task id for each player
   
    return PLUGIN_CONTINUE
}
public StopNVG(player) {
   
    // bereits abgeschaltet
    if (!spieler[player][E_S_USENVG]) return PLUGIN_CONTINUE
   
    // jetzt wirklich ausschalten
    remove_task(player + 100)
   
    spieler[player][E_S_USENVG] = 0

    return PLUGIN_CONTINUE
}
public ShowNVG(player[]) {
    new id = get_user_index(player)
   
    if (!is_user_connected(id)) return

    // Radius setzen ... tote Spieler sehen mehr
    new radius = 50
    if (!is_user_alive(id)) radius = 100
   
    // jetzt die Position holen
    new origin[3]
    get_user_origin(id, origin)
   
    // Monitoring nicht vergessen
    if (fxinuse) return
    fxinuse = 1
   
    // lokale Lichtquelle erzeugen
    message_begin(MSG_ONE, SVC_TEMPENTITY, {0,0,0}, id)
   
    write_byte(27)
   
    write_coord(origin[0])
    write_coord(origin[1])
    write_coord(origin[2])
   
    write_byte(radius)
   
    write_byte(100)
    write_byte(100)
    write_byte(100)
   
    write_byte(5)        // Life
    write_byte(0)        // Decay
   
    message_end()
   
    fxinuse = 0
}

hand, mogel

SAMURAI16 03-01-2007 13:40

Re: Nightvision Color
 
1) it's corrupted and i want to know are defined missed variables
2) i don't thing this will work because on "public ToggleNVG(player)" it's checked this :
PHP Code:

if (spieler[player][E_S_USENVG])
    {         
StopNVG(player

And where is defined to see when start the nightvision ?

mogel 03-01-2007 15:40

Re: Nightvision Color
 
Hmm,

sorry ... it is a fast copy from my plugin

Code:

spieler[player][E_S_USENVG]

a simple boolean to check if the player already use the nvg

roundstatus != RS_RUNNING

it is a enum to remember the round-state ... running (between roundstart & roundend) and not running (the other time) ... the nvg can only start if the round running

Code:

enum ROUNDSTATUS {
        RS_END,
        RS_RUNNING,
        RS_UNDEFINED
}
new ROUNDSTATUS:roundstatus = RS_UNDEFINED

Code:

enum E_SPIELER {
        E_S_LEVEL,                // Level des Spielers
        E_S_SPEED,                // geschwindgikeit des Spieler
        E_S_MODEL,                // Model des Zombies bzw. Typ
        E_S_HOSTAGE_KILLED,        // soviele Geisel diese Runde gekillt
        E_S_HOSTAGE_RESCUED,        // soviele gerettet
        E_S_BOMB_PLANTED,        // soviele Bomben gelegt
        E_S_BOMB_DEFUSED,        // soviele entschärft
        E_S_PINGWARN,                // Ping-Warnungen
        E_S_SPAWNPROTECT,        // 1 wenn der Bot geschützt ist beim Spawn
        E_S_READVAULT,                // Spieler-Daten muss noch aus dem Vault gelesen werden
        E_S_LASTFLARE,                // letzte Fackel gelegt .. nur alle 5 Sekunden möglich
        E_S_HEALTH,                // Health des Spielers bzw. Bots
        E_S_USENVG                // NVG wird bereits benutzt
}
new spieler[33][E_SPIELER]

hand, mogel

regalis 03-02-2007 05:25

Re: Nightvision Color
 
1 Attachment(s)
I have looked at the source from the SHERO Specialist and made a plugin from this...thanks goes to
Quote:

// The Specialist - Weapon Specialist
// Made By Eyeless
// http://eyeless.freelinuxhost.com/
Now when a player say /nvg or .nvg he'll get a blue nightvision...


greetz regalis


All times are GMT -4. The time now is 00:37.

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