Raised This Month: $12 Target: $400
 3% 

First plugin simple need help :)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kumlaserver
Junior Member
Join Date: Jul 2011
Old 05-08-2012 , 10:25   First plugin simple need help :)
Reply With Quote #1

Hey im REALLY new to scripting in sourcepawn this is actually my first script that i try to do.

So i want the plugin to slay all players after xx minutes.

this is what i have so far..
i am stuck at how i can slay all players.

Code:
#include <sourcemod>
#include <sdktools>
 
public Plugin:myinfo =
{
	name = "Slay All",
	author = "Hannes",
	description = "Kills all players after xx minutes",
	version = "1.0.0.0",
	url = "http://www.kumlaonline.se/"
};

public OnPluginStart()
{
	CreateTimer(5.0, kill)
}
 
public Action:kill(Handle:timer)
{

}

Last edited by Kumlaserver; 05-08-2012 at 10:26.
Kumlaserver is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 05-08-2012 , 10:48   Re: First plugin simple need help :)
Reply With Quote #2

http://docs.sourcemod.net/api/index....oad=show&id=41

Code:
for( new iClient = 1; iClient <= MaxClients; iClient++ )
    if( IsClientInGame( iClient ) )
    {
        // do it
    }
__________________
Leonardo is offline
Kumlaserver
Junior Member
Join Date: Jul 2011
Old 05-08-2012 , 10:51   Re: First plugin simple need help :)
Reply With Quote #3

Quote:
Originally Posted by Leonardo View Post
http://docs.sourcemod.net/api/index....oad=show&id=41

Code:
for( new iClient = 1; iClient <= MaxClients; iClient++ )
    if( IsClientInGame( iClient ) )
    {
        // do it
    }
Like this then? (sorry im really new to this)
Code:
#include <sourcemod>
#include <sdktools>
 
public Plugin:myinfo =
{
	name = "Slay All",
	author = "Hannes",
	description = "Kills all players after xx minutes",
	version = "1.0.0.0",
	url = "http://www.kumlaonline.se/"
};

public OnPluginStart()
{
	CreateTimer(5.0, kill)
}
 
public Action:kill(Handle:timer)
{
for( new iClient = 1; iClient <= MaxClients; iClient++ )
    if( IsClientInGame( iClient ) )
    {
        // do it
    }
}

Last edited by Kumlaserver; 05-08-2012 at 10:51.
Kumlaserver is offline
Grognak
SourceMod Donor
Join Date: Jan 2012
Old 05-08-2012 , 11:00   Re: First plugin simple need help :)
Reply With Quote #4

PHP Code:
public Action:kill(Handle:timer)
{
    for( new 
iClient 1iClient <= MaxClientsiClient++ )
        if( 
IsClientInGameiClient ) )
        {
            
ForcePlayerSuicideiClient );
        }

Be sure to read up on proper indentation... it'll save you a lot of headaches in the future. As well, "// do it" is just a comment, if you wanted to force the player's suicide you have to use the function that he linked to.

Last edited by Grognak; 05-08-2012 at 11:00.
Grognak is offline
Kumlaserver
Junior Member
Join Date: Jul 2011
Old 05-08-2012 , 11:10   Re: First plugin simple need help :)
Reply With Quote #5

Quote:
Originally Posted by Grognak View Post
PHP Code:
public Action:kill(Handle:timer)
{
    for( new 
iClient 1iClient <= MaxClientsiClient++ )
        if( 
IsClientInGameiClient ) )
        {
            
ForcePlayerSuicideiClient );
        }

Be sure to read up on proper indentation... it'll save you a lot of headaches in the future. As well, "// do it" is just a comment, if you wanted to force the player's suicide you have to use the function that he linked to.

Okey, i have another issue now where i want it to make the suicide at each round now it only make them suicide on plugin start.

i tried doin OnRoundStart instead of OnPluginStart but that didnt work.. :/
Code:
#include <sourcemod>
#include <sdktools>
 
public Plugin:myinfo =
{
	name = "Slay All",
	author = "Hannes",
	description = "Kills all players after xx minutes",
	version = "1.0.0.0",
	url = "http://www.kumlaonline.se/"
};

public OnPluginStart()
{
	CreateTimer(5.0, kill)
}
 
public Action:kill(Handle:timer)
{
    for( new iClient = 1; iClient <= MaxClients; iClient++ )
        if( IsClientInGame( iClient ) )
        {
            ForcePlayerSuicide(iClient);
        }
}
Kumlaserver is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 05-08-2012 , 11:12   Re: First plugin simple need help :)
Reply With Quote #6

http://wiki.alliedmods.net/Events_(SourceMod_Scripting)
__________________
Leonardo is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 05-08-2012 , 11:17   Re: First plugin simple need help :)
Reply With Quote #7

Quote:
Originally Posted by Leonardo View Post
However, to make it cross compatible with all games, it needs to be done on both round_start and teamplay_round_start... I recommend using HookEventEx on the latter because teamplay_round_start doesn't exist in all games.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Kumlaserver
Junior Member
Join Date: Jul 2011
Old 05-08-2012 , 11:27   Re: First plugin simple need help :)
Reply With Quote #8

Quote:
Originally Posted by Leonardo View Post
Like this? : /

Code:
#include <sourcemod>
#include <sdktools>
 
public Plugin:myinfo =
{
	name = "Slay All",
	author = "Hannes",
	description = "Kills all players after xx minutes",
	version = "1.0.0.0",
	url = "http://www.kumlaonline.se/"
};

public OnPluginStart() 
{ 
HookEvent("round_start", Event_RoundStart); 
} 

public Action:Event_RoundStart(Handle:event, const String name[], bool:dontBroadcast) 
{
	CreateTimer(5.0, kill)
}
 
public Action:kill(Handle:timer)
{
    for( new iClient = 1; iClient <= MaxClients; iClient++ )
        if( IsClientInGame( iClient ) )
        {
            ForcePlayerSuicide(iClient);
        }
}
Kumlaserver is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 05-08-2012 , 12:18   Re: First plugin simple need help :)
Reply With Quote #9

You would have to kill the timer at round end, or otherwise the timer would go into the next round.

And please use { } brackets for every block, not using them is a bad habbit and makes the code unreadable and becomes a problem when you want to extend the block with more lines later.

Code:
public Action:kill(Handle:timer)
{
    for( new iClient = 1; iClient <= MaxClients; iClient++ ) {
        if( IsClientInGame( iClient ) )
        {
            ForcePlayerSuicide(iClient);
        }
    }
}
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0

Last edited by berni; 05-08-2012 at 12:20.
berni is offline
Kumlaserver
Junior Member
Join Date: Jul 2011
Old 05-08-2012 , 12:53   Re: First plugin simple need help :)
Reply With Quote #10

Quote:
Originally Posted by berni View Post
You would have to kill the timer at round end, or otherwise the timer would go into the next round.

And please use { } brackets for every block, not using them is a bad habbit and makes the code unreadable and becomes a problem when you want to extend the block with more lines later.

Code:
public Action:kill(Handle:timer)
{
    for( new iClient = 1; iClient <= MaxClients; iClient++ ) {
        if( IsClientInGame( iClient ) )
        {
            ForcePlayerSuicide(iClient);
        }
    }
}
Okey but when i try to add 'return Plugin_Stop' and 'return Plugin_Continue'
it wont let me compile it..
Kumlaserver 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 13:18.


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