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

[CS:GO] How to run a script (plugin) for all?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Fastmancz
Senior Member
Join Date: Jul 2013
Location: Czech Republic
Old 07-09-2014 , 11:20   [CS:GO] How to run a script (plugin) for all?
Reply With Quote #1

Hi,

I'm doing little plugin, but there is a somewhat larger problems with the code. This is my code:
Code:
#include <sourcemod>
#include <sdktools>
#define CS_TEAM_CT  3
#define CS_TEAM_T 2    /**< Terrorists. */ 
#define GAMEOVER_SOUND "zombieapocalypse.mp3"

public Plugin:myinfo =
{
	name = "Zombie Apocalypse",
	author = "Fastmancz",
	description = "Zombie Apocalypse",
	version = "1.0",
	url = "http://www.twse.cz/"
};
//HP regeneration - https://forums.alliedmods.net/showthread.php?p=500636

public OnMapStart()
{
 AddFileToDownloadsTable("sound/cmg/zombieapocalypse.mp3");
}  

public OnPluginStart()
{
RegConsoleCmd("sm_zombie", zombie,"Zombie");  
}

stock FakePrecacheSound( const String:szPath[] )
{
	AddToStringTable( FindStringTable( "soundprecache" ), szPath );
}   

public Action:zombie(client, args)
{
  if (GetClientTeam(client) == CS_TEAM_CT) 
		{
			if (IsPlayerAlive(client)) 
			{
        PrintToChatAll("\x04[TWSE APOCALYPSE]\x01\x0B\x01Na TWSE zautocil Zombie virus a dostal se na Jail!!!", client);
        ServerCommand("sm_hsay TWSE ZOMBIE APOCALYPSE ZACALA A NEDÁ SE ZASTAVIT!!!");  
        decl String:buffer[256];
	     EmitSoundToAll("play *cmg/zombieapocalypse.mp3");  
	      AddFileToDownloadsTable(buffer);
	      PrecacheSound(GAMEOVER_SOUND);  
        ServerCommand ("sm_blind @all 230");
        GivePlayerItem(client, "weapon_negev");
			}
      if (GetClientTeam(client) == CS_TEAM_T)
      {
      SetEntProp( client, Prop_Send, "m_iHealth", 1000 );
      SetEntProp( client, Prop_Send, "m_iMaxHealth", 1000 );  
      }
      
		}
Thank you GsiX and MasterOfTheXP for help.

1a.) Music does not start.
PHP Code:
EmitSoundToAll("play *cmg/zombieapocalypse.mp3"); 
1b.) Music start only for me.
PHP Code:
ClientCommand(client"play *cmg/zombieapocalypse.mp3"); 
2.) This command has put all (CT) gun "negev". It's Not. The weapon negev give only for me.
PHP Code:
GivePlayerItem(client"weapon_negev"); 
3.) The terrorists have to get 1000 HP. Not work.
PHP Code:
      if (GetClientTeam(client) == CS_TEAM_T)
      {
      
SetEntPropclientProp_Send"m_iHealth"1000 );
      
SetEntPropclientProp_Send"m_iMaxHealth"1000 );  
      } 
Therefore, I ask, how can I do to make weapons or HP got all (CT or T)?
My plugin works right for individuals (not for all, but where is problem?).

Thank you for all the answers.

Last edited by Fastmancz; 07-09-2014 at 11:25.
Fastmancz is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-09-2014 , 11:35   Re: [CS:GO] How to run a script (plugin) for all?
Reply With Quote #2

A few things...

PHP Code:
EmitSoundToAll("play *cmg/zombieapocalypse.mp3"); 
should be
PHP Code:
EmitSoundToAll("*cmg/zombieapocalypse.mp3"); 
If you want to do something for all clients, you need to loop through them... something like

PHP Code:
for (new 1<= MaxClientsi++)
{
    if (
IsClientInGame(i))
    {
        
//Do command(s) here, using i instead of client
        
new team GetClientTeam(i);
        if (
team CS_TEAM_SPECTATOR)
        {
            
GivePlayerItem(i"weapon_negev");
        }
        if (
team == CS_TEAM_T)
        {
            
SetEntPropiProp_Send"m_iMaxHealth"1000 );
            
SetEntPropiProp_Send"m_iHealth"1000 );
        }
    }

(I don't usually do CS:GO stuff, so I don't know if the max health thing works)
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Fastmancz
Senior Member
Join Date: Jul 2013
Location: Czech Republic
Old 07-09-2014 , 12:33   Re: [CS:GO] How to run a script (plugin) for all?
Reply With Quote #3

Quote:
Originally Posted by Powerlord View Post
A few things...

PHP Code:
EmitSoundToAll("play *cmg/zombieapocalypse.mp3"); 
should be
PHP Code:
EmitSoundToAll("*cmg/zombieapocalypse.mp3"); 
If you want to do something for all clients, you need to loop through them... something like

PHP Code:
for (new 1<= MaxClientsi++)
{
    if (
IsClientInGame(i))
    {
        
//Do command(s) here, using i instead of client
        
new team GetClientTeam(i);
        if (
team CS_TEAM_SPECTATOR)
        {
            
GivePlayerItem(i"weapon_negev");
        }
        if (
team == CS_TEAM_T)
        {
            
SetEntPropiProp_Send"m_iMaxHealth"1000 );
            
SetEntPropiProp_Send"m_iHealth"1000 );
        }
    }

(I don't usually do CS:GO stuff, so I don't know if the max health thing works)
Thanks for reply!
This is my new code:
Code:
#include <sourcemod>
#include <sdktools>
#define CS_TEAM_NONE        0    /**< No team yet. */ 
#define CS_TEAM_SPECTATOR    1    /**< Spectators. */ 
#define CS_TEAM_T             2    /**< Terrorists. */ 
#define CS_TEAM_CT            3    /**< Counter-Terrorists. */  
#define GAMEOVER_SOUND "zombieapocalypse.mp3"

public Plugin:myinfo =
{
	name = "Zombie Apocalypse",
	author = "Fastmancz",
	description = "Zombie Apocalypse",
	version = "1.0",
	url = "http://www.twse.cz/"
};
//HP regeneration - https://forums.alliedmods.net/showthread.php?p=500636

public OnMapStart()
{
 AddFileToDownloadsTable("sound/cmg/zombieapocalypse.mp3");
}  

public OnPluginStart()
{
RegConsoleCmd("sm_zombie", zombie,"Zombie");  
}

stock FakePrecacheSound( const String:szPath[] )
{
	AddToStringTable( FindStringTable( "soundprecache" ), szPath );
}   

public Action:zombie(client, args)
{
  if (GetClientTeam(client) == CS_TEAM_CT) 
		{
			if (IsPlayerAlive(client)) 
			{
        PrintToChatAll("\x04[TWSE APOCALYPSE]\x01\x0B\x01Na TWSE zautocil Zombie virus a dostal se na Jail!!!", client);
        ServerCommand("sm_hsay TWSE ZOMBIE APOCALYPSE ZACALA A NEDÁ SE ZASTAVIT!!!");  
        decl String:buffer[256];
	     EmitSoundToAll("*cmg/zombieapocalypse.mp3");  
	      AddFileToDownloadsTable(buffer);
	      PrecacheSound(GAMEOVER_SOUND);  
        ServerCommand ("sm_blind @all 230");
			}
      for (new i = 1; i <= MaxClients; i++) 
{ 
    if (IsClientInGame(i)) 
    { 
        //Do command(s) here, using i instead of client 
        new team = GetClientTeam(i); 
        if (team > CS_TEAM_SPECTATOR) 
        { 
            GivePlayerItem(i, "weapon_negev"); 
        } 
        if (team == CS_TEAM_T) 
        { 
            SetEntProp( i, Prop_Send, "m_iMaxHealth", 1000 ); 
            SetEntProp( i, Prop_Send, "m_iHealth", 1000 ); 
        } 
    } 
}  
      
		}
		else
Works!
PHP Code:
//Do command(s) here, using i instead of client 
        
new team GetClientTeam(i); 
        if (
team CS_TEAM_SPECTATOR
        { 
            
GivePlayerItem(i"weapon_negev"); 
        } 
But..
HP and music not work.
Thank you all for the answers.
Fastmancz is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-09-2014 , 12:55   Re: [CS:GO] How to run a script (plugin) for all?
Reply With Quote #4

FakePrecacheSound("*cmg/zombieapocalypse.mp3") needs to be called in OnMapStart

Not sure how to fix the HP thingy, though.
__________________
Not currently working on SourceMod plugin development.
Powerlord 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 23:00.


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