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

Help with plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dzinks2009
Junior Member
Join Date: Dec 2015
Old 06-04-2017 , 09:29   Help with plugin
Reply With Quote #1

Hello, I'm trying to make that after 15seconds, the players will be killed.

This is what I have so far:
PHP Code:

public OnPluginStart()
{
    
HookEvent("round_start"Event_RoundStart);
    
HookEvent("round_end"Event_RoundEnd);
}
public 
Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    
Kill false;
    
timerr CreateTimer(15Killing);
}

public 
Action:Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)

    
Kill false;
    
KillTimer(timerr);

}

public 
Action:Killing(Handle:timer){
    
Kill true;

What I'm trying to do is that after 15seconds, it will put Kill from false to true.

Last edited by dzinks2009; 06-04-2017 at 09:31.
dzinks2009 is offline
hamilton5
Veteran Member
Join Date: Oct 2012
Location: USA
Old 06-05-2017 , 20:27   Re: Help with plugin
Reply With Quote #2

wrong section, this should be in the scripting section... maybe a mod will move it for you....

timers are float values, you might want to read the timers wiki guide sourcemod has
hamilton5 is offline
sdz
Senior Member
Join Date: Feb 2012
Old 06-06-2017 , 07:25   Re: Help with plugin
Reply With Quote #3

PHP Code:
for(new 1<= MaxClientsi++)
{
     if(
IsClientInGame(i) && IsPlayerAlive(i)) ForcePlayerSuicide(i);


Last edited by sdz; 06-06-2017 at 07:25.
sdz is offline
Walgrim
AlliedModders Donor
Join Date: Dec 2015
Location: France
Old 06-06-2017 , 07:38   Re: Help with plugin
Reply With Quote #4

Quote:
Originally Posted by EasSidezz View Post
PHP Code:
for(new 1<= MaxClientsi++)
{
     if(
IsClientInGame(i) && IsPlayerAlive(i)) ForcePlayerSuicide(i);

He didn't ask for that I think ? (Not really sure )

Quote:
Originally Posted by dzinks2009 View Post
What I'm trying to do is that after 15seconds, it will put Kill from false to true.
But by the way, why don't you use something like a spawnprotection?
__________________
Walgrim is offline
dzinks2009
Junior Member
Join Date: Dec 2015
Old 06-06-2017 , 07:45   Re: Help with plugin
Reply With Quote #5

Quote:
Originally Posted by Walgrim View Post
He didn't ask for that I think ? (Not really sure )



But by the way, why don't you use something like a spawnprotection?
Ye, I already have the client part. I just need help with the timer part because I been having a little problem with that lately. I don't use a spawnprotection since I want to make my own.
dzinks2009 is offline
Walgrim
AlliedModders Donor
Join Date: Dec 2015
Location: France
Old 06-06-2017 , 09:09   Re: Help with plugin
Reply With Quote #6

Just look at the sp of some spawnprotections, you can make your own spawnprotect by taking example on the others.
__________________
Walgrim is offline
brunoronning
Senior Member
Join Date: Jan 2014
Location: Brazil
Old 06-06-2017 , 15:29   Re: Help with plugin
Reply With Quote #7

Try:
PHP Code:
#include <sourcemod>

Handle g_hTimerKilling null;
bool g_bKill false;

public 
void OnPluginStart()
{
    
HookEvent("round_start"Event_RoundStart);
    
HookEvent("round_end"Event_RoundEndEventHookMode_Pre);
}

public 
void Event_RoundStart(Event event, const char[] namebool dontBroadcast)
{
    
g_bKill false;
    
g_hTimerKilling CreateTimer(15.0Timer_Killing);
}

public 
void Event_RoundEnd(Event event, const char[] namebool dontBroadcast)

    
g_bKill false;
    
    if (
g_hTimerKilling != null)
        
delete g_hTimerKilling;
}

public 
Action Timer_Killing(Handle timer)
{
    
g_bKill true;
    
    
// code kill players.
    
    
g_hTimerKilling null;
    return 
Plugin_Handled;


Last edited by brunoronning; 06-06-2017 at 15:31.
brunoronning is offline
dzinks2009
Junior Member
Join Date: Dec 2015
Old 06-06-2017 , 20:07   Re: Help with plugin
Reply With Quote #8

Quote:
Originally Posted by brunoronning View Post
Try:
PHP Code:
#include <sourcemod>

Handle g_hTimerKilling null;
bool g_bKill false;

public 
void OnPluginStart()
{
    
HookEvent("round_start"Event_RoundStart);
    
HookEvent("round_end"Event_RoundEndEventHookMode_Pre);
}

public 
void Event_RoundStart(Event event, const char[] namebool dontBroadcast)
{
    
g_bKill false;
    
g_hTimerKilling CreateTimer(15.0Timer_Killing);
}

public 
void Event_RoundEnd(Event event, const char[] namebool dontBroadcast)

    
g_bKill false;
    
    if (
g_hTimerKilling != null)
        
delete g_hTimerKilling;
}

public 
Action Timer_Killing(Handle timer)
{
    
g_bKill true;
    
    
// code kill players.
    
    
g_hTimerKilling null;
    return 
Plugin_Handled;

Thanks for help, but its kind of not what I wanted.
I want to put a variable "kill" to true when it passes 15seconds so then when a player choses a team and spawns, he will be slayed because the variable "kill" is true. On beginning of round its supposed to be false.

Last edited by dzinks2009; 06-06-2017 at 20:16.
dzinks2009 is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 06-06-2017 , 20:26   Re: Help with plugin
Reply With Quote #9

Quote:
Originally Posted by dzinks2009 View Post
Thanks for help, but its kind of not what I wanted.
I want to put a variable "kill" to true when it passes 15seconds so then when a player choses a team and spawns, he will be slayed because the variable "kill" is true. On beginning of round its supposed to be false.
what he posted is exactly what you wanted
8guawong is offline
dzinks2009
Junior Member
Join Date: Dec 2015
Old 06-06-2017 , 20:34   Re: Help with plugin
Reply With Quote #10

Quote:
Originally Posted by 8guawong View Post
what he posted is exactly what you wanted
how am i supposed to know if a player spawned tho?

This is my code right now:

PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
new bool:Kill false;

public 
OnPluginStart()
{
    
CreateConVar("sm_cannounce_version"VERSION"Anti-Reconnecting"FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
    
HookEvent("round_start"Event_RoundStart);
    
HookEvent("round_end"Event_RoundEnd);
    
HookEvent("player_spawn"Event_PlayerSpawn);
}

public 
Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
Float:Time float(30);
    new 
client     GetClientOfUserId(GetEventInt(event"userid"));
    
Kill false;
    
TimerRawr CreateTimer(TimeKillingclient);
}

public 
Action:Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)

    
Kill false;
}

public 
Action:Killing(Handle:timerany:client)
{
    
Kill true;
}

public 
Action:Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if (!
client)
    {
        return;    
    }
        
    if(
IsClientInGame(client) && IsPlayerAlive(client)){
        if(
Kill){
            
ForcePlayerSuicide(client);
            
PrintToChat(client"[Late Spawn] You have been slayed for spawning late!");
        }
    }

But whenever user joins, he gets slayed right away without even getting a chance to spawn and makes it glitchy because you can't choose a team after that.

Last edited by dzinks2009; 06-06-2017 at 22:04.
dzinks2009 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 08:37.


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