AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved Timer for HookEvent (https://forums.alliedmods.net/showthread.php?t=324657)

Gurrth 05-22-2020 20:08

Timer for HookEvent
 
Hello all, need help regarding creating a Timer for a HookEvent.

I would like to make it so that at the end of a mvm mission victory, the server waits 15 seconds
to then use the command sm_resetpopfile.

Can't figure out the timer part, but resetpopfile does reset the round and not make it change maps after a victory.

Any help would be greatly appreciated.


Code:

#include <sourcemod>
#include <sdktools>
#include <tf2>
#include <tf2_objects>
#include <sdkhooks>


public Plugin:myinfo =
{
        name = "[TF2]Reset Popfile",
        author = "Gurrth",
        description = "Resets current Popfile after a MVM Mission Completes, no map change",
        version = "1.0",
        url = ""
}

public OnPluginStart()
{
       
        HookEvent("mvm_mission_complete", Event_MissionComplete);
       
       
        PrintToServer("[SM] Rest Pop Files is Loaded!")
       
       
        RegConsoleCmd("sm_resetpopfile", command_resetpopfile, "resets popfile");
       
       
       
}


// What sm_resetpopfile does
public Action:command_resetpopfile(client, args)
{
       
        // Test Text
        PrintToServer("This is a Test");
       
       
        char responseBuffer[4096];
        int ObjectiveEntity = FindEntityByClassname(-1, "tf_objective_resource");
       
       
        // Get Popfile Name
        GetEntPropString(ObjectiveEntity, Prop_Send, "m_iszMvMPopfileName", responseBuffer, sizeof(responseBuffer));
       
        // Tell server to change popfile
        ServerCommand("tf_mvm_popfile %s", ObjectiveEntity);
       
}

public Action:Event_MissionComplete(Handle:event, const String:mission[], bool:dontBroadcast)
{
        // Tell server to use command
        ServerCommand("sm_resetpopfile");
               
}


Tilex 05-24-2020 08:11

Re: Timer for HookEvent
 
pretty basic one-shot timer:
(see: https://wiki.alliedmods.net/Timers_(...Mod_Scripting) )
PHP Code:


public Action:Event_MissionComplete(Handle:event, const String:mission[], bool:dontBroadcast)
{
    
//execute fireReset after 15 seconds
    
CreateTimer(15.0fireReset);
}
 
public 
Action:fireReset(Handle timer)
{
    
// Tell server to use command
    
ServerCommand("sm_resetpopfile");




All times are GMT -4. The time now is 15:14.

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