Raised This Month: $51 Target: $400
 12% 

Help to modify PrintToChatAll


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PepeZukas
Member
Join Date: Oct 2015
Location: Banana Republic
Old 03-16-2017 , 08:39   Help to modify PrintToChatAll
Reply With Quote #1

I want to change, with your help a plugin, so that the messages appear only to me, even properly configured in sourcemod.cfg, everyone can see them;

Code:
// Default: 13 (1+4+8)
sm_show_activity 12
Here is the part of the code where the messages are:
Code:
if (StrContains(mapname, "c1m3_mall", false) != -1)
	{
		// Dead Center 03 - emergency door or windows
		// name door_hallway_lower4a, class prop_door_rotating, Input "Open"
		// they do the rest veeery slowly, but by themselves
		
		new door = FindEntityByName("door_hallway_lower4a", -1);
		
		decl Float:pos1[3];
		if (door > 0)
		{
			GetEntityAbsOrigin(door, pos1);
			if (CheckforBots(pos1, 200.0) && !MapTrigger)
			{
				//PrintToChatAll("\x04[AutoTrigger] \x01Bot found close to the Emergency Door, open sesame...");
				//PrintToChatAll("\x04[AutoTrigger] \x01Warping them all ahead in 30 seconds.");
				PrintToChatAll("\x04[AutoTrigger] \x01Start c1m3 trigger.");

				AcceptEntityInput(door, "Open");

				new Handle:posxdata = CreateDataPack();
				WritePackFloat(posxdata, 1207.4);
				WritePackFloat(posxdata, -3180.1);
				WritePackFloat(posxdata, 598.0);
				CreateTimer(30.0, WarpAllBots, posxdata);
				MapTrigger = true;
			}
		}
		
		new glass = FindEntityByName("breakble_glass_minifinale", -1); //Valve typing error, lol
		if (glass > 0)
		{
			GetEntityAbsOrigin(glass, pos1);
			if (CheckforBots(pos1, 200.0) && !MapTrigger)
			{
				//PrintToChatAll("\x04[AutoTrigger] \x01Bot found close to the Alarmed Windows, open sesame...");
				//PrintToChatAll("\x04[AutoTrigger] \x01Warping them all ahead in 30 seconds.");
				PrintToChatAll("\x04[AutoTrigger] \x01Start c1m3 trigger.");

				new Handle:posxdata = CreateDataPack();
				WritePackFloat(posxdata, 1207.4);
				WritePackFloat(posxdata, -3180.1);
				WritePackFloat(posxdata, 598.0);
				CreateTimer(30.0, WarpAllBots, posxdata);
				MapTrigger = true;
			}
		}
	}
(There are several of them)

I thought about modifying the "PrintToChatAll" to "PrintToAdmins" or something like, but I do not know if this will only work, if it has to modify something else...

If necessary the complete code, here it is: [L4D2] Survivor Bots Auto Trigger


I am very grateful if anyone can help me.
PepeZukas is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 03-16-2017 , 09:30   Re: Help to modify PrintToChatAll
Reply With Quote #2

ShowActivity convar only affects the ShowActivity natives. ie: https://sm.alliedmods.net/new-api/console/ShowActivity
Mitchell is offline
midnight9
Senior Member
Join Date: Nov 2012
Old 03-16-2017 , 13:01   Re: Help to modify PrintToChatAll
Reply With Quote #3

Quote:
Originally Posted by PepeZukas View Post
I want to change, with your help a plugin, so that the messages appear only to me, even properly configured in sourcemod.cfg, everyone can see them;

Code:
// Default: 13 (1+4+8)
 sm_show_activity 12
Here is the part of the code where the messages are:
Code:
if (StrContains(mapname, "c1m3_mall", false) != -1)
     {
         // Dead Center 03 - emergency door or windows
         // name door_hallway_lower4a, class prop_door_rotating, Input "Open"
         // they do the rest veeery slowly, but by themselves
         
         new door = FindEntityByName("door_hallway_lower4a", -1);
         
         decl Float:pos1[3];
         if (door > 0)
         {
             GetEntityAbsOrigin(door, pos1);
             if (CheckforBots(pos1, 200.0) && !MapTrigger)
             {
                 //PrintToChatAll("\x04[AutoTrigger] \x01Bot found close to the Emergency Door, open sesame...");
                 //PrintToChatAll("\x04[AutoTrigger] \x01Warping them all ahead in 30 seconds.");
                 PrintToChatAll("\x04[AutoTrigger] \x01Start c1m3 trigger.");
 
                 AcceptEntityInput(door, "Open");
 
                 new Handle:posxdata = CreateDataPack();
                 WritePackFloat(posxdata, 1207.4);
                 WritePackFloat(posxdata, -3180.1);
                 WritePackFloat(posxdata, 598.0);
                 CreateTimer(30.0, WarpAllBots, posxdata);
                 MapTrigger = true;
             }
         }
         
         new glass = FindEntityByName("breakble_glass_minifinale", -1); //Valve typing error, lol
         if (glass > 0)
         {
             GetEntityAbsOrigin(glass, pos1);
             if (CheckforBots(pos1, 200.0) && !MapTrigger)
             {
                 //PrintToChatAll("\x04[AutoTrigger] \x01Bot found close to the Alarmed Windows, open sesame...");
                 //PrintToChatAll("\x04[AutoTrigger] \x01Warping them all ahead in 30 seconds.");
                 PrintToChatAll("\x04[AutoTrigger] \x01Start c1m3 trigger.");
 
                 new Handle:posxdata = CreateDataPack();
                 WritePackFloat(posxdata, 1207.4);
                 WritePackFloat(posxdata, -3180.1);
                 WritePackFloat(posxdata, 598.0);
                 CreateTimer(30.0, WarpAllBots, posxdata);
                 MapTrigger = true;
             }
         }
     }
(There are several of them)

I thought about modifying the "PrintToChatAll" to "PrintToAdmins" or something like, but I do not know if this will only work, if it has to modify something else...

If necessary the complete code, here it is: [L4D2] Survivor Bots Auto Trigger


I am very grateful if anyone can help me.
I think something like this should work:

PHP Code:
for (new 1<= GetMaxClients(); i++)
{
      if (
IsClientInGame(i) && !IsFakeClient(i) && CheckCommandAccess(i"sm_ban"ADMFLAG_BAN))
      {
            
//PrintToChat (i, "\x04[AutoTrigger] \x01Bot found close to the Emergency Door, open sesame...");
            //PrintToChat (i, "\x04[AutoTrigger] \x01Warping them all ahead in 30 seconds.");
            
PrintToChat (i"\x04[AutoTrigger] \x01Start c1m3 trigger.");
      }


Last edited by midnight9; 03-16-2017 at 13:04.
midnight9 is offline
Timocop
AlliedModders Donor
Join Date: Mar 2013
Location: Germany
Old 03-16-2017 , 14:20   Re: Help to modify PrintToChatAll
Reply With Quote #4

To avoid unnecessary calls and slowdowns dont call methods everytime if you know the result will always be the same or doesnt change.
PHP Code:
for (new 1<= MaxClientsi++) //Best 
PHP Code:
new iMaxClients GetMaxClients();
for (new 
1<= iMaxClientsi++) //Ok

for (new GetMaxClients(); 0i--) //Ok 
PHP Code:
for (new 1<= GetMaxClients(); i++) //Bad 
Timocop is offline
xines
Veteran Member
Join Date: Aug 2013
Location: Denmark
Old 03-16-2017 , 14:27   Re: Help to modify PrintToChatAll
Reply With Quote #5

Quote:
Originally Posted by Timocop View Post
To avoid unnecessary calls and slowdowns dont call methods everytime if you know the result will always be the same or doesnt change.
PHP Code:
for (new 1<= MaxClientsi++) //Best 
PHP Code:
new iMaxClients GetMaxClients();
for (new 
1<= iMaxClientsi++) //Ok

for (new GetMaxClients(); 0i--) //Ok 
PHP Code:
for (new 1<= GetMaxClients(); i++) //Bad 
Since the function is set to be deprecated, we should only focus on using the MaxClients dynamic variable.
__________________
xines is offline
PepeZukas
Member
Join Date: Oct 2015
Location: Banana Republic
Old 03-16-2017 , 20:52   Re: Help to modify PrintToChatAll
Reply With Quote #6

Quote:
Originally Posted by Timocop View Post
To avoid unnecessary calls and slowdowns dont call methods everytime if you know the result will always be the same or doesnt change.
PHP Code:
for (new 1<= MaxClientsi++) //Best 
PHP Code:
new iMaxClients GetMaxClients();
for (new 
1<= iMaxClientsi++) //Ok

for (new GetMaxClients(); 0i--) //Ok 
PHP Code:
for (new 1<= GetMaxClients(); i++) //Bad 
I'm bad at writing these codes, how could I include these lines in the plugin?

I thank you all for all the tips.
PepeZukas is offline
midnight9
Senior Member
Join Date: Nov 2012
Old 03-17-2017 , 02:38   Re: Help to modify PrintToChatAll
Reply With Quote #7

Quote:
Originally Posted by Timocop View Post
To avoid unnecessary calls and slowdowns dont call methods everytime if you know the result will always be the same or doesnt change.
PHP Code:
for (new 1<= MaxClientsi++) //Best 
PHP Code:
 new iMaxClients GetMaxClients();
 for (new 
1<= iMaxClientsi++) //Ok
 
 
for (new GetMaxClients(); 0i--) //Ok 
PHP Code:
for (new 1<= GetMaxClients(); i++) //Bad 

Ahh yes, my bad.
midnight9 is offline
midnight9
Senior Member
Join Date: Nov 2012
Old 03-17-2017 , 12:16   Re: Help to modify PrintToChatAll
Reply With Quote #8

Quote:
Originally Posted by PepeZukas View Post
I'm bad at writing these codes, how could I include these lines in the plugin?

I thank you all for all the tips.

Code:
 if (StrContains(mapname, "c1m3_mall", false) != -1)
 {
  // Dead Center 03 - emergency door or windows
  // name door_hallway_lower4a, class prop_door_rotating, Input "Open"
  // they do the rest veeery slowly, but by themselves
  
  new door = FindEntityByName("door_hallway_lower4a", -1);
  
  decl Float:pos1[3];
  if (door > 0)
  {
   GetEntityAbsOrigin(door, pos1);
   if (CheckforBots(pos1, 200.0) && !MapTrigger)
   {
         for (new i = 1; i <= MaxClients; i++)
         {
              if (IsClientInGame(i) && !IsFakeClient(i) && CheckCommandAccess(i, "sm_ban", ADMFLAG_BAN))
              {
                    //PrintToChat (i, "\x04[AutoTrigger] \x01Bot found close to the Emergency Door, open sesame...");
                    //PrintToChal (i, "\x04[AutoTrigger] \x01Warping them all ahead in 30 seconds.");
                    PrintToChat (i, "\x04[AutoTrigger] \x01Start c1m3 trigger.");
              }
         } 
     
         AcceptEntityInput(door, "Open");
    
         new Handle:posxdata = CreateDataPack();
         WritePackFloat(posxdata, 1207.4);
         WritePackFloat(posxdata, -3180.1);
         WritePackFloat(posxdata, 598.0);
         CreateTimer(30.0, WarpAllBots, posxdata);
         MapTrigger = true;
   }
  }

Last edited by midnight9; 03-17-2017 at 12:19.
midnight9 is offline
Fortis
Junior Member
Join Date: Nov 2016
Old 03-18-2017 , 01:17   Re: Help to modify PrintToChatAll
Reply With Quote #9

PrintToChatAll prints a message to everyone in the chat.
PrintToChat prints a message to the client.

Example:
PrintToChatAll("Hello"); - This prints a chat to everyone saying hello.
PrintToChat(client, "Hello"); - This prints a chat to you saying hello.

Client can be replaced with i, depending on how it is being used.

Last edited by Fortis; 03-18-2017 at 01:19.
Fortis is offline
PepeZukas
Member
Join Date: Oct 2015
Location: Banana Republic
Old 03-18-2017 , 10:34   Re: Help to modify PrintToChatAll
Reply With Quote #10

Thank you all for the help.
PepeZukas 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 03:00.


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