[ Новые сообщения · Участники · Правила форума · Поиск · RSS ]
  • Страница 1 из 1
  • 1
Форум » Форум » Уроки SourceMod (SourcePawn) Скриптинга » Мини скрипты/плагины
Мини скрипты/плагины
rootДата: Пятница, 01.03.2013, 14:44 | Сообщение # 1
Генералиссимус
Группа: Администраторы
Сообщений: 561
Статус: Offline
Если игрок жмет F1(автопокупка), в чате пишется "guns" от него. Хорошо для DeathMatch
PHP код:
#include <sourcemod>  

public OnPluginStart()  
{  
    
RegConsoleCmd("autobuy", autobuy);  
}  

public 
Action:autobuy(client, args)  
{  
    
FakeClientCommand(client, "say guns")  
}
 
rootДата: Пятница, 01.03.2013, 15:19 | Сообщение # 2
Генералиссимус
Группа: Администраторы
Сообщений: 561
Статус: Offline
Мониторинг оставшився в живых игроков
PHP код:
#include <sourcemod>

new Handle:GAP_Timer;
new 
x;
new 
xx;

public 
OnPluginStart()
{
    
ServerCommand("sv_hudhint_sound 0");
    
HookEvent("round_start", Event_RoundStart);
    
HookEvent("round_end", Event_RoundEnd);
}

public 
Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    
x = 0;
    
xx = 0;
    if (
GAP_Timer != INVALID_HANDLE)
    {
        
KillTimer(GAP_Timer);
        
GAP_Timer = INVALID_HANDLE;
    }
    
GAP_Timer = CreateTimer(1.0, GAP_TimerTell, _, TIMER_REPEAT);
}

public 
Action:Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
{
    
x = 0;
    
xx = 0;
    if (
GAP_Timer != INVALID_HANDLE)
    {
        
KillTimer(GAP_Timer);
        
GAP_Timer = INVALID_HANDLE;
    }
}

public 
Action:GAP_TimerTell(Handle:timer)
{
    
x = 0;
    
xx = 0;
    for (new 
i = 1; i <= MaxClients; i++)
    {
        if (
IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == 2)
        {
            
x++;
        }
    }
    for (new 
i = 1; i <= MaxClients; i++)
    {
        if (
IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == 3)
        {
            
xx++;
        }
    }
    
PrintHintTextToAll("%d T:%d CT", x, xx);
    return 
Plugin_Continue;
}
 
rootДата: Пятница, 01.03.2013, 15:22 | Сообщение # 3
Генералиссимус
Группа: Администраторы
Сообщений: 561
Статус: Offline
Для функции OnPlayerRunCmd
PHP код:
public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
доступные кнопки, кнопки не только ксс, так что некоторые могут не работать
PHP код:
#define IN_ATTACK      (1 << 0)
#define IN_JUMP   (1 << 1)
#define IN_DUCK   (1 << 2)
#define IN_FORWARD    (1 << 3)
#define IN_BACK   (1 << 4)
#define IN_USE      (1 << 5)
#define IN_CANCEL      (1 << 6)
#define IN_LEFT   (1 << 7)
#define IN_RIGHT        (1 << 8)
#define IN_MOVELEFT  (1 << 9)
#define IN_MOVERIGHT        (1 << 10)
#define IN_ATTACK2    (1 << 11)
#define IN_RUN      (1 << 12)
#define IN_RELOAD      (1 << 13)
#define IN_ALT1   (1 << 14)
#define IN_ALT2   (1 << 15)
#define IN_SCORE        (1 << 16)       // Used by client.dll for when scoreboard is held down
#define IN_SPEED        (1 << 17)   // Player is holding the speed key
#define IN_WALK   (1 << 18)    // Player holding walk key
#define IN_ZOOM   (1 << 19)    // Zoom key for HUD zoom
#define IN_WEAPON1    (1 << 20) // weapon defines these bits
#define IN_WEAPON2    (1 << 21) // weapon defines these bits
#define IN_BULLRUSH  (1 << 22)
#define IN_GRENADE1  (1 << 23)    // grenade 1
#define IN_GRENADE2  (1 << 24)    // grenade 2
 
rootДата: Пятница, 01.03.2013, 16:45 | Сообщение # 4
Генералиссимус
Группа: Администраторы
Сообщений: 561
Статус: Offline
Не отображает в чате любой текст с !
Пример:
!rs
!rank
!admin

PHP код:
public OnPluginStart()  
{  
     
RegConsoleCmd("say", hidetrigger);  
     
RegConsoleCmd("say_team", hidetrigger);  
}  

public 
Action:hidetrigger(client, args)  
{  
     if (
args > 0)  
     {  
         
decl String:command[65]; GetCmdArg(1, command, 65);  
         if (
command[0] == '!') return Plugin_Handled;  
     }  
     return 
Plugin_Continue;  
}
 
rootДата: Пятница, 01.03.2013, 16:48 | Сообщение # 5
Генералиссимус
Группа: Администраторы
Сообщений: 561
Статус: Offline
Запрет команды status всем, кроме админа с флагом z
PHP код:
#pragma semicolon 1 
#include <sourcemod> 

public OnPluginStart() RegConsoleCmd("status", Status); 

public 
Action:Status(client, args) 
{ 
    if (
client != 0 && !(GetUserFlagBits(client) & ADMFLAG_ROOT)) 
    { 
        
PrintToChat(client, "\x01\x05[SM] \x03Нет доступа."); 
        return 
Plugin_Handled; 
    } 
    return 
Plugin_Continue; 
}
 
rootДата: Пятница, 01.03.2013, 16:52 | Сообщение # 6
Генералиссимус
Группа: Администраторы
Сообщений: 561
Статус: Offline
Запрет выброса оружия
PHP код:
#include  

#define PLUGIN_VERSION "1.0" 

public Plugin:myinfo = 
{ 
    
name = "Restrict weapon drop", 
    
author = "ilga80", 
    
description = "restrict weapons drop", 
    
version = PLUGIN_VERSION, 
    
url = "/" 
} 

public 
OnPluginStart() 
{ 
    
RegConsoleCmd("drop", drop); 
} 

public 
Action:drop(client, args) 
{ 
    
PrintToChat(client, "\x01\x07%06XЗапрещено выкидывать оружие", 0xFFFF00); 
    return 
Plugin_Handled; 
}
 
rootДата: Пятница, 01.03.2013, 16:53 | Сообщение # 7
Генералиссимус
Группа: Администраторы
Сообщений: 561
Статус: Offline
Запрет выброса оружия №2
PHP код:
#include  

#define PLUGIN_VERSION "1.0" 

public Plugin:myinfo = 
{ 
    
name = "Restrict weapon drop", 
    
author = "ilga80", 
    
description = "restrict weapons drop", 
    
version = PLUGIN_VERSION, 
    
url = "/" 
} 

public 
Action:CS_OnCSWeaponDrop(client, weaponIndex) 
{ 
    return 
Plugin_Handled; 
}
 
rootДата: Пятница, 01.03.2013, 19:09 | Сообщение # 8
Генералиссимус
Группа: Администраторы
Сообщений: 561
Статус: Offline
Быстрая смена команды
PHP код:
#pragma semicolon 1

#include <sourcemod>
#include <cstrike>

public OnPluginStart() 
{
    
AddCommandListener(say, "say");  
    
AddCommandListener(say, "say_team"); 
}

public 
Action:say(i, const String:command[], argc) 
{  
    
decl String:csay[8];
    
GetCmdArgString(csay, sizeof(csay));
    
StripQuotes(csay);
    
TrimString(csay);
    new 
frags = GetClientFrags(i);
    if (((
strcmp(csay, "!sp", false) == 0) || (strcmp(csay, "!spec", false) == 0)) && i > 0 && GetClientTeam(i) != 1) 
        
CS_SwitchTeam(i, 1);        
    else if (((
strcmp(csay, "!t", false) == 0) || (strcmp(csay, "!ter", false) == 0)) && i > 0 && GetClientTeam(i) != 2)
    {
        
SetEntProp(i, Prop_Data, "m_iFrags", frags + 1);
        
ChangeClientTeam(i, 2);
    }
    else if (((
strcmp(csay, "!c", false) == 0) || (strcmp(csay, "!ct", false) == 0)) && i > 0 && GetClientTeam(i) != 3)
    {
        
SetEntProp(i, Prop_Data, "m_iFrags", frags + 1);
        
ChangeClientTeam(i, 3);
    }
}

Упрощенная версия перехода в наблюдатели
PHP код:
#pragma semicolon 1

#include <sourcemod>
#include <cstrike>

public OnPluginStart() 
{
    
AddCommandListener(say, "say");  
    
AddCommandListener(say, "say_team"); 
}

public 
Action:say(i, const String:command[], argc) 
{  
    
decl String:csay[8];
    
GetCmdArgString(csay, sizeof(csay));
    
StripQuotes(csay);
    
TrimString(csay);    
    if (((
strcmp(csay, "!sp", false) == 0) || (strcmp(csay, "!spec", false) == 0)) && i > 0 && GetClientTeam(i) != 1) 
        
CS_SwitchTeam(i, 1);
}
 
rootДата: Пятница, 01.03.2013, 22:02 | Сообщение # 9
Генералиссимус
Группа: Администраторы
Сообщений: 561
Статус: Offline
Переход в наблюдатели №2
PHP код:
#pragma semicolon 1 

#include  
#include  

#define PLUGIN_VERSION "1.0"  

public Plugin:myinfo =  
{  
    
name = "fast spectator teamchange",  
    
author = "ilga80",  
    
description = "Быстрый переход в наблюдатели",  
    
version = PLUGIN_VERSION,  
    
url = "/"  
}  

public 
OnPluginStart()  
{ 
    
AddCommandListener(say, "say");   
    
AddCommandListener(say, "say_team");  
} 

public 
Action:say(client, const String:command[], argc)  
{ 
    
decl String:sp[64]; 
    
GetCmdArgString(sp, sizeof(sp) - 1); 
    
StripQuotes(sp); 
    
TrimString(sp); 
    if ((
StrEqual(sp, "!sp", false) || (StrEqual(sp, "!ыз", false)) || (StrEqual(sp, "!spec", false))) && client > 0 && GetClientTeam(client) != 1) 
    { 
        
ChangeClientTeam(client, 1); 
        
PrintToChat(client, "\x01\x07%06XВы перешли в наблюдатели", 0xFFFF00); 
    } 
}
 
rootДата: Воскресенье, 31.03.2013, 02:03 | Сообщение # 10
Генералиссимус
Группа: Администраторы
Сообщений: 561
Статус: Offline
Пример запрета скорострелок навсегда
PHP код:
#include <sourcemod> 
#include <sdktools_functions> 
#include <sdktools_entinput> 
#include <cstrike> 

#define scorostrelki    "sg550|g3sg1" 

new Handle:g_Enable; 

public 
OnPluginStart() 
{ 
    
HookEvent("item_pickup", item_pickup); 
    
g_Enable = CreateConVar("sg_restrict", "1", "Restrict sg550 & g3sg1", FCVAR_NOTIFY, true, 0.0, true, 1.0); 
} 

public 
Action:CS_OnBuyCommand(client, const String:item[])  
{ 
    if (
GetConVarBool(g_Enable)) 
    { 
         if (
strcmp(item, "sg550", false) == 0 || strcmp(item, "g3sg1", false) == 0) 
         { 
            
ClientCommand(client, "play buttons/weapon_cant_buy.wav"); 
            
PrintToChat(client, "\x0700FFFF%N\07FF0000, \07F8F8FFэто оружие запрещено\07FFFF00!", client); 
            for (new 
i = 1; i <= MaxClients; i++) 
            { 
                if(
IsClientInGame(i) && i != client) 
                { 
                    
decl String:tag[5]; 
                    new 
team = GetClientTeam(client); 
                    if(
team == 2) 
                    { 
                        
Format(tag, 5, "[T]"); 
                    } 
                    else if(
team == 3) 
                    { 
                        
Format(tag, 5, "[CT]"); 
                    } 
                    
PrintToChat(i, "\x0700FFFFИгрок \07FFFF00%s \07F8F8FF%N \x0700FFFFпытается купить скорострелку.", tag, client); 
                } 
            } 
            return 
Plugin_Handled; 
         } 
    } 
    return 
Plugin_Continue; 
} 

public 
item_pickup(Handle:event, const String:name[], bool:dontBroadcast) 
{ 
    if (
GetConVarBool(g_Enable)) 
    { 
        
decl String:g_szWeapon[32]; 
        
GetEventString(event, "item", g_szWeapon, sizeof(g_szWeapon)); 
         
        if (
StrContains(scorostrelki, g_szWeapon, false) != -1) 
        { 
            new 
client = GetClientOfUserId(GetEventInt(event, "userid")); 
            
decl item;  
            for (new 
slot = 0; slot < 5; slot++) 
            {  
                if (
slot == 0 && (item = GetPlayerWeaponSlot(client, slot)) > 0 && RemovePlayerItem(client, item))  
                {  
                    
AcceptEntityInput(item, "Kill");  
                } 
            } 
            
FakeClientCommand(client, "use weapon_knife"); 
            
ClientCommand(client, "play buttons/weapon_cant_buy.wav"); 
            
PrintToChat(client, "\x0700FFFF%N\07FF0000, \07F8F8FFэто оружие запрещено\07FFFF00!", client); 
            for (new 
i = 1; i <= MaxClients; i++) 
            { 
                if(
IsClientInGame(i) && i != client) 
                { 
                    
decl String:tag[5]; 
                    new 
team = GetClientTeam(client); 
                    if(
team == 2) 
                    { 
                        
Format(tag, 5, "[T]"); 
                    } 
                    else if(
team == 3) 
                    { 
                        
Format(tag, 5, "[CT]"); 
                    } 
                    
PrintToChat(i, "\x0700FFFFИгрок \07FFFF00%s \07F8F8FF%N \x0700FFFFпытается поднять скорострелку.", tag, client); 
                } 
            } 
        } 
    } 
}
 
rootДата: Пятница, 12.04.2013, 23:31 | Сообщение # 11
Генералиссимус
Группа: Администраторы
Сообщений: 561
Статус: Offline
Измененные сообщения о подключении игроков и смене команды
PHP код:
#include <sourcemod> 
new String:teams[3][] = {"CCCCCCSpectators","FF4040Terrorist \x01force","99CCFFCounter-Terrorist \x01force"} 

public 
Plugin:myinfo =   
{ 
    
name = "[KDLP] Game Events",  
    
author = "KorDen",  
    
description = "",  
    
version = "1.0",  
    
url = "css32.ru"  
} 
public 
OnPluginStart()  
{ 
    
HookEvent("player_disconnect", event_PlayerConn, EventHookMode_Pre); 
    
HookEvent("player_connect", event_PlayerConn, EventHookMode_Pre); 
    
HookEvent("player_team", event_PlayerTeam, EventHookMode_Pre); 
} 
//GameEvents Begin 
public Action:event_PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast) 
{ 
    new 
client=GetClientOfUserId(GetEventInt(event, "userid")) 
    if (!
dontBroadcast && !GetEventBool(event,"disconnect") && !GetEventBool(event,"silent") && IsClientConnected(client)) 
    { 
        
SetEventBroadcast(event, true); 
        
PrintToChatAll("\x04%N \x01зашел за \x07%s",client,teams[GetEventInt(event,"team")-1]); 
    } 
} 
public 
Action:event_PlayerConn(Handle:event, const String:name[], bool:dontBroadcast) 
{ 
    if (!
dontBroadcast) 
        
SetEventBroadcast(event, true); 
    
decl String:rawmsg[255]; 
    
decl String:rawadmmsg[255]; 
    
decl String:steam[24]; 
    
decl String:nick[48]; 
    
decl String:ip[16]; 
    
decl String:reason[192]; 
    
GetEventString(event, "networkid", steam, sizeof(steam)); 
    
GetEventString(event, "name", nick, sizeof(nick)); 
    if (
strcmp(name,"player_connect"))  
    { 
        new 
client=GetClientOfUserId(GetEventInt(event,"userid")) 
        if(
client<1) return; 
        
GetEventString(event, "reason", reason, sizeof(reason)); 
        
GetClientIP(client, ip, sizeof(ip)); // В player_disconnect нет address 
        
ReplaceString(reason, sizeof(reason), "\n", " "); 
        
Format(rawadmmsg,sizeof(rawadmmsg),"\x01Игрок \x07FF0000%s \x01| \x07228B22%s \x01| \x03%s \x01 отключился - \x03%s", nick, steam, ip, reason); 
        
Format(rawmsg,sizeof(rawmsg),"\x01Игрок \x04%s \x01отключился\x07FFFF00 - %s", nick, reason); 
    } 
    else 
    {     
        
GetEventString(event, "address", ip, sizeof(ip)); 
        
SplitString(ip,":",ip,sizeof(ip)); 
        
Format(rawmsg,sizeof(rawmsg), "\x01Игрок \x04%s \x01вступает в игру", nick); 
        
Format(rawadmmsg,sizeof(rawadmmsg), "\x01Игрок \x070099FF%s \x01| \x07228B22%s \x01| \x03%s \x01подключается", nick, steam, ip); 
    } 
     
    for (new 
i = 1; i <= MaxClients; i++) 
        if(
IsClientConnected(i) && IsClientInGame(i)) 
            if (
GetUserFlagBits(i)) 
                
PrintToChat(i, "%s", rawadmmsg); 
            else 
                
PrintToChat(i, "%s", rawmsg); 
}
 
Форум » Форум » Уроки SourceMod (SourcePawn) Скриптинга » Мини скрипты/плагины
  • Страница 1 из 1
  • 1
Поиск: