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

Solved [L4D2]Plugin command looping


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
King_OXO
Senior Member
Join Date: Dec 2020
Location: Brazil
Old 06-15-2021 , 20:22   [L4D2]Plugin command looping
Reply With Quote #1

hi guys, i need help with this scripting, when i say the command !rainbow, the plugin starts giving me random colors but i want it to stay infinitely until my character dies, if anyone can help me i'm very grateful
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <sdktools_functions>

public Plugin myinfo =
{
    
name "[L4D2]Random color",
    
author "King",
    
description "",
    
version "2.0.0",
    
url "www.sourcemod.net"
};

public 
OnPluginStart()
{
    
RegConsoleCmd("sm_rainbow"Rainbow"rainbow for survivors");
}

public 
Action Rainbow(clientargs)
{
    
CreateTimer(0.5Random1client);
    
CreateTimer(1.0Random2client);
    
CreateTimer(1.5Random3client);
    
CreateTimer(2.0Random4client);
    
CreateTimer(2.5Random5client);
    
CreateTimer(3.0Random6client);
    
CreateTimer(3.5Random7client);
    
CreateTimer(4.0Random8client);
    
CreateTimer(4.5Random9client);
    
CreateTimer(5.0Random10client);
    return 
Plugin_Handled;
}

public 
Action Random1(Handle Timerclient)
{
    
SetEntityRenderColor(client02550255);
    
SetEntProp(clientProp_Send"m_glowColorOverride"+ (255 256) + (65536));
    
SetEntProp(clientProp_Send"m_iGlowType"3);
    
SetEntProp(clientProp_Send"m_nGlowRange"99999);
    
SetEntProp(clientProp_Send"m_nGlowRangeMin"0);
    
}

public 
Action Random2(Handle Timerclient)
{
    
SetEntityRenderColor(client719250255);
    
SetEntProp(clientProp_Send"m_glowColorOverride"+ (19 256) + (250 65536));
    
SetEntProp(clientProp_Send"m_iGlowType"3);
    
SetEntProp(clientProp_Send"m_nGlowRange"99999);
    
SetEntProp(clientProp_Send"m_nGlowRangeMin"0);
    
}

public 
Action Random3(Handle Timerclient)
{
    
SetEntityRenderColor(client24919250255);
    
SetEntProp(clientProp_Send"m_glowColorOverride"249 + (19 256) + (250 65536));
    
SetEntProp(clientProp_Send"m_iGlowType"3);
    
SetEntProp(clientProp_Send"m_nGlowRange"99999);    
    
}

public 
Action Random4(Handle Timerclient)
{
    
SetEntityRenderColor(client66250250255);
    
SetEntProp(clientProp_Send"m_glowColorOverride"66 + (250 256) + (250 65536));
    
SetEntProp(clientProp_Send"m_iGlowType"3);
    
SetEntProp(clientProp_Send"m_nGlowRange"99999);
    
SetEntProp(clientProp_Send"m_nGlowRangeMin"0);
    
}

public 
Action Random5(Handle Timerclient)
{
    
SetEntityRenderColor(client25500255);
    
SetEntProp(clientProp_Send"m_glowColorOverride"255 + (256) + (65536));
    
SetEntProp(clientProp_Send"m_iGlowType"3);
    
SetEntProp(clientProp_Send"m_nGlowRange"99999);
    
SetEntProp(clientProp_Send"m_nGlowRangeMin"0);
    
}

public 
Action Random6(Handle Timerclient)
{
    
SetEntityRenderColor(client505050255);
    
SetEntProp(clientProp_Send"m_glowColorOverride"75 + (75 256) + (75 65536));
    
SetEntProp(clientProp_Send"m_iGlowType"3);
    
SetEntProp(clientProp_Send"m_nGlowRange"99999);
    
SetEntProp(clientProp_Send"m_nGlowRangeMin"0);
    
}

public 
Action Random7(Handle Timerclient)
{
    
SetEntityRenderColor(client2552550255);
    
SetEntProp(clientProp_Send"m_glowColorOverride"255 + (255 256) + (65536));
    
SetEntProp(clientProp_Send"m_iGlowType"3);
    
SetEntProp(clientProp_Send"m_nGlowRange"99999);
    
SetEntProp(clientProp_Send"m_nGlowRangeMin"0);
    
}

public 
Action Random8(Handle Timerclient)
{
    
SetEntityRenderColor(client1282550255);
    
SetEntProp(clientProp_Send"m_glowColorOverride"128 + (255 256) + (65536));
    
SetEntProp(clientProp_Send"m_iGlowType"3);
    
SetEntProp(clientProp_Send"m_nGlowRange"99999);
    
SetEntProp(clientProp_Send"m_nGlowRangeMin"0);
    
}

public 
Action Random9(Handle Timerclient)
{
    
SetEntityRenderColor(client12800255);
    
SetEntProp(clientProp_Send"m_glowColorOverride"128 + (256) + (65536));
    
SetEntProp(clientProp_Send"m_iGlowType"3);
    
SetEntProp(clientProp_Send"m_nGlowRange"99999);
    
SetEntProp(clientProp_Send"m_nGlowRangeMin"0);
    
}

public 
Action Random10(Handle Timerclient)
{
    
SetEntityRenderColor(client0128128255);
    
SetEntProp(clientProp_Send"m_glowColorOverride"+ (128 256) + (128 65536));
    
SetEntProp(clientProp_Send"m_iGlowType"3);
    
SetEntProp(clientProp_Send"m_nGlowRange"99999);
    
SetEntProp(clientProp_Send"m_nGlowRangeMin"0);

Attached Files
File Type: sp Get Plugin or Get Source (l4d2_rainbow_glow.sp - 79 views - 4.4 KB)

Last edited by King_OXO; 06-16-2021 at 06:39.
King_OXO is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 06-15-2021 , 22:58   Re: [L4D2]Plugin command looping
Reply With Quote #2

Use SDKHook_PreThinkPost to change colors. You don't need to call all those timers. Command looping is also insufficient and insane for what you're trying to accomplish.
PHP Code:
public void OnPlayerPreThinkPost(int client)
{
    if (!(
client <= MaxClients && IsClientInGame(client) && IsPlayerAlive(client)))
    {
        
SDKUnhook(clientSDKHook_PreThinkOnPlayerPreThinkPost);

        return;
    }

    
int color[3];
    
color[0] = RoundToNearest(Cosine((GetGameTime() * 1.0) + client 0) * 127.5 127.5);
    
color[1] = RoundToNearest(Cosine((GetGameTime() * 1.0) + client 2) * 127.5 127.5);
    
color[2] = RoundToNearest(Cosine((GetGameTime() * 1.0) + client 4) * 127.5 127.5);
    
SetEntProp(clientProp_Send"m_glowColorOverride"color[0] + (color[1] * 256) + (color[2] * 65536));
    
SetEntProp(clientProp_Send"m_iGlowType"3);
    
SetEntProp(clientProp_Send"m_nGlowRange"99999);
    
SetEntProp(clientProp_Send"m_nGlowRangeMin"0);

__________________
Psyk0tik is offline
King_OXO
Senior Member
Join Date: Dec 2020
Location: Brazil
Old 06-16-2021 , 06:39   Re: [L4D2]Plugin command looping
Reply With Quote #3

Thank you, crasher
King_OXO 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 09:09.


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