Raised This Month: $ Target: $400
 0% 

Ham_Use and Button id's (HELP)


Post New Thread Reply   
 
Thread Tools Display Modes
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 07-05-2016 , 09:14   Re: Ham_Use and Button id's (HELP)
Reply With Quote #21

Fixed:

PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <engine>
#include <colorchat>

#define DR_BUTTONS_FILE "addons/amxmodx/configs/dr_buttons.ini" 

new g_Button;

public 
plugin_init()
{
    
register_plugin("Map Secret Button""1.0""siriusmd99");
    
    new 
pFile fopen(DR_BUTTONS_FILE"r");
    
    if(!
pFile)
    {
        
log_amx("[ Dr Buttons ]: File %s not found. Check your directory."DR_BUTTONS_FILE); 
        return 
PLUGIN_CONTINUE;
    }    
    
    new 
szCurrentMap[45];
    
get_mapname(szCurrentMapcharsmax(szCurrentMap));
    
    new 
szString[64], szMap[45], szButton[7];
    new 
iButton = -1;
    
    while( 
fgets(pFileszStringcharsmax(szString) ) )
    {
        
trim(szString); 
        if(
szString[0] == ';')
            continue;
        
        
parse(szString,szMap,charsmax(szMap),szButton,charsmax(szButton));
        
        if(
equali(szMapszCurrentMap))
        {
            
iButton str_to_num(szButton);
            break;
        }
    }    
    
    
fclose(pFile);
    
    if(
iButton == -1)
    { 
        
log_amx("[ Dr Buttons ]: Current Map (%s) hasn't been found in configuration file."szCurrentMap); 
        return 
PLUGIN_CONTINUE;
    }
    else
    {
        if(
iButton == 0)
        {
            
log_amx("[ Dr Buttons ]: Invalid Button - %s. Check your configuration file."szButton); 
            return 
PLUGIN_CONTINUE;
        }
    }
    
    new const 
CLASS_NAME[4][16] = { "func_button",  "func_rot_button""button_target""" };
    new 
ient = -1;
    
    for(
0charsmax(CLASS_NAME); i++)
    {
        
ent = -1
        
while((ent find_ent_by_class(entCLASS_NAME[i])))
        {
            if(
ent == iButton)
            {
                
g_Button iButton;
                
RegisterHam(Ham_UseCLASS_NAME[i], "fwButtonUsed");
                return 
PLUGIN_CONTINUE
            }
        }        
    }
    
    
log_amx("[ Dr Buttons ]: Button %s hasn't been found on this map (%s)."szButtonszCurrentMap ); 
    
    return 
PLUGIN_CONTINUE;
}

public 
fwButtonUsed(entidcalleridactivatoruse_typeFloat:value)
{
    if(
idcaller == idactivator && ent == g_Button)
    {     
        new 
szPlayerName[32]
        
get_user_name(idactivatorszPlayerNamecharsmax(szPlayerName))
        
ColorChat(0NORMAL"^4[SERVER] ^1%s pressed an sweet button :D"szPlayerName)
    }

Tested with

PHP Code:
;MapName ButtonID
deathrun_temple 65 
in config file

Pressed the third button which has id 65 (used oxicrom plugin to get button id) and message appeared.

P.S. I don't know why oxicrom saves button in his plugin by model but not by id.
siriusmd99 is offline
KaLoIaN
Senior Member
Join Date: Feb 2013
Old 07-05-2016 , 09:54   Re: Ham_Use and Button id's (HELP)
Reply With Quote #22

I will try it. I get the button ID by another plugin just when press it I made it :

client_print(idcaller, print_chat, "%i", ent)


ent is the button ID
KaLoIaN is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 07-05-2016 , 12:53   Re: Ham_Use and Button id's (HELP)
Reply With Quote #23

Try to get third button id on deathrun_temple with your way of getting and if it's 65 then your method is correct.
siriusmd99 is offline
KaLoIaN
Senior Member
Join Date: Feb 2013
Old 07-06-2016 , 14:13   Re: Ham_Use and Button id's (HELP)
Reply With Quote #24

It is working, so how I can now avoid the spam? I Just pressed the button 50 times and spammed the whole server LOL...
Something like saving the last message shown in a temp variable and to check if it is the same message don't display it.. I mean display it something like only 1 time per round? Or display it then wait set_task to 30 seconds wait ? Did you get it ?
KaLoIaN is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 07-06-2016 , 14:39   Re: Ham_Use and Button id's (HELP)
Reply With Quote #25

Change this to what value you want :

Quote:
#define WAIT_TIME 30
I used get_systime(), it's good method.

PHP Code:
#include <amxmodx> 
#include <hamsandwich> 
#include <engine> 
#include <colorchat> 

#define DR_BUTTONS_FILE "addons/amxmodx/configs/dr_buttons.ini"  
#define WAIT_TIME 30

new g_Button
new 
g_time[33]

public 
plugin_init() 

    
register_plugin("Map Secret Button""1.0""siriusmd99"); 
     
    new 
pFile fopen(DR_BUTTONS_FILE"r"); 
     
    if(!
pFile
    { 
        
log_amx("[ Dr Buttons ]: File %s not found. Check your directory."DR_BUTTONS_FILE);  
        return 
PLUGIN_CONTINUE
    }     
     
    new 
szCurrentMap[45]; 
    
get_mapname(szCurrentMapcharsmax(szCurrentMap)); 
     
    new 
szString[64], szMap[45], szButton[7]; 
    new 
iButton = -1
     
    while( 
fgets(pFileszStringcharsmax(szString) ) ) 
    { 
        
trim(szString);  
        if(
szString[0] == ';'
            continue; 
         
        
parse(szString,szMap,charsmax(szMap),szButton,charsmax(szButton)); 
         
        if(
equali(szMapszCurrentMap)) 
        { 
            
iButton str_to_num(szButton); 
            break; 
        } 
    }     
     
    
fclose(pFile); 
     
    if(
iButton == -1
    {  
        
log_amx("[ Dr Buttons ]: Current Map (%s) hasn't been found in configuration file."szCurrentMap);  
        return 
PLUGIN_CONTINUE
    } 
    else 
    { 
        if(
iButton == 0
        { 
            
log_amx("[ Dr Buttons ]: Invalid Button - %s. Check your configuration file."szButton);  
            return 
PLUGIN_CONTINUE
        } 
    } 
     
    new const 
CLASS_NAME[4][16] = { "func_button",  "func_rot_button""button_target""" }; 
    new 
ient = -1
     
    for(
0charsmax(CLASS_NAME); i++) 
    { 
        
ent = -
        
while((ent find_ent_by_class(entCLASS_NAME[i]))) 
        { 
            if(
ent == iButton
            { 
                
g_Button iButton
                
RegisterHam(Ham_UseCLASS_NAME[i], "fwButtonUsed"); 
                return 
PLUGIN_CONTINUE;  
            } 
        }         
    } 
     
    
log_amx("[ Dr Buttons ]: Button %s hasn't been found on this map (%s)."szButtonszCurrentMap );  
     
    return 
PLUGIN_CONTINUE


public 
fwButtonUsed(entidcalleridactivatoruse_typeFloat:value

    if(
idcaller == idactivator && ent == g_Button
    {
        new 
iSystime get_systime();
        if(
iSystime >= g_time[idactivator])    
        {
            new 
szPlayerName[32
            
get_user_name(idactivatorszPlayerNamecharsmax(szPlayerName)) 
            
ColorChat(0NORMAL"^4[SERVER] ^1%s pressed an sweet button :D"szPlayerName
            
g_time[idactivator] = iSystime WAIT_TIME;
        }    
    } 


Last edited by siriusmd99; 07-06-2016 at 15:07.
siriusmd99 is offline
KaLoIaN
Senior Member
Join Date: Feb 2013
Old 07-06-2016 , 14:59   Re: Ham_Use and Button id's (HELP)
Reply With Quote #26

It is working good.
You just forgot to declare the variable : g_time
but I done it
Code:
new g_time[32]
Last question : can I have for example 4 buttons at the same map and for each one button show different message for example?
KaLoIaN is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 07-06-2016 , 15:10   Re: Ham_Use and Button id's (HELP)
Reply With Quote #27

Quote:
Originally Posted by KaLoIaN View Post
It is working good.
You just forgot to declare the variable : g_time
but I done it
Code:
new g_time[32]
Sorry, i updated code.
USe g_time[33] not 32 because last cell 32 cannot be accesed, so in this case and if you have full server then it will throw an error.

Quote:
Last question : can I have for example 4 buttons at the same map and for each one button show different message for example?
I don't know really
You can have separate file for every map and it will contain button id and after button id it will have the message.
But you want to use activator's name in every message or not?
siriusmd99 is offline
KaLoIaN
Senior Member
Join Date: Feb 2013
Old 07-06-2016 , 15:13   Re: Ham_Use and Button id's (HELP)
Reply With Quote #28

Yes activator's name in every message must be shown.
Not in all maps are 4 buttons for example, some have only 1-2 ...
Can we make all of this in 1 plugin?
If you don't know how I guess someone other should? And thanks for your help!


EDIT: u know what? it's good this way no need more.. only 1 button per map, thank you!

Last edited by KaLoIaN; 07-06-2016 at 15:14.
KaLoIaN is offline
KaLoIaN
Senior Member
Join Date: Feb 2013
Old 07-08-2016 , 14:04   Re: Ham_Use and Button id's (HELP)
Reply With Quote #29

I've got a trouble over here...
I am using the last code sirius gave me but I want to show different text for every single different map.

if map is for example de_Dust2 (just an example!!!) print_chat : ala bala
if map is for example de_aztec print_chat : ala bala trala lala

Got it ?

Also how to make a countdown HUD?
When someone press the button instead of client_print show an HUD with an specific number set for the map and decrement it with -1 each second?

Last edited by KaLoIaN; 07-08-2016 at 14:07.
KaLoIaN is offline
KaLoIaN
Senior Member
Join Date: Feb 2013
Old 07-15-2016 , 01:49   Re: Ham_Use and Button id's (HELP)
Reply With Quote #30

The button ids on the map has all changed wtf ?!
KaLoIaN 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 12:18.


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