Raised This Month: $ Target: $400
 0% 

[REG] Simple "quit" sender :)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Daeth111
Junior Member
Join Date: Apr 2008
Old 04-23-2008 , 16:35   [REG] Simple "quit" sender :)
Reply With Quote #1

Hey guys, I'am new here.
I installed some plugins ony my cs:source-server (Jetpack, noblock, effects).

I looked at the source codes, and so I wanted to make some easy plugin's for my server( a restart plugin^^)
I'am so interesstet in this, cause the source-codes looks like C <-iam learning @ school^^
Maybe someonecan make a finished plugin, but what I really want is, how to do it myself...
So long:
Quote:
It should start when I type "sm_restart" in the console.

PrintToChatAll("Server will restart in 5 seconds.");
PrintCenterTextAll("Server will restart in 5 seconds.");
EmitSoundToAll("hl1/fvox/five.wav");
PrintToChatAll("Server will restart in 4 seconds.");
PrintCenterTextAll("Server will restart in 4seconds.");
EmitSoundToAll("fvox/four.wav");
....

after "Server will restart in 1 seconds" it should send to the console "quit"
[OPEN] 1. So how do I send "quit" to the console?
[DONE] 2. what do i have to do, that the plugin is executed by typing "sm_restart" ?
[OPEN] 3. What do I have to mind by doing this plugin?(some tricks or smth. like that)

What I've done already:
- plugin start by typing sm_restart
- plugin displays the message "Server will restart in x seconds" and plays the sound to x.(x=4 so sound= 4 seconds^^)
- problem is. it dont waits 1 second before display the next step(x-1) and all sounds are played at the same time
- Dunno how to send the "quit" to the server

Hope someone can help me, I will post tomorrow my Code , right now iam on another pc.

Greetings

Daeth

Sog god morning, here's what i've done already
Quote:
/********************************************* ***********************************
*
* Simple Server restart tool with 5 second countdown
* Plugin licensed under the GPLv3
*
* Coded by Daeth111/Sounds from V0gelz Nukem!
*
********************************************* *****************************/

#pragma semicolon 1
#include <sourcemod>
#include <sdktools>

#define PLUGIN_VERSION "0.1"

#define FADE_IN 0x0001
#define FADE_OUT 0x0002

public Plugin:myinfo =
{
name = "Restart script",
author = "Daeth",
description = "Restart the server with 5 second countdown",
version = PLUGIN_VERSION,
url = "http://www.sourcemod.net/"
};

public OnPluginStart()
{

RegAdminCmd( "sm_restart", Command_restart, ADMFLAG_SLAY, "countdown to restart server" );
CreateConVar("sm_restart_version", PLUGIN_VERSION, "", FCVAR_PLUGIN | FCVAR_REPLICATED | FCVAR_NOTIFY);
}


public OnMapStart()
{
PrecacheSound( "hl1/fvox/five.wav", true);
PrecacheSound( "fvox/four.wav", true);
PrecacheSound( "fvox/three.wav", true);
PrecacheSound( "fvox/two.wav", true);
PrecacheSound( "fvox/one.wav", true);


AddFileToDownloadsTable("sound/fvox/four.wav");
AddFileToDownloadsTable("sound/fvox/three.wav");
AddFileToDownloadsTable("sound/fvox/two.wav");
AddFileToDownloadsTable("sound/fvox/one.wav");

}


public Action:Command_restart( client, args )
{

PrintToChatAll("Server will restart in 5 seconds.");
PrintCenterTextAll("Server will restart in 5 seconds.");
EmitSoundToAll("hl1/fvox/five.wav");

//Wait one second...
// sleep(1);
// -Don't work

PrintToChatAll("Server will restart in 4 seconds.");
PrintCenterTextAll("Server will restart in 4 seconds.");
EmitSoundToAll("fvox/four.wav");

//Wait one second...
// sleep(1);
// -Don't work

PrintToChatAll("Server will restart in 3 seconds.");
PrintCenterTextAll("Server will restart in 3 seconds.");
EmitSoundToAll("fvox/three.wav");

//Wait one second...
// sleep(1);
// -Don't work

PrintToChatAll("Server will restart in 2 seconds.");
PrintCenterTextAll("Server will restart in 2 seconds.");
EmitSoundToAll("fvox/two.wav");

//Wait one second...
// sleep(1);
// -Don't work

PrintToChatAll("Server will restart in 1 seconds.");
PrintCenterTextAll("Server will restart in 1 seconds.");
EmitSoundToAll("fvox/one.wav");

//Wait one second...
// sleep(1);
//Send "quit" to the server.
// quit -Don't work

return Plugin_Handled;
}




public EmitSoundFromOrigin(const String:sound[],const Floatrig[3])
{
EmitSoundToAll(sound,SOUND_FROM_WORLD,SNDCHAN _AUTO,SNDLEVEL_NORMAL,SND_NOFLAGS,SNDVOL_NORM AL,SNDPITCH_NORMAL,-1,orig,NULL_VECTOR,true,0.0);
}

Last edited by Daeth111; 04-24-2008 at 00:43.
Daeth111 is offline
Daeth111
Junior Member
Join Date: Apr 2008
Old 04-28-2008 , 12:03   Re: [REG] Simple "quit" sender :)
Reply With Quote #2

is this so difficult? - Let me know it..

Do you need some more informations?
Don't you know what my question is?

But please just answer something......
Daeth111 is offline
mkay_63
Junior Member
Join Date: Jan 2008
Old 04-29-2008 , 18:37   Re: [REG] Simple "quit" sender :)
Reply With Quote #3

Hi guy,

welcome to the forums - wish you nice time here...

First, before programming, read the documents ;)
At least this:
http://wiki.alliedmods.net/index.php...od_Development
http://docs.sourcemod.net/api/

To send a command to the server (like !quit), simply use:
ServerCommand(); // TODO: read documentation ;)

Quote:
Originally Posted by Daeth111 View Post
// Wait one second...
// sleep(1);
// -Don't work
As you already known - that doesn't work ^^
The reason for this is very simple...
Hint: It's the documentation thing ;)

*scnr
Here is the link to the wiki (hopefully it helps):
http://wiki.alliedmods.net/Timers_%2...d_Scripting%29

So, have a nice day ;)
mkay_63 is offline
Daeth111
Junior Member
Join Date: Apr 2008
Old 05-01-2008 , 07:23   Re: [REG] Simple "quit" sender :)
Reply With Quote #4

Hi, thx for your answer.

That with sleep(1)... I know that // are comments. I made it to an command cause when i compile it and start the plugin on the server, the server goes offline.

That with createtimer:

Code:
/********************************************************************************
 *
 *  Simple Server restart tool with 5 second countdown
 *   Plugin licensed under the GPLv3
 *   
 *   Coded by Daeth111
 *
 **************************************************************************/

#pragma semicolon 1
#include <sourcemod>
#include <sdktools>

#define PLUGIN_VERSION "0.2"

public Plugin:myinfo =
{
    name = "Restart script",
    author = "Daeth",
    description = "Restart the server with 5 second countdown",
    version = PLUGIN_VERSION,
    url = "http://www.sourcemod.net/"
};

public OnPluginStart()
{
    CreateTimer(1.0, onesecond_timer, _, TIMER_REPEAT);
    RegAdminCmd( "sm_restart",    Command_restart,    ADMFLAG_SLAY, "countdown to restart server" );
    CreateConVar("sm_restart_version", PLUGIN_VERSION, "", FCVAR_PLUGIN | FCVAR_REPLICATED | FCVAR_NOTIFY);
}


public OnMapStart()
{
    PrecacheSound( "hl1/fvox/five.wav", true);
    PrecacheSound( "fvox/four.wav", true);
    PrecacheSound( "fvox/three.wav", true);
    PrecacheSound( "fvox/two.wav", true);
    PrecacheSound( "fvox/one.wav", true);


    AddFileToDownloadsTable("sound/fvox/four.wav");
    AddFileToDownloadsTable("sound/fvox/three.wav");
    AddFileToDownloadsTable("sound/fvox/two.wav");
    AddFileToDownloadsTable("sound/fvox/one.wav");

}


public Action:Command_restart( client, args )
{

    PrintToChatAll("Server will restart in 5 seconds.");
    PrintCenterTextAll("Server will restart in 5 seconds.");
    EmitSoundToAll("hl1/fvox/five.wav");
 
CreateTimer(1.0, onesecond_timer, _, TIMER_REPEAT); // I dont know.. Does it work like this that it waits 1 second and go to the next step?
    PrintToChatAll("Server will restart in 4 seconds.");
    PrintCenterTextAll("Server will restart in 4 seconds.");
    EmitSoundToAll("fvox/four.wav");
CreateTimer(1.0, onesecond_timer, _, TIMER_REPEAT);

    PrintToChatAll("Server will restart in 3 seconds.");
    PrintCenterTextAll("Server will restart in 3 seconds.");
    EmitSoundToAll("fvox/three.wav");


CreateTimer(1.0, onesecond_timer, _, TIMER_REPEAT);
    PrintToChatAll("Server will restart in 2 seconds.");
    PrintCenterTextAll("Server will restart in 2 seconds.");
    EmitSoundToAll("fvox/two.wav");


CreateTimer(1.0, onesecond_timer, _, TIMER_REPEAT);
    PrintToChatAll("Server will restart in 1 seconds.");
    PrintCenterTextAll("Server will restart in 1 seconds.");
    EmitSoundToAll("fvox/one.wav");

CreateTimer(1.0, onesecond_timer, _, TIMER_REPEAT);

        ServerCommand("quit");

    return Plugin_Handled;

}


public Action:onesecond_timer(Handle:timer)
{
        new a=1;  // just that it do something..
            a--;      // just that it do something..
 
    return Plugin_Continue;
}

public EmitSoundFromOrigin(const String:sound[],const Float:orig[3])
{
    EmitSoundToAll(sound,SOUND_FROM_WORLD,SNDCHAN_AUTO,SNDLEVEL_NORMAL,SND_NOFLAGS,SNDVOL_NORMAL,SNDPITCH_NORMAL,-1,orig,NULL_VECTOR,true,0.0);
}
If i complie that there are some warnings..
Quote:
/home/groups/sourcemod/upload_tmp/text55JFqU.sp(60) : warning 217: loose indentation
/home/groups/sourcemod/upload_tmp/text55JFqU.sp(61) : warning 217: loose indentation
/home/groups/sourcemod/upload_tmp/text55JFqU.sp(64) : warning 217: loose indentation
/home/groups/sourcemod/upload_tmp/text55JFqU.sp(66) : warning 217: loose indentation
/home/groups/sourcemod/upload_tmp/text55JFqU.sp(71) : warning 217: loose indentation
/home/groups/sourcemod/upload_tmp/text55JFqU.sp(72) : warning 217: loose indentation
/home/groups/sourcemod/upload_tmp/text55JFqU.sp(77) : warning 217: loose indentation
/home/groups/sourcemod/upload_tmp/text55JFqU.sp(7 : warning 217: loose indentation
/home/groups/sourcemod/upload_tmp/text55JFqU.sp(82) : warning 217: loose indentation
/home/groups/sourcemod/upload_tmp/text55JFqU.sp(84) : warning 217: loose indentation
/home/groups/sourcemod/upload_tmp/text55JFqU.sp(99) : warning 217: loose indentation
But why? What does that mean?

Daeth
Daeth111 is offline
raydan
Senior Member
Join Date: Aug 2006
Old 05-01-2008 , 08:43   Re: [REG] Simple "quit" sender :)
Reply With Quote #5

haven't use SM to compile, hope work


Code:
/********************************************************************************
 *
 *  Simple Server restart tool with 5 second countdown
 *   Plugin licensed under the GPLv3
 *   
 *   Coded by Daeth111
 *
 **************************************************************************/
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#define PLUGIN_VERSION "0.2"
public Plugin:myinfo =
{
    name = "Restart script",
    author = "Daeth",
    description = "Restart the server with 5 second countdown",
    version = PLUGIN_VERSION,
    url = "http://www.sourcemod.net/"
};
public OnPluginStart()
{
    CreateTimer(1.0, onesecond_timer, _, TIMER_REPEAT);
    RegAdminCmd( "sm_restart",    Command_restart,    ADMFLAG_SLAY, "countdown to restart server" );
    CreateConVar("sm_restart_version", PLUGIN_VERSION, "", FCVAR_PLUGIN | FCVAR_REPLICATED | FCVAR_NOTIFY);
}
new String:Sound_file[5][32] = {"fvox/one","fvox/two","fvox/three","fvox/four","hl1/fvox/five"};
new g_countdown;
public OnMapStart()
{
    PrecacheSound( "hl1/fvox/five.wav", true);
    PrecacheSound( "fvox/four.wav", true);
    PrecacheSound( "fvox/three.wav", true);
    PrecacheSound( "fvox/two.wav", true);
    PrecacheSound( "fvox/one.wav", true);
 
    AddFileToDownloadsTable("sound/fvox/four.wav");
    AddFileToDownloadsTable("sound/fvox/three.wav");
    AddFileToDownloadsTable("sound/fvox/two.wav");
    AddFileToDownloadsTable("sound/fvox/one.wav");
}
 
public Action:Command_restart( client, args )
{
    PrintToChatAll("Server will restart in 5 seconds.");
    PrintCenterTextAll("Server will restart in 5 seconds.");
    EmitSoundToAll("hl1/fvox/five.wav");
    g_countdown = 5;
 
CreateTimer(1.0, onesecond_timer, _, TIMER_REPEAT);
    return Plugin_Handled;
}
 
public Action:onesecond_timer(Handle:timer)
{
    g_countdown--;
    if(g_countdown > 0)
    {
 decl String:format[65];
 PrintToChatAll("Server will restart in %d seconds.",g_countdown);
     PrintCenterTextAll("Server will restart in %d seconds.",g_countdown);
 Format(format,sizeof(format),"%s.wav",Sound_file[g_countdown]-1); // example: now is 4 seconds, it play Sound_file[3],"fvox/four"
     EmitSoundToAll(format);
 return Plugin_Continue;
    }
ServerCommand("quit");
    return Plugin_Handled;
}
public EmitSoundFromOrigin(const String:sound[],const Float:orig[3])
{
    EmitSoundToAll(sound,SOUND_FROM_WORLD,SNDCHAN_AUTO,SNDLEVEL_NORMAL,SND_NOFLAGS,SNDVOL_NORMAL,SNDPITCH_NORMAL,-1,orig,NULL_VECTOR,true,0.0);
}

Last edited by raydan; 05-01-2008 at 08:58.
raydan is offline
Daeth111
Junior Member
Join Date: Apr 2008
Old 05-01-2008 , 11:59   Re: [REG] Simple "quit" sender :)
Reply With Quote #6

Thank you. But i get an error if i try to compile:
(62) : error 033: array must be indexed (variable "Sound_file")

Daeth ^_^
Daeth111 is offline
mkay_63
Junior Member
Join Date: Jan 2008
Old 05-03-2008 , 16:04   Re: [REG] Simple "quit" sender :)
Reply With Quote #7

Code:
Format(format,sizeof(format),"%s.wav",Sound_file[g_countdown]-1);
Apparently it is a typing mistake...
Try the following: Sound_file[g_countdown - 1].

About the warnings (
"loose indentation") - you can ignore them.
It means there is something wrong with the "indentation"/"tabs".

More about indent style:
http://en.wikipedia.org/wiki/Indent_style

I hope I could help ;)
mkay_63 is offline
Daeth111
Junior Member
Join Date: Apr 2008
Old 05-04-2008 , 11:50   Re: [REG] Simple "quit" sender :)
Reply With Quote #8

oh yeah for sure thank you

Daeth

€dit:
One problem.. The Server restarts now after every mapchange..

Last edited by Daeth111; 05-05-2008 at 11:07.
Daeth111 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 03:50.


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