Raised This Month: $51 Target: $400
 12% 

Solved [HELP] block duck + another questions


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
nacknic
Senior Member
Join Date: Mar 2019
Old 04-15-2019 , 01:44   [HELP] block duck + another questions
Reply With Quote #1

i try to learning events, i want for now block duck in freezetime.

question 0: for event i need learn all parameters on the event ? or verbal is ok, im ask because all event are const.

question 1: when i duck in freezetime i see my print duck not allowed in freezetime! but, when i try remove the action of the duck entity_set_int(id, EV_INT_button, button & ~IN_DUCK);, not working.

question 2: dont know why but, get_user_name/get_user_info(id,"name"... its set the server name, can i do it post like RegisterHam ?

Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <hamsandwich>

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

new g_countrounds,
    g_nick[32],
    HamHook:g_hamplayerduck; 
public plugin_init() 
{
	register_plugin(PLUGIN, VERSION, AUTHOR);
	register_event("HLTV", "freezetime", "a", "1=0", "2=0");
	register_logevent("roundstart", 2, "1=Round_Start");
	register_logevent("roundend", 2, "1=Round_End");
	DisableHamForward(g_hamplayerduck = RegisterHam(Ham_Player_Duck, "player", "duckFunc"));
	
}

public freezetime(id)
{
	EnableHamForward(g_hamplayerduck);
	new ftime; ftime = get_cvar_num("mp_freezetime");
	get_user_name(id, g_nick, charsmax(g_nick));
	client_print(0, print_chat, "%s freezetime on, please wait: %d", g_nick, ftime);	
}

public roundstart()
{
	DisableHamForward(g_hamplayerduck);
	client_print(0, print_chat, "freezetime off, the round start right now, (Round Num: %d)", g_countrounds);
	g_countrounds++;
}

public roundend()
{
	client_print(0, print_chat, "round end, please wait for the next one");
}

public duckFunc(id)
{
	new button = entity_get_int(id, EV_INT_button);
	if(button & IN_DUCK)
	{
		client_print(id, print_chat, "duck not allowed in freezetime!");
		entity_set_int(id, EV_INT_button, button & ~IN_DUCK);
	}
}
question 3: i understood for all fakemetamethod there engine method to do the same:
Code:
 register_forward(FM_ClientUserInfoChanged, "fwClientUserInfoChanged")
so its fakemeta, how i do the same thing in engine ?

*notice: i decided learn events before fakemeta.

next question 4: i saw in some codes, using id in barket on array like this:
Code:
 
public function(id)
{
new arr[11];
arr[id]  // what the meaning for that ? 
}
in this get_name works, becuase he hvae paramter to to pre = 0 or 1 = post:
Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>

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

new g_nick[11];
public plugin_init() RegisterHam(Ham_Spawn, "player", "HamSpawn", 1); //1 = post

public HamSpawn(id) 
{
	new cid[1]; cid[0] = id;
	new ftime; ftime = get_cvar_num("mp_freezetime");
	new Float:freezetime = float(ftime)
	get_user_name(id, g_nick, charsmax(g_nick));
	client_print(0, print_chat, "hake ya zain");
	if(equali(g_nick, "elad")) set_task(freezetime, "killSomeone", 0, cid, 1);
	else return HAM_HANDLED;
	return HAM_HANDLED;
}

public killSomeone(cid[]) 
{
	client_print(0, print_chat, "%s, meyakim lo mshkim cs 1.6", g_nick);
	user_kill(cid[0]);
}
question 5: there any tutorial for all events ? its hard search all event separately
this sucks:
https://wiki.alliedmods.net/Half-life_1_game_events

Last edited by nacknic; 04-23-2019 at 09:58.
nacknic is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 04-15-2019 , 03:09   Re: [HELP] block duck + another questions
Reply With Quote #2

It seems like you are jumping from basic things (in pawn) and wants to do some advanced stuff..well that reminds me of me, and i think its not really proper way to work, but yeah its fun

Code:
register_event("HLTV", "freezetime", "a", "1=0", "2=0");
then in public freezetime() i think its better to go with player loop, im not sure if freezetime( index ) works there

also im not sure if its the best way to get freezetime...but if it works then its okay..doing freezetime( index ) and then getting name by index, but printing message to all (0) is not the best logic i think
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)

Last edited by JocAnis; 04-15-2019 at 03:11.
JocAnis is offline
nacknic
Senior Member
Join Date: Mar 2019
Old 04-15-2019 , 03:22   Re: [HELP] block duck + another questions
Reply With Quote #3

Quote:
Originally Posted by JocAnis View Post
It seems like you are jumping from basic things (in pawn) and wants to do some advanced stuff..well that reminds me of me, and i think its not really proper way to work, but yeah its fun

Code:
register_event("HLTV", "freezetime", "a", "1=0", "2=0");
then in public freezetime() i think its better to go with player loop, im not sure if freezetime( index ) works there

also im not sure if its the best way to get freezetime...but if it works then its okay..doing freezetime( index ) and then getting name by index, but printing message to all (0) is not the best logic i think
i think its called to early, beacuse of this nit work, the funny thing: when i use RegisterHam its work, i will put later the code her(im not on my pc)
nacknic is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 04-15-2019 , 06:11   Re: [HELP] block duck + another questions
Reply With Quote #4

RegisterHam(Ham_Spawn.. nad HLTV events arent the same...first is called on every client's spawn...hltv is for new round starting (and probably without index)
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)
JocAnis is offline
nacknic
Senior Member
Join Date: Mar 2019
Old 04-15-2019 , 07:00   Re: [HELP] block duck + another questions
Reply With Quote #5

get the nick work her becuase i used 1 = post...
RegisterHam(Ham_Spawn, "player", "HamSpawn", 1);
Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>

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

new g_nick[11];
public plugin_init() RegisterHam(Ham_Spawn, "player", "HamSpawn", 1); //1 = post

public HamSpawn(id) 
{
	new cid[1]; cid[0] = id;
	new ftime; ftime = get_cvar_num("mp_freezetime");
	new Float:freezetime = float(ftime)
	get_user_name(id, g_nick, charsmax(g_nick));
	client_print(0, print_chat, "hake ya zain");
	if(equali(g_nick, "elad")) set_task(freezetime, "killSomeone", 0, cid, 1);
	else return HAM_HANDLED;
	return HAM_HANDLED;
}

public killSomeone(cid[]) 
{
	client_print(0, print_chat, "%s, meyakim lo mshkim cs 1.6", g_nick);
	user_kill(cid[0]);
}
nacknic is offline
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 04-15-2019 , 12:08   Re: [HELP] block duck + another questions
Reply With Quote #6

As they pointed to you, it is possible to do a few options such as the Round will do
Code:
set_task(get_cvar_num("mp_freezetime")
Public himself of FREEZE, do LOOP
Code:
 for (new i = 0; i < ....; i++)
{
        player = players[i]
Just Example for block duck and allow

Code:
#include <amxmodx> 
#include <fakemeta> 

new g_pAllowDuck, g_pAllowJump 

public plugin_init() 
{ 
    register_plugin("Block", "1.0", "Example") 

    register_forward(FM_CmdStart, "fw_CmdStart_Pre", 0) 

    g_pAllowDuck = register_cvar("amx_allow_duck", "0") 
    g_pAllowJump = register_cvar("amx_allow_jump", "0") 
} 

public fw_CmdStart_Pre(id, uc_handle, seed) 
{ 
    if(!is_user_alive(id)) 
    { 
        return; 
    } 

    new iButtons = get_uc(uc_handle, UC_Buttons) 

    if(iButtons & IN_DUCK) 
    { 
        if(get_pcvar_num(g_pAllowDuck)) 
        { 
            return; 
        } 

        set_uc(uc_handle, UC_Buttons, iButtons & ~IN_DUCK) 
        return; 
    } 

    if(iButtons & IN_JUMP) 
    { 
        if(get_pcvar_num(g_pAllowJump)) 
        { 
            return; 
        } 

        set_uc(uc_handle, UC_Buttons, iButtons & ~IN_JUMP) 
    } 
}
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
Old 04-17-2019, 08:05
nacknic
This message has been deleted by nacknic. Reason: miss
nacknic
Senior Member
Join Date: Mar 2019
Old 04-23-2019 , 00:07   Re: [HELP] block duck + another questions
Reply With Quote #7

i found something that work, but im not understood two lines:
Code:
 if( ~iOldButtons & IN_JUMP || ~iOldButtons & IN_DUCK )
1. how server detected ~iOldButtons ? maybe first he ask: if iOldButtons & IN_JUMP or iOldButtons & IN_DUCK and after he remove the buttons ?
Code:
 iOldButtons |= (IN_JUMP | IN_DUCK);
2. why use != and not &= ?

3. what the difference between id to iId ? (i think its just to separate for entity but its same thing).

all plugin:
Code:
#include <amxmodx>
#include <engine>
#include <hamsandwich>

new HamHook:g_pHamPlayerJump,
    HamHook:g_pHamPlayerDuck;

public plugin_init( )
{
    register_plugin( "Block Jump & Duck", "1.0", "Manu" );
    
    register_logevent( "ev_RoundStart", 2, "1=Round_Start" );
    register_event( "HLTV", "ev_RoundCommencing", "a", "1=0", "2=0" );
    
    DisableHamForward( g_pHamPlayerJump = RegisterHam( Ham_Player_Jump, "player", "fw_PlayerJumpOrDuck_Pre" ) );
    DisableHamForward( g_pHamPlayerDuck = RegisterHam( Ham_Player_Duck, "player", "fw_PlayerJumpOrDuck_Pre" ) );
}

public fw_PlayerJumpOrDuck_Pre( iId )
{
    static iOldButtons; iOldButtons = entity_get_int( iId, EV_INT_oldbuttons );
    
    if( ~iOldButtons & IN_JUMP || ~iOldButtons & IN_DUCK )
    {
        iOldButtons |= (IN_JUMP | IN_DUCK);
        entity_set_int( iId, EV_INT_oldbuttons, iOldButtons );
        
        return HAM_HANDLED;
    }
    
    return HAM_IGNORED;
}

public ev_RoundCommencing( )
{
    EnableHamForward( g_pHamPlayerJump );
    EnableHamForward( g_pHamPlayerDuck );
}

public ev_RoundStart( )
{
    DisableHamForward( g_pHamPlayerJump );
    DisableHamForward( g_pHamPlayerDuck );
}

Last edited by nacknic; 04-23-2019 at 02:54.
nacknic is offline
nacknic
Senior Member
Join Date: Mar 2019
Old 04-23-2019 , 01:20   Re: [HELP] block duck + another questions
Reply With Quote #8

i update the thread, please help (very quick all code here but have 3 simple questions)

Last edited by nacknic; 04-23-2019 at 02:50.
nacknic is offline
nacknic
Senior Member
Join Date: Mar 2019
Old 04-23-2019 , 09:58   Re: [HELP] block duck + another questions
Reply With Quote #9

finally understood, and got more simple code for the same thing:

**next step is: do players loop to get all id, and try on all players ;)
Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <hamsandwich>

new g_id,HamHook:g_HamPlayerDuck, HamHook:g_HamPlayerJump;
public plugin_init( )
{
	register_plugin( "block movement", "1.0", "nacknic" );
	register_event( "HLTV", "freezetime", "a", "1=0", "2=0" );
	register_logevent("roundstart", 2, "1=Round_Start");
	DisableHamForward( g_HamPlayerDuck = RegisterHam( Ham_Player_Duck, "player", "bmovement" ) );
	DisableHamForward( g_HamPlayerJump = RegisterHam( Ham_Player_Jump, "player", "bmovement" ) );
}

public client_authorized( id ) 
         g_id = id;
	 
public bmovement(  )
{
	static b; b = entity_get_int( g_id, EV_INT_button ); // create new button
	if( b & IN_DUCK || b & IN_JUMP ) // check in duck pressed
	{
		client_print(0, print_chat, "block movement");
		// just b its equal to b |= IN_DUCK or  b |= (IN_DUCK | IIN_JUMP) because the | operator say: or/both so its actually
		entity_set_int( g_id, EV_INT_oldbuttons, b ); // insert to button that presses (before aka old)
		return HAM_HANDLED;
	}
	client_print(0, print_chat, "not blocking movement");
	return HAM_IGNORED; 
}


public freezetime( )
{
	EnableHamForward( g_HamPlayerDuck );
	EnableHamForward( g_HamPlayerJump );
}
        	
public roundstart( )
{
	client_print(0, print_chat, "movement allowed");
	DisableHamForward( g_HamPlayerDuck );
	DisableHamForward( g_HamPlayerJump );
}

Last edited by nacknic; 04-23-2019 at 10:10.
nacknic 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 00:48.


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