Raised This Month: $32 Target: $400
 8% 

Solved [CSGO]How i can write plugin which will turn of and on plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 02-01-2023 , 06:59   Re: [CSGO]How i can write plugin which will turn of and on plugin
Reply With Quote #11

I would do something like this:
PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <sdktools_engine>
#include <sdktools_entinput>
#include <sdktools_functions>

bool
    bShow
[MAXPLAYERS+1];
int
    iTesla 
= -1,
    
iFade = -1;

public 
void OnPluginStart()
{
    
RegAdminCmd("sm_thunder"Cmd_ThunderADMFLAG_SLAY);

    
HookEvent("player_death"Event_Death);
    
HookEvent("round_freeze_end"Event_StartEventHookMode_PostNoCopy);
}

public 
void OnMapStart()
{
    
iTesla iFade = -1;
    
PrecacheGeneric("sprites/physbeam.vmt");
}

public 
void OnClientDisconnect(int client)
{
    
bShow[client] = false;
}

public 
Action Cmd_Thunder(int clientint args)
{
    
bShow[client] ^= true;
    
PrintToChat(client"Thunder shot is %abled"bShow[client] ? "en" "dis");
    return 
Plugin_Handled;
}

public 
void Event_Start(Event event, const char[] namebool dontBroadcast)
{
    
int entity;
    if((
iTesla == -|| EntRefToEntIndex(iTesla) == -1) && (entity CreateEntityByName("point_tesla")) != -1)
    {
        
DispatchKeyValue(entity"beamcount_max""8");
        
DispatchKeyValue(entity"beamcount_min""6");
        
DispatchKeyValue(entity"interval_max""2");
        
DispatchKeyValue(entity"interval_min""0.5");
        
DispatchKeyValue(entity"lifetime_max""0.3");
        
DispatchKeyValue(entity"lifetime_min""0.3");
        
DispatchKeyValue(entity"m_Color""255 255 255");
        
DispatchKeyValue(entity"m_flRadius""200");
        
DispatchKeyValue(entity"m_SoundName""DoSpark");
        
DispatchKeyValue(entity"texture""sprites/physbeam.vmt");
        
DispatchKeyValue(entity"thick_max""5");
        
DispatchKeyValue(entity"thick_min""4");

        if(
DispatchSpawn(entity)) iTesla EntIndexToEntRef(entity);
    }

    if((
iFade == -|| EntRefToEntIndex(iFade) == -1) && (entity CreateEntityByName("env_fade")) != -1)
    {
        
DispatchKeyValue(entity"duration""0");
        
DispatchKeyValue(entity"renderamt""255");
        
DispatchKeyValue(entity"rendercolor""29 211 222");
        
DispatchKeyValue(entity"ReverseFadeDuration""0");
        
DispatchKeyValue(entity"spawnflags""0");

        if(
DispatchSpawn(entity)) iFade  EntIndexToEntRef(entity);
    }
}

public 
void Event_Death(Event event, const char[] namebool dontBroadcast)
{
    if(!
event.GetBool("headshot"))
        return;

    
int attacker GetClientOfUserId(event.GetInt("attacker"));
    if(!
attacker || !IsClientInGame(attacker) || !bShow[attacker])
        return;

    
int victim GetClientOfUserId(event.GetInt("userid"));
    if(!
victim || !IsClientInGame(victim))
        return;

    
AcceptEntityInput(iFade"Fade"attacker);

    static 
float pos[3];
    
GetClientEyePosition(victimpos);
    
TeleportEntity(iTeslaposNULL_VECTORNULL_VECTOR);
    
AcceptEntityInput(iTesla"DoSpark");

__________________
Grey83 is offline
Reply


Thread Tools
Display Modes

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 02:13.


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