AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   IN_USE -> Execute command (https://forums.alliedmods.net/showthread.php?t=278077)

organnerX 01-24-2016 07:25

IN_USE -> Execute command
 
Hello guys, I'm real newbie at Amxx scripting, so I need detail help with this plugin.

I have some plugin that have function "box_use" to grab boxes from map and "box_use" to drop them.
I can easily bind it to myself with "bind e box_use", but many players can't bind it with console cause they kids. I need a plugin that will execute box_use in console when player press his use button. Do I need to edit a box plugin for it? Cause I heard that binding with clientcmd is a bad way to execute commands and cannot work properly on Steam clients.

I can attach sma file for boxes plugin if you can help me, I just need to attach one function, pls guys :3

addons_zz 01-24-2016 07:58

Re: IN_USE -> Execute command
 
Better way is to edit your plugin as this parachute plugin to use the 'use' button command as/instead of 'use_box'.

See:
  1. You can use this to teach:


organnerX 01-24-2016 08:12

Re: IN_USE -> Execute command
 
I tiried this code:

public client_PreThink(id){
if(entity_get_int(id,EV_INT_button) & IN_USE)
{
client_print(id,print_chat,"You are you using box")
box_use(id)
}
}

But when I press button once it counts many times like:
You are you using box
You are you using box
You are you using box
You are you using box

Any idea how to solve it? I can use box now with this use but it is laggy due to multiple usage with one press.

UPDATE:

I found a fix for this! Now all working perfect, thanks to addons_zz and google.

public client_PreThink(id){
if(get_user_button(id) & IN_USE && !(get_user_oldbutton(id) & IN_USE)) {
client_print(id,print_chat,"You are you using box") // Your commands there
box_use(id) // Your commands there
}
}

addons_zz 01-24-2016 08:57

Re: IN_USE -> Execute command
 
Use 'Ham_ObjectCaps' instead of 'client_PreThink' because 'client_PreThink' is called per frame (like 20 times per second) all the time (every second) and 'Ham_ObjectCaps' is just called when you press the button.
Code:
#include <amxmodx> #include <hamsandwich> #include <fun> /*  * Called just after server activation.  */ public plugin_init() {     register_plugin( "Cool Plugin", "1.0", "Addons zz" )         RegisterHam( Ham_ObjectCaps, "player", "pressed_button_command", 0 ) } /*  * Called when a button is pressed.  */ public pressed_button_command( id ) {     static user_health; user_health = get_user_health( id )         set_user_health( id, user_health + 1 )         if( user_health > 254 )     {         set_user_health( id, 100 )     } }
See also: [SOLVED] Any way to hook +use?

jimaway 01-24-2016 11:26

Re: IN_USE -> Execute command
 
Quote:

Originally Posted by addons_zz (Post 2386024)
Better way is to edit your plugin as this parachute plugin to use the 'use' button command as/instead of 'use_box'.

See:
  1. Admin Slowhacking
  2. Why slowhacking, etc, is bad.
  3. Slow Hacking
  4. Valve's Policy of Truth: Valve to crack down on servers that fake info to players
You can use this to teach:

how exactly do you consider his request slowhacking?

fysiks 01-24-2016 14:38

Re: IN_USE -> Execute command
 
You are becoming the new Antichristus and it's very annoying.

JusTGo 01-25-2016 03:51

Re: IN_USE -> Execute command
 
Quote:

Originally Posted by fysiks (Post 2386122)
You are becoming the new Antichristus and it's very annoying.

lol


All times are GMT -4. The time now is 09:31.

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