AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Get Button ID (https://forums.alliedmods.net/showthread.php?t=140094)

Stylaa 10-08-2010 20:46

Get Button ID
 
1. How i can get the Button IDs from a Button in a CS 1.6 Map?

best is when i aim at it and i write /info and it shows me the button id

2. and how i can aktivate the Button over the Plugin over a clcmd


GreeTz from Me :)

wrecked_ 10-08-2010 21:33

Re: Get Button ID
 
1.
Code:
#include <amxmodx> #include <engine> public plugin_init() {     register_clcmd( "say /info", "CmdInfo" ) } public CmdInfo( id ) {     new ent, aim     get_user_aiming( id, ent, aim )         if( ent )     {         new cname[32]         entity_get_string( ent, EV_SZ_classname, cname, 31 )                 if( equal( cname, "func_button" ) )         {             client_print( id, print_chat, "Button ID: %d", ent )         }     } }

2.
Code:
dllfunc( DLLFunc_Use, buttonid, userid )

Stylaa 10-09-2010 09:00

Re: Get Button ID
 
THanks this works Great

And how can i get the event Player Uses a Button? :D
I want to show a msg if the Player for example presses button id 50


But Dynamic like that :P


Register Button Press

id = Pressedbutton

if id = 50 then
Colorchat ... Message
else if id = 45
Colorchat ... Message

minimiller 10-09-2010 09:47

Re: Get Button ID
 
should work

PHP Code:

public plugin_init()
{
    
RegisterHam(Ham_Use"func_button""fwdButtonUse");
}

public 
fwdButtonUse(entid)
{
    
//id = index of player who pressed the button
    //ent = entity index of the button
    
    
switch(ent)
    {
         case 
50: { /* Stuff here */ }
         case 
45: { /* Stuff here */ }
    }



Stylaa 10-09-2010 13:58

Re: Get Button ID
 
Quote:

Originally Posted by minimiller (Post 1320031)
should work

PHP Code:

public plugin_init()
{
    
RegisterHam(Ham_Use"func_button""fwdButtonUse");
}

public 
fwdButtonUse(ident)
{
    
//id = index of player who pressed the button
    //ent = entity index of the button
    
    
switch(ent)
    {
         case 
50: { /* Stuff here */ }
         case 
45: { /* Stuff here */ }
    }




doesent work :)
I think its a button id dont must it be anythink like

as

case"func_button 50"

?

GreeTz

Exolent[jNr] 10-09-2010 14:02

Re: Get Button ID
 
Quote:

Originally Posted by Stylaa (Post 1320363)
doesent work :)
I think its a button id dont must it be anythink like

as

case"func_button 50"

?

GreeTz

No, his code is right.
Make sure you have the correct button ids.

Code:
#include < amxmodx > #include < hamsandwich > public plugin_init( ) {     RegisterHam( Ham_Use, "func_button", "FwdUseButton" ); } public FwdUseButton( iEntity, iPlayer, iActivator, iUseType, Float:flValue ) {     if( !is_user_alive( iPlayer )     ||  iUseType != 2     ||  flValue != 1.0 )     {         return HAM_IGNORED;     }         client_print( iPlayer, print_chat, "Button Entity: %i", iEntity );         return HAM_IGNORED; }

Stylaa 10-09-2010 14:08

Re: Get Button ID
 
Heres my Code

and the Button IDs are 100 % Correct and it doesnt work

PHP Code:

public plugin_init()
{
    ....
    
RegisterHam(Ham_Use"func_button""fwdButtonUse");
    ....
}


public 
fwdButtonUse(ident)
{
    
//id = index of player who pressed the button
    //ent = entity index of the button
    
    
new mapname[33]
    
get_mapname(mapname32)
    
    new 
PlayerName[32]
    
    
get_user_name(idPlayerName31)

if (
equali(mapname,"jb_mania_fixed"))
    {
        
        switch(
ent)
        {
            case 
290:
            {
                
ColorChat(0RED"%s %L",PREFIXLANG_SERVER,"KZ_DONE"PlayerName )
            }
            case 
291:
            {
                
ColorChat(0RED"%s %L",PREFIXLANG_SERVER,"KZ_DONE"PlayerName )
            }

        }
    }
    



lazarev 10-09-2010 14:19

Re: Get Button ID
 
PHP Code:

public plugin_init()
{
    new 
mapname[33]
    
get_mapname(mapname32)
    
    if (
equali(mapname,"jb_mania_fixed"))
    {
        
RegisterHam(Ham_Use"func_button""fwdButtonUse");
    }
}


public 
fwdButtonUse(entid)
{
    new 
PlayerName[33]
    
    
get_user_name(idPlayerName32)
        
    switch(
ent)
    {
        case 
290:
        {
            
ColorChat(0RED"%s %L",PREFIXLANG_SERVER,"KZ_DONE"PlayerName )
        }
        case 
291:
        {
            
ColorChat(0RED"%s %L",PREFIXLANG_SERVER,"KZ_DONE"PlayerName )
        }
    }




minimiller 10-09-2010 14:25

Re: Get Button ID
 
my bad
i got the params in fwdButtonUse the wrong way round

Stylaa 10-09-2010 15:09

Re: Get Button ID
 
okay thanks everythink is working well now


All times are GMT -4. The time now is 10:26.

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