AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Say command print chat & set_task (https://forums.alliedmods.net/showthread.php?t=271005)

4ever16 09-03-2015 07:51

Say command print chat & set_task
 
I know this is really easiy one but i cant code at all.
I have tryed different plugins but it only prints 1 time.
The problem i found is that print action is forced all at once and taht makes that only print 1 time cause the actions is happening so fast.

client_cmd(say lol)
client_cmd(say lol)
client_cmd(say lol)

Like i sed it only prints 1 time because i think these 3 actions happens so fast.

So i would need some say command that prints 4 times the solution is to solve it by setting set_task between prints.

set_task(0.0)
client_cmd(say lol)
set_task(1.0)
client_cmd(say lol)
set_task(2.0)
client_cmd(say lol)

Reffered to this request. https://forums.alliedmods.net/showthread.php?t=270939

redivcram 09-03-2015 08:38

Re: Say command print chat & set_task
 
Use the for loop
I'm no pro, but this might help you... and remove the "set_task"s


PHP Code:

public urfunction(id)
{
    new 
//We need this variable for the "for" loop
    
    
for(04i++)
    {
        
client_cmd(id"say lol")
    }
    
    
/* For loop:
    First parameter sets "i"'s value to 0
    Second parameter tells when to repeatedly print out "lol" (in this case while "i"'s value is less than 4
    Third parameter adds up "i"'s value by 1
    
    So when it adds up to 4, it will stop printing out "lol"
    You have to be careful when making loops, you can crash your server
    */
    
    
return PLUGIN_HANDLED



4ever16 09-03-2015 13:33

Re: Say command print chat & set_task
 
Ok how to add print in the script u wrote?

client_cmd(id,"say_team lol")

Fuck For Fun 09-03-2015 14:53

Re: Say command print chat & set_task
 
Quote:

Originally Posted by 4ever16 (Post 2339517)
Ok how to add print in the script u wrote?

client_cmd(id,"say_team lol")

nope
Code:

client_print(id, print_chat, "[AMXX] Your Text Here.");
i dunno if you can use id but try

4ever16 09-03-2015 18:01

Re: Say command print chat & set_task
 
Solved it: client_cmd(0, "say_team B B B;wait;say_team B B B;wait;say_team B B B")

fysiks 09-03-2015 21:00

Re: Say command print chat & set_task
 
Quote:

Originally Posted by redivcram (Post 2339442)
Use the for loop
I'm no pro, but this might help you... and remove the "set_task"s

No. A for loop will execute just as fast as multiples of the same command one after the other.

Quote:

Originally Posted by 4ever16 (Post 2339605)
Solved it: client_cmd(0, "say_team B B B;wait;say_team B B B;wait;say_team B B B")

This will not work for anybody that is using cl_filterstuffcmd 1 FYI (and everybody should have this set to 1, IMO).

The proper way would be to use set_task() with engclient_cmd() like so:

PHP Code:

public function(id)
{
    
set_task(0.2"saycommand"id)
}

public 
saycommand(id)
{
    
engclient_cmd(id"say_team""lol")




All times are GMT -4. The time now is 22:12.

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