- Сообщения
- 2,382
- Реакции
- 2,187
- Команда форума
- #41
-=Batista=-, он имел ввиду многострочный комментарий.
#include <sourcemod>
#include <sdktools>
#pragma semicolon 1
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "tuty"
#define SOUND_FILE "pedic/pedic.mp3" //sound
new Handle:gPluginEnabled = INVALID_HANDLE;
new Handle:gHealthAmount = INVALID_HANDLE;
new Handle:gMinHealth = INVALID_HANDLE;
new Handle:gMedicCost = INVALID_HANDLE;
//new Handle:gShowInChat = INVALID_HANDLE; //Сообщение в общий чат
new Handle:gMaxTimeUse = INVALID_HANDLE;
new Handle:gCvarmedicsongs = INVALID_HANDLE;
new gPlayerMoney;
new gUsedMedic[ 33 ];
public Plugin:myinfo =
{
name = "CSS Medic",
author = PLUGIN_AUTHOR,
description = "You can call a medic.",
version = PLUGIN_VERSION,
url = "www.ligs.us"
};
public OnPluginStart()
{
HookEvent( "player_spawn", Event_PlayerSpawn );
RegConsoleCmd( "say", Command_Medic );
RegConsoleCmd( "say_team", Command_Medic );
// CreateConVar( "cssmedic_version", PLUGIN_VERSION, "CSS Medic Version", FCVAR_PLUGIN | FCVAR_SPONLY | FCVAR_REPLICATED | FCVAR_NOTIFY );
gPluginEnabled = CreateConVar( "css_medic", "1" ); //Выключение плагина
gMinHealth = CreateConVar( "css_medic_minhealth", "40" );
gHealthAmount = CreateConVar( "css_medic_healhealth", "100" );
gMedicCost = CreateConVar( "css_medic_cost", "2000" );
gCvarmedicsongs = CreateConVar( "css_medicsound", "pedic/pedic.mp3");
// gShowInChat = CreateConVar( "css_medic_showcall", "1" ); //Сообщение в общий чат
gMaxTimeUse = CreateConVar( "css_medic_maxuse", "1" );
AutoExecConfig(true, "medic"); //Создание конфигурационного файла
LoadTranslations("medic.phrases"); //Файл перевода
gPlayerMoney = FindSendPropOffs( "CCSPlayer", "m_iAccount" );
}
public OnClientConnected( id )
{
gUsedMedic[ id ] = 0;
}
public OnClientDisconnect( id )
{
gUsedMedic[ id ] = 0;
}
//public OnMapStart()
//{
// decl String:MedicSound[ 100 ]; //Sound
// FormatEx( MedicSound, sizeof( MedicSound ) - 1, "sound/%s", SOUND_FILE );
//
// if( FileExists( MedicSound ) )
// {
// AddFileToDownloadsTable( MedicSound );
// PrecacheSound( SOUND_FILE, true );
// }
//} //Звук
public Action:Event_PlayerSpawn( Handle:event, const String:name[], bool:dontBroadcast )
{
if( GetConVarInt( gPluginEnabled ) == 1 )
{
new id = GetClientOfUserId( GetEventInt( event, "userid" ) );
gUsedMedic[ id ] = 0;
}
}
public MessagePrinToChat(id, String:sText[1256])
{
ReplaceString(sText, sizeof(sText), "#", "\x07");
PrintToChat(id, sText);
}
public Action:Command_Medic( id, args )
{
decl String:Said[ 128 ],
String:sText[ 1256 ];
GetCmdArgString( Said, sizeof( Said ) - 1 );
StripQuotes( Said );
TrimString( Said );
if( StrEqual( Said, "!medic" )|| StrEqual( Said, "medic" )|| StrEqual( Said, "doctor" ) || StrEqual( Said, "!doctor" ) || StrEqual( Said, "медик" ) || StrEqual( Said, "!медик" ))
{
if( GetConVarInt( gPluginEnabled ) == 0 )
{
Format(sText, sizeof(sText), "%t", "Message1");
MessagePrinToChat(id, sText);
return Plugin_Continue;
}
// if( !IsPlayerAlive( id ) ) //Уведомление о невозможности использования медика
// {
// Format(sText, sizeof(sText), "%t", "Message2");
// MessagePrinToChat(id, sText);
//
// return Plugin_Continue;
// }
new maxtime = GetConVarInt( gMaxTimeUse );
if( gUsedMedic[ id ] >= maxtime )
{
Format(sText, sizeof(sText), "%t", "Message3", maxtime);
MessagePrinToChat(id, sText);
return Plugin_Continue;
}
new money = GetClientMoney( id );
new cost = GetConVarInt( gMedicCost );
if( money < cost )
{
Format(sText, sizeof(sText), "%t", "Message4", cost);
MessagePrinToChat(id, sText);
return Plugin_Continue;
}
if( GetClientHealth( id ) >= GetConVarInt( gMinHealth ) )
{
Format(sText, sizeof(sText), "%t", "Message5");
MessagePrinToChat(id, sText);
return Plugin_Continue;
}
gUsedMedic[ id ]++;
SetEntProp( id, Prop_Data, "m_iHealth", GetConVarInt( gHealthAmount ) );
SetClientMoney( id, money - cost );
Format(sText, sizeof(sText), "%t", "Message6");
MessagePrinToChat(id, sText);
// if( GetConVarInt( gShowInChat, gCvarmedicsongs ) != 0 ) //Сообщение в общий чат
// {
// decl String:Name[ 32 ];
// GetClientName( id, Name, sizeof( Name ) - 1 );
//
// PrintToChatAll( "\x03%s \x01(CALLED): \x04Medic!", Name );
// }
//
// new Float:fOrigin[ 3 ]; //Sound
// GetClientAbsOrigin( id, Float:fOrigin );
//
// EmitAmbientSound( SOUND_FILE, fOrigin, id, SNDLEVEL_CONVO );
// AttachClientIcon( id );
}
return Plugin_Continue;
}
stock SetClientMoney( index, money )
{
if( gPlayerMoney != -1 )
{
SetEntData( index, gPlayerMoney, money );
}
}
stock GetClientMoney( index )
{
if( gPlayerMoney != -1 )
{
return GetEntData( index, gPlayerMoney );
}
return 0;
}
stock AttachClientIcon( index )
{
TE_Start( "RadioIcon" );
TE_WriteNum( "m_iAttachToClient", index );
TE_SendToAll();
}
Тебе необходимо убрать все (или почти все - там на сообщения ещё код) //, иначе звук и не грузится, и не воспроизводится вовсе.гляньте вот код
Тебе необходимо убрать все (или почти все - там на сообщения ещё код) //, иначе звук и не грузится, и не воспроизводится вовсе.
ОффтопРаньше я не работал со звуком и сам не вникал, почему в этом плагине часто жаловались на него. А сейчас, хоть бери, переписывай это всё.
#include <sourcemod>
#include <sdktools>
#pragma semicolon 1
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "tuty"
#define SOUND_FILE "pedic/pedic.mp3" //sound
new Handle:gPluginEnabled = INVALID_HANDLE;
new Handle:gHealthAmount = INVALID_HANDLE;
new Handle:gMinHealth = INVALID_HANDLE;
new Handle:gMedicCost = INVALID_HANDLE;
new Handle:gShowInChat = INVALID_HANDLE;
new Handle:gMaxTimeUse = INVALID_HANDLE;
new Handle:gCvarmedicsongs = INVALID_HANDLE;
new gPlayerMoney;
new gUsedMedic[MAXPLAYERS+1];
public Plugin:myinfo =
{
name = "CSS Medic",
author = PLUGIN_AUTHOR,
description = "You can call a medic.",
version = PLUGIN_VERSION,
url = "www.ligs.us"
};
public OnPluginStart()
{
HookEvent( "player_spawn", Event_PlayerSpawn );
RegConsoleCmd( "say", Command_Medic );
RegConsoleCmd( "say_team", Command_Medic );
CreateConVar( "cssmedic_version", PLUGIN_VERSION, "CSS Medic Version", FCVAR_PLUGIN | FCVAR_SPONLY | FCVAR_REPLICATED | FCVAR_NOTIFY );
gPluginEnabled = CreateConVar( "css_medic", "1" );
gMinHealth = CreateConVar( "css_medic_minhealth", "40" );
gHealthAmount = CreateConVar( "css_medic_healhealth", "100" );
gMedicCost = CreateConVar( "css_medic_cost", "2000" );
gShowInChat = CreateConVar( "css_medic_showcall", "1" );
gCvarmedicsongs = CreateConVar( "css_medicsound", "pedic/pedic.mp3");
gMaxTimeUse = CreateConVar( "css_medic_maxuse", "1" );
AutoExecConfig(true, "medic"); //Создание конфигурационного файла
LoadTranslations("medic.phrases"); //Файл перевода
gPlayerMoney = FindSendPropOffs( "CCSPlayer", "m_iAccount" );
}
public OnClientConnected( id )
{
gUsedMedic[ id ] = 0;
}
public OnClientDisconnect( id )
{
gUsedMedic[ id ] = 0;
}
public OnMapStart()
{
decl String:MedicSound[ 100 ];
FormatEx( MedicSound, sizeof( MedicSound ) - 1, "sound/%s", SOUND_FILE );
if( FileExists( MedicSound ) )
{
AddFileToDownloadsTable( MedicSound );
PrecacheSound( SOUND_FILE, true );
}
}
public Action:Event_PlayerSpawn( Handle:event, const String:name[], bool:dontBroadcast )
{
if( GetConVarInt( gPluginEnabled ) == 1 )
{
new id = GetClientOfUserId( GetEventInt( event, "userid" ) );
gUsedMedic[ id ] = 0;
}
}
public Action:Command_Medic( id, args )
{
decl String:Said[ 128 ];
GetCmdArgString( Said, sizeof( Said ) - 1 );
StripQuotes( Said );
TrimString( Said );
if( StrEqual( Said, "!medic" ) || StrEqual( Said, "!doctor" ) )
{
if( GetConVarInt( gPluginEnabled ) == 0 )
{
PrintToChat( id, "\x03[CSS Medic] \x01Sorry, you can't call a \x04Medic\x01 !" );
return Plugin_Continue;
}
if( !IsPlayerAlive( id ) )
{
PrintToChat( id, "\x03[CSS Medic] \x01You can't call \x04Medic \x01while you are dead!" );
return Plugin_Continue;
}
new maxtime = GetConVarInt( gMaxTimeUse );
if( gUsedMedic[ id ] >= maxtime )
{
PrintToChat( id, "\x03[CSS Medic] \x01You can call \x04Medic \x01only \x03%d \x01times per round!", maxtime );
return Plugin_Continue;
}
new money = GetClientMoney( id );
new cost = GetConVarInt( gMedicCost );
if( money < cost )
{
PrintToChat( id, "\x03[CSS Medic] \x01You don't have enough money to call a \x04Medic\x01 ! You need %d$", cost );
return Plugin_Continue;
}
if( GetClientHealth( id ) >= GetConVarInt( gMinHealth ) )
{
PrintToChat( id, "\x03[CSS Medic] \x01Hey dude! You have enough health, and you don't need a \x04Medic \x01! Go back to fight!" );
return Plugin_Continue;
}
gUsedMedic[ id ]++;
SetEntProp( id, Prop_Data, "m_iHealth", GetConVarInt( gHealthAmount ) );
SetClientMoney( id, money - cost );
PrintToChat( id, "\x03[CSS Medic] \x01Successfully called a \x04Medic\x01 ! You are now healed." );
if( GetConVarInt( gShowInChat, gCvarmedicsongs ) != 0 )
{
decl String:Name[ 32 ];
GetClientName( id, Name, sizeof( Name ) - 1 );
PrintToChatAll( "\x03%s \x01(CALLED): \x04Medic!", Name );
}
new Float:fOrigin[ 3 ];
GetClientAbsOrigin( id, Float:fOrigin );
EmitAmbientSound( SOUND_FILE, fOrigin, id, SNDLEVEL_CONVO );
AttachClientIcon( id );
}
return Plugin_Continue;
}
stock SetClientMoney( index, money )
{
if( gPlayerMoney != -1 )
{
SetEntData( index, gPlayerMoney, money );
}
}
stock GetClientMoney( index )
{
if( gPlayerMoney != -1 )
{
return GetEntData( index, gPlayerMoney );
}
return 0;
}
stock AttachClientIcon( index )
{
TE_Start( "RadioIcon" );
TE_WriteNum( "m_iAttachToClient", index );
TE_SendToAll();
}
rotmir, потому что ты сделал бред. У тебя звук в кваре, а ты получаешь его как число.
Вот код который добавил плагин без ошибок компилится , но звук все равно не качается и не проигрывает .rotmir, создай глобальную переменную для звука, при старте карты делай прекеш и добавляй для загрузки.
именно! cstrike/cfg/sourcemod/
Находишь старый работающий звук, копируешь полностью его имя файла (вместе с расширением, если отображается), удаляешь его, новый звук называешь именем предыдущего (сохранённого) звука и заливаешь вместо старого.помогите сменить звук
Находишь старый работающий звук, копируешь полностью его имя файла (вместе с расширением, если отображается), удаляешь его, новый звук называешь именем предыдущего (сохранённого) звука и заливаешь вместо старого.
Так все пути и имя файла не изменены - всё должно работать.