AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to register a bool variable to catch flashlight on (https://forums.alliedmods.net/showthread.php?t=217953)

Moody92 06-09-2013 13:10

How to register a bool variable to catch flashlight on
 
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)

}

public function() {
    new 
bool:IsFlashLightOn
    IsFlashLightOn 
= ???
    
    if ( 
bool:IsFlashLightOn == true ) { 
        
client_cmd (31"impulse 100")
    }
    else {
        
// Do nothing
    
}
}} 

I just started to learn pawn as I'm free in this summer,
I know this is a total mess :P ..Just doing it for learning purposes, but how to catch the player when his flashlight is on ?

President 06-09-2013 13:21

Re: How to register a bool variable to catch flashlight on
 
register_impulse(100, "HookFlashlight");

Smatify 06-09-2013 13:22

Re: How to register a bool variable to catch flashlight on
 
PHP Code:

public plugin_init()
{
    
register_impulse(100"your_function")
}

public 
your_function(id)
{    
    
client_cmd (id,"impulse 100"



Moody92 06-09-2013 13:25

Re: How to register a bool variable to catch flashlight on
 
Quote:

Originally Posted by Smatify (Post 1967564)
PHP Code:

public plugin_init()
{
    
register_impulse(100"your_function")
}

public 
your_function()
{    
    
client_cmd (31,"impulse 100"



So this is going to close the flashlight once it's ON.

Thanks alot. but the thing is no such a thing called register_impulse..

EDIT: Nvm, didn't include engine

President 06-09-2013 13:29

Re: How to register a bool variable to catch flashlight on
 
Quote:

Originally Posted by Smatify (Post 1967564)
PHP Code:

public plugin_init()
{
    
register_impulse(100"your_function")
}

public 
your_function(id)
{    
    
client_cmd (id,"impulse 100"



-->
PHP Code:

#include <amxmodx>
#include <engine>

public plugin_cfg() register_impulse(100"HookFlashlight");
public 
HookFlashlight(id) return PLUGIN_HANDLED


Moody92 06-09-2013 13:32

Re: How to register a bool variable to catch flashlight on
 
Quote:

Originally Posted by President (Post 1967571)
-->
PHP Code:

#include <amxmodx>
#include <engine>

public plugin_cfg() register_impulse(100"HookFlashlight");
public 
HookFlashlight(id) return PLUGIN_HANDLED


I get it now. thanks

Kia 06-09-2013 13:32

Re: How to register a bool variable to catch flashlight on
 
Quote:

. but the thing is no such a thing called register_impulse..
Quote:

register_impulse
Engine (engine.inc)

Description

register_impulse - Registers a client impulse to a function.

Syntax

register_impulse ( impulse, function[] )

Type

Forward

Notes

When an impulse is started on a client, the client's id is forwarded to the named function.

This is a blocking forward (PLUGIN_HANDLED will block the operation).

a7811311622 06-09-2013 23:40

Re: How to register a bool variable to catch flashlight on
 
register_event("Flashlight", ...) and read_data(1).

fysiks 06-09-2013 23:45

Re: How to register a bool variable to catch flashlight on
 
Quote:

Originally Posted by a7811311622 (Post 1967889)
register_event("Flashlight", ...) and read_data(1).

That event only updates the HUD. This will not do any good if you want to modify the how the flashlight works.

a7811311622 06-10-2013 00:51

Re: How to register a bool variable to catch flashlight on
 
Quote:

Originally Posted by fysiks (Post 1967890)
That event only updates the HUD. This will not do any good if you want to modify the how the flashlight works.

Sorry, I'm confused about topic name, it looks like get but his code is set...


All times are GMT -4. The time now is 16:21.

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