AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Chat print help. (https://forums.alliedmods.net/showthread.php?t=94152)

Cretu 06-07-2009 04:39

Chat print help.
 
Hello.

This a simple cod that allows you to use amx_freezetime in stead of amx_cvar mp_freezetime.

The THING is that it doen`t print the command in the server`s general chat.

I want it to say on the chat "Command : <admin who uses the command> Changed cvar <freezetime,limitteams or any cvar i wait to put in the plugin> to 1"

COULD someone please add the line for this with red color ( so i know what is added) and someone please explain every single letter`s function ?

Example : new name[32],com[32] // we will use name as a variable for the admins name and com variable for the commad


QUESTION 2 : How i add a wait period in a plugin ? Because I done this :

client_cmd (print_chat;wait;wait;snapshot;wait;wait;)
server_cmd (around 40 waits here)
server_cmd (ban client) .

Is there a special line for those waits ? lie in stead of using 40 waits like that just type : server_wait_20_seconds :))

I hope someone help me with this . I must say i`m a total n00b at coding , i just copy a part of a cod , ad another part from another plugin and from 2 part i make 1 plugin and register the plugin under everybody`s names :)) . So it won`t be stealing.

Thank you for you`r time .



Code:

#include <amxmodx>
#include <amxmisc>

new mp_freezetime;

public plugin_init()
{
    register_plugin("amx_freezetime", "0.1", "Exolent");
   
    register_concmd("amx_freezetime", "CmdFreezetime", ADMIN_KICK, "<freezetime seconds>");
   
    mp_freezetime = get_cvar_pointer("mp_freezetime");
}

public CmdFreezetime(plr, level, cid)
{
    if( !cmd_access(plr, level, cid, 2) )
    {
        return PLUGIN_HANDLED;
    }
   
    new arg[10];
    read_argv(1, arg, sizeof(arg) - 1);
   
    new num = str_to_num(arg);
   
    set_pcvar_num(mp_freezetime, num);
   
    console_print(plr, "[AMXX] You set mp_freezetime to %i", num);
   
    return PLUGIN_HANDLED;
}


187Ghost187 06-07-2009 07:16

Re: Chat print help.
 
Please use the [php] tag's when posting code and the command you're looking for is client_print

PHP Code:

client_print(idprint_chat"Your Message"ThingstoShowInMessage

Where id is, that's where you want to put the user(s) you want to see the message

Your Message must always be in "" but can also contain %s %i %d depending on what type of info being shown (%s = strings, etc.)

where I have "ThingstoShowInMessage" is where you'd put the things you're wanting to show through the %'s

Cretu 06-07-2009 07:28

Re: Chat print help.
 
First of all , thank you for you`r reply.

ThingstoShowInMessage should be "adminname, clientname"

But how i make adminname = the name of the admin that executed the command
And how i make clientname = the client on wich the command was used.

PHP Code:

client_print(idprint_chat"Command : $s mp_freezetime 0"adminname

This is how the command should be? Wright ?
But it won`t work like this because i dont have "new adminname[32] and other stuff".
Can you please write the whole code that is being used by the client_print function above ? And explain to me the whole thing ? I wan`t to know this so in the future i won`t boder anyone else .


Second question :

If in stead of freeze time is KICK command.

I want this :
PHP Code:

client_print(idprint_chat"Command : %s used command Llama on %s"adminnameclientname

This is how it should be , write ?

In question 1 , the one above you will explain hot i get adminname defined , now explain how i get adminname AND clientname defined (defined i mean to make the function work fine)

THANK YOU

Cretu 06-08-2009 04:01

Re: Chat print help.
 
anyone reply ? please....

Emilioneri 06-08-2009 10:45

Re: Chat print help.
 
show full code

Cretu 06-08-2009 11:11

Re: Chat print help.
 
Quote:

Originally Posted by Emilioneri (Post 844285)
show full code

The full code is in my first post .

If you want you can add in the code with red color the code for what i want and maybe explain everything you add . Exept for the client_print line , i know how it works. I don`t know hot you add the strings.

Thank you.

Emilioneri 06-08-2009 15:15

Re: Chat print help.
 
you mean this?
PHP Code:

#include <amxmodx>
#include <amxmisc>

new mp_freezetime;

public 
plugin_init()
{
    
register_plugin("amx_freezetime""0.1""Exolent");
    
    
register_concmd("amx_freezetime""CmdFreezetime"ADMIN_KICK"<freezetime seconds>");
    
    
mp_freezetime get_cvar_pointer("mp_freezetime");
}

public 
CmdFreezetime(plrlevelcid)
{
    if( !
cmd_access(plrlevelcid2) )
    {
        return 
PLUGIN_HANDLED;
    }
    
    new 
arg[10];
    
read_argv(1argsizeof(arg) - 1);
    
    new 
num str_to_num(arg);
    
    
set_pcvar_num(mp_freezetimenum);
    
    new 
adminname[32]
    
get_user_name(plrname31)
    
    
client_print(0print_chat"ADMIN %s: set cvar mp_freezetime to %i"adminnamenum)
    
    return 
PLUGIN_HANDLED;



fysiks 06-08-2009 15:22

Re: Chat print help.
 
Quote:

Originally Posted by Cretu (Post 843504)
QUESTION 2 : How i add a wait period in a plugin ? Because I done this :

client_cmd (print_chat;wait;wait;snapshot;wait;wait;)
server_cmd (around 40 waits here)
server_cmd (ban client) .

Is there a special line for those waits ? lie in stead of using 40 waits like that just type : server_wait_20_seconds :))

Use set_task(20.0, "function", id)

Cretu 06-09-2009 02:10

Re: Chat print help.
 
Quote:

Originally Posted by fysiks (Post 844445)
Use set_task(20.0, "function", id)

Thank you for you`r reply .

set_task(22.0,"wait",id) , and this will execute wait function 22 times ?



PHP Code:

/home/groups/amxmodx/tmp3/text8xL7Lb.sma(30) : error 017undefined symbol "name"
/home/groups/amxmodx/tmp3/text8xL7Lb.sma(30) : warning 215expression has no effect
/home/groups/amxmodx/tmp3/text8xL7Lb.sma(30) : error 001expected token";"but found ")"
/home/groups/amxmodx/tmp3/text8xL7Lb.sma(30) : error 029invalid expressionassumed zero
/home/groups/amxmodx/tmp3/text8xL7Lb.sma(30) : fatal error 107too many error messages on one line

Compilation aborted
.
4 Errors

I don`t think that is the way to do it, Emilioneri . Any other ideea, please ?

ehha 06-09-2009 05:18

Re: Chat print help.
 
No, set_task(22.0, "function") will execute function after 22 seconds.
Function is a function not a command like wait.
For example CmdFreezetime is a function in your code, not a command.


All times are GMT -4. The time now is 14:00.

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