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

[SM] Plugin load/unload


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
headhunterzcph
Member
Join Date: Nov 2012
Location: Danmark
Old 03-16-2018 , 12:59   [SM] Plugin load/unload
Reply With Quote #1

i need help to code plugin sourcemod
2 plugin unload and load again be 2 minutes


unload and load sounds.smx
unload and load hideme.smx

Hope someone who can help me
headhunterzcph is offline
Dr.Mohammad
Senior Member
Join Date: Jan 2016
Location: CSGO Servers
Old 03-16-2018 , 16:11   Re: [SM] Plugin load/unload
Reply With Quote #2

hi
I helped you as much as possible

this no test:
PHP Code:
#include <sourcemod> 

public Plugin:myinfo 

    
name "--"
    
author "Dr.Mohammad"
    
description "--"
    
version "1.0.0"
    
url "https://forums.alliedmods.net" 


public 
void OnPluginStart() 

    
RegAdminCmd("sm_load"UnloadPluginsADMFLAG_SLAY); 


public 
Action UnloadPlugins(int clientint arg

    
ServerCommand("sm plugins unload sounds.smx"); 
    
ServerCommand("sm plugins unload hideme.smx"); 
    
PrintToChat(client"Plugins Unload for 2 min!!"); 
    
CreateTimer(120.0loadPluginsclient); 
    return 
Plugin_Handled


public 
Action loadPlugins(Handle iTimerclient

    
ServerCommand("sm plugins load sounds.smx"); 
    
ServerCommand("sm plugins load hideme.smx"); 
    
PrintToChat(client"Plugins load !!"); 
    return 
Plugin_Stop


Last edited by Dr.Mohammad; 03-16-2018 at 16:37. Reason: thank you shanapu !! Update Cod
Dr.Mohammad is offline
shanapu
Veteran Member
Join Date: Apr 2015
Location: .de
Old 03-16-2018 , 16:23   Re: [SM] Plugin load/unload
Reply With Quote #3

some small mistakes on plugin header (misspelt author & missed a comma).
And you have to pass the clientid through the timer so you can use it in callback
Quote:
Originally Posted by Dr.Mohammad View Post
hi
I helped you as much as possible

this no test:
Quote:
author = "Dr.Mohammad",
description = "--",
version = "1.0.0",
url = "https://forums.alliedmods.net"
}
...

CreateTimer(120.0, loadPlugins, client);
return Plugin_Handled;
}
edit: DON'T USE MY CODE! Use version of neuro toxin in post #4

PHP Code:
#include <sourcemod>

public Plugin:myinfo =
{
    
name "--",
    
author "Dr.Mohammad",
    
description "--",
    
version "1.0.0",
    
url "https://forums.alliedmods.net"
}

public 
void OnPluginStart()
{
    
RegAdminCmd("sm_load"UnloadPluginsADMFLAG_SLAY);
}

public 
Action UnloadPlugins(int clientint arg)
{
    
ServerCommand("sm plugins unload sounds.smx");
    
ServerCommand("sm plugins unload hideme.smx");
    
PrintToChat(client"Plugins Unload for 2 min!!");
    
CreateTimer(120.0loadPluginsclient);
    return 
Plugin_Handled;
}

public 
Action loadPlugins(Handle iTimerint client)
{
    
ServerCommand("sm plugins load sounds.smx");
    
ServerCommand("sm plugins load hideme.smx");
    
PrintToChat(client"Plugins load !!");
    return 
Plugin_Stop;

__________________
coding & free software

Last edited by shanapu; 03-19-2018 at 15:26.
shanapu is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 03-19-2018 , 15:20   Re: [SM] Plugin load/unload
Reply With Quote #4

Dont parse client indicies through timers.

In this case the print msg would fail if the client index disconnected and the timer would continue to repeat as the stop return msg wouldn't execute.

Code:
#include <sourcemod>

public Plugin:myinfo =
{
    name = "--",
    author = "Dr.Mohammad",
    description = "--",
    version = "1.0.0",
    url = "https://forums.alliedmods.net"
}

public void OnPluginStart()
{
    RegAdminCmd("sm_load", UnloadPlugins, ADMFLAG_SLAY);
}

public Action UnloadPlugins(int client, int arg)
{
    ServerCommand("sm plugins unload sounds.smx");
    ServerCommand("sm plugins unload hideme.smx");
    PrintToChat(client, "Plugins Unload for 2 min!!");
    CreateTimer(120.0, loadPlugins, GetClientUserId(client));
    return Plugin_Handled;
}

public Action loadPlugins(Handle iTimer, int userid)
{
    ServerCommand("sm plugins load sounds.smx");
    ServerCommand("sm plugins load hideme.smx");
    int client = GetClientOfUserId(userid);
    if (client > 0)
        PrintToChat(client, "Plugins load !!");
    return Plugin_Stop;
}
__________________
Neuro Toxin is offline
shanapu
Veteran Member
Join Date: Apr 2015
Location: .de
Old 03-19-2018 , 15:27   Re: [SM] Plugin load/unload
Reply With Quote #5

Quote:
Originally Posted by Neuro Toxin View Post
Dont parse client indicies through timers.
You are absolutely right!
__________________
coding & free software
shanapu 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 19:15.


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