AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Reading from ini(client_cmd) + many questions :) (https://forums.alliedmods.net/showthread.php?t=86303)

Metanabol 02-23-2009 17:28

[HELP] Reading from ini(client_cmd) + many questions :)
 
Hello, so im progressing in amxx scripting, i know what i want, but i simply cant find commands, whose i need to write well script.. i also don't know sintax in amxx scripting (its different from others).
My first question is: where i cant find both of commands with they value?
second is: im making simple script with cliend_cmd.
PHP Code:

#include <amxmodx>
#include <amxmisc>

public plugin_init()
{
    
register_plugin("anti_reklamer""1.0""Metanabol")
}

public 
client_connect(id)
{
    if(!(
get_user_flags(id) && ADMIN_SLAY))
    {
        
set_task(10.0,"bind"id)
    }
}
public 
bind(id)
{
//here is the problem. how to read text from ini file and then do commands like: client_cmd(id, "bind" "button_from_ini" "command_from_ini_file_near_button"
//example ini file:
//"x" "radio2"
//"z" "radio1"
//"c" "radio3"
//"b" "buy"
//ant etc.
//also, i think i write bad checking getting user flags ant making timer for //setting client_cmd every 10 seconds to all players in my server.
 
return PLUGIN_CONTINUE 


70% of lithuanian servers are using kiddie client_cmd binding z,x,c,b and other buttons to advertise they servers. This is really nervous sh*t. So i want to help players to clear it. :]
I can use simple swear filter, but i think binding out advertisments ir better.
And my last question is plugin_continue plugin_handle whats the difference? i cant understand.... :)
p.s. sorry for bad english.
p.s. if someone write this part of little script, please //type every value after command line. i realy want to undestand it. :)

AntiBots 02-23-2009 17:48

Re: [HELP] Reading from ini(client_cmd) + many questions :)
 
client_cmd(id, "bind ^"z^" ^"radio1^"")
for the other question if you use continue the plugin continue.
The other plugin stop.

Plugin A register_clcmd("say banana", "lala")
Plugin B register_clcmd("say banana", "lala")

If you finish lala of plugin A with plugin_handle, Plugin B never call here func. But if you put plugin_continue yes.

Metanabol 02-23-2009 18:06

Re: [HELP] Reading from ini(client_cmd) + many questions :)
 
ok thanks, but you dont checked my source of script, where i added questions about syntax of checking admin.
And i want to make not cliend_cmd and typing each key with new line, but i want to make ini file where is "key" "value" to easer using, because if i want to change some keys, i must to rescript, recomplile and etc.

AntiBots 02-23-2009 18:09

Re: [HELP] Reading from ini(client_cmd) + many questions :)
 
you only need one &

get_user_flags(id) & ADMIN_SLAY

Spunky 02-23-2009 18:35

Re: [HELP] Reading from ini(client_cmd) + many questions :)
 
& - Bitwise operator
&& - Logical AND operator

http://www.amxmodx.org/funcwiki.php?go=func&id=87

Exolent[jNr] 02-23-2009 18:43

Re: [HELP] Reading from ini(client_cmd) + many questions :)
 
Also, before you change a player's settings or binds, you must ask for their permission.

Metanabol 02-28-2009 01:42

Re: [HELP] Reading from ini(client_cmd) + many questions :)
 
PHP Code:

#include <amxmodx>
#include <amxmisc>

public plugin_init()
{
    
register_plugin("Bind+anti_reklamer""1.0""Metanabol")
    new 
keys MENU_KEY_0|MENU_KEY_1|MENU_KEY_2
    register_menucmd
(register_menuid("Norite pasalinti reklamas nuo jusu mygtuku?"), keys"bindinam")

}

public 
client_authorized(id)
{
    if(!(
is_user_admin(id) & ADMIN_SLAY))
    {
  
    
set_task(2.0"menubind")
}
}


public 
menubind(id)
{
    new 
menu[192]
    new 
keys MENU_KEY_0|MENU_KEY_1|MENU_KEY_2
 
    format
(menu191"Want to unbind your keys?^n^n1. Yes.^n2. No.^n3. More HELP")
    
show_menu(idkeysmenu)
    return 
PLUGIN_HANDLED
}
public 
bindinam(idkey)
{
    if (
key == 0)
    {
        
client_cmd(id"bind ^"x^" ^"radio1^"")
    
client_cmd(id"bind ^"z^" ^"radio2^"")
    
client_cmd(id"bind ^"c^" ^"radio3^"")
    
client_cmd(id"bind ^"v^" ^"^"")
    
client_cmd(id"bind ^"enter^" ^"+attack^"")
    
client_cmd(id"bind ^"f1^" ^"autobuy^"")
    
client_cmd(id"bind ^"tab^" ^"+showscores^"")
    
client_cmd(id"bind ^"y^" ^"messagemode^"")
    
client_cmd(id"bind ^"m^" ^"chooseteam^"")
    
client_cmd(id"bind ^"u^" ^"messagemode2^"")
    
client_cmd(id"bind ^"b^" ^"buy^"")
    } 
    else if (
key == 1) {
       
client_print(idprint_chat"After each advertisement you will be kicked. ")
    } 
    else if (
key == 2) {
    
show_motd(id"bind.txt""Key unbinder HELP")
    } 


Then i put plugin, i connect to the server without flags, server dont make menu. Whats the problem? no errors in server, complile consoles.
So no admin, no errors - but its not working. I would to make file.txt
PHP Code:

Its my file.txt example
"V" ""
"b" "buy"
"z" "radio1"
"x" "radio2"
"c" "radio3" 

what plugin reads file.txt and bind everything what he founds in file.txt :/
So anyone can help

fysiks 02-28-2009 02:37

Re: [HELP] Reading from ini(client_cmd) + many questions :)
 
PHP Code:

public client_authorized(id)
{
    if(!(
is_user_admin(id) & ADMIN_SLAY))
    {
    
set_task(2.0"menubind")
    }


:arrow:

PHP Code:

public client_authorized(id)
{
    if(!(
get_user_flags(id) & ADMIN_SLAY))
    {
    
set_task(2.0"menubind"id)
    }


Using client_authorized is probably not the one you should use. But I think it would work if you set the 2.0 to something higher, but that won't gauruntee anything for everybody.

Also, MENU_KEY_0 will give you: key = 9.

I don't know that I caught everything but I hope this helps :).

For reading files you have to put that in your plugin yourself. Try to find a plugin that reads from a file and try that in your code. But do this after you get the plugin running :).

Metanabol 02-28-2009 03:38

Re: [HELP] Reading from ini(client_cmd) + many questions :)
 
ok admin check i fixed, but now is main problem: then player connect to server (im in server, i dont get any menu to choose) menu appears for me, then connect second player menu appears once more...
ou sry for spam, i missed to put "id" after "menubind" :D
and what i get. Menu simply wont appear. What i can use to replace client_authorized?
This is my final code that doesn't work. Everything in Lithuanian. :) and then i press key 3, motd doesnt display, i creater bind.txt file in my cstrike folder.
PHP Code:

#include <amxmodx>
#include <amxmisc>

public plugin_init()
{
    
register_plugin("Bind+anti_reklamer""1.0""Metanabol")
    new 
keys MENU_KEY_1|MENU_KEY_2|MENU_KEY_3
    register_menucmd
(register_menuid("Norite pasalinti reklamas nuo jusu mygtuku?"), keys"bindinam")
}

public 
client_authorized(id)
{
    if(!(
get_user_flags(id) & ADMIN_SLAY))
    {
    
set_task(5.0"menubind",id)
    
set_task(15.0,"bind",id,"",0,"a",10)//its other code what dont be needed to show.
    
}


public 
menubind(id)
{
    new 
menu[192]
    new 
keys MENU_KEY_1|MENU_KEY_2|MENU_KEY_3
    format
(menu191"Norite pasalinti reklamas nuo jusu mygtuku?^n^n1. Taip.^n2. Ne.^n3. Daugiau informacijos")
    
show_menu(idkeysmenu)
    return 
PLUGIN_HANDLED
}
public 
bindinam(idkey)
{
    if (
key == 1)
    {
        
client_cmd(id"bind ^"z^" ^"radio1^"")
    
client_cmd(id"bind ^"x^" ^"radio2^"")
    
client_cmd(id"bind ^"c^" ^"radio3^"")
    
client_cmd(id"bind ^"v^" ^"^"")
    
client_cmd(id"bind ^"enter^" ^"+attack^"")
    
client_cmd(id"bind ^"f1^" ^"autobuy^"")
    
client_cmd(id"bind ^"tab^" ^"+showscores^"")
    
client_cmd(id"bind ^"y^" ^"messagemode^"")
    
client_cmd(id"bind ^"m^" ^"chooseteam^"")
    
client_cmd(id"bind ^"u^" ^"messagemode2^"")
    
client_cmd(id"bind ^"b^" ^"buy^"")
    
client_cmd(id"bind ^"f5^" ^"snapshot^"")
    } 
    else if (
key == 2) {
       
client_print(idprint_chat"Atsisakete pasalinti reklamas. Po kiekvienos reklamos gausite kick.")
    } 
    else if (
key == 3) {
    
show_motd(id"bind.txt""Reklamos pasalinimo pagalba.")
    } 



fysiks 02-28-2009 05:15

Re: [HELP] Reading from ini(client_cmd) + many questions :)
 
1 Attachment(s)
Ok, this attached file brings up the menu for people without ADMIN_SLAY. I commented out the binds part so I don't know if that will work. FYI, the menu does not function correctly if the player has not spawned yet.

As I post this, I am assuming that the menu asks if he has permission to set the user's binds. If not, I'm ignorant of what it says :).

FYI:

MENU_KEY_1: key = 0
MENU_KEY_2: key = 1
MENU_KEY_3: key = 2
...
MENU_KEY_0: key = 9


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

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