Example plugin

RedDevil6193

New Member
Member
Oct 11, 2014
20
2
3
38
Is there a way to add a timer on example plugin which has starter kits, so you cant spam starter kit?
If there was an answer already i didnt read it and i m sorry.
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
This is something I made a few days ago.

Python:
__author__ = 'DreTaX'
__version__ = '1.0'

import clr

clr.AddReferenceByPartialName("Pluton")
import Pluton
import math
import System

"""
    Class
"""


class Kits:
    def On_Command(self, cmd):
            Player = cmd.User
            args = cmd.args
            if cmd.cmd == "kit":
                if Player.Admin:
                    if len(args) == 0:
                        Player.Message("starter, builder, admin")
                        return
                    if Server.LoadOuts.ContainsKey(args[0]):
                        loadout = Server.LoadOuts[args[0]]
                        loadout.ToInv(Player.Inventory)
                        return
                    else:
                        Player.Message("Kit " + str(cmd.args[0]) + " not found!")
                        return
                else:
                    if len(args) == 0:
                        Player.Message("Available kits: starter")
                        return
                    # 20 * 60 * 1000 = 1200000 (20 mins)
                    cooldown = 1200000
                    if cooldown > 0:
                        systick = System.Environment.TickCount
                        time = DataStore.Get("startercooldown", Player.SteamID)
                        if time is None or (systick - time) < 0 or math.isnan(systick - time):
                            DataStore.Add("startercooldown", Player.SteamID, 7)
                        calc = systick - time
                        if calc >= cooldown or time == 7:
                            loadout = Server.LoadOuts["starter"]
                            loadout.ToInv(Player.Inventory)
                            DataStore.Add("startercooldown", Player.SteamID, System.Environment.TickCount)
                        else:
                            Player.Message("You have to wait before using this again!")
                            done = round((calc / 1000) / 60, 2)
                            done2 = round((cooldown / 1000) / 60, 2)
                            Player.Message("Time Remaining: " + str(done) + "/" + str(done2) + " minutes")
                    else:
                        loadout = Server.LoadOuts["starter"]
                        loadout.ToInv(Player.Inventory)
 

RedDevil6193

New Member
Member
Oct 11, 2014
20
2
3
38
I tried to reload the example and it did this


Code:
[10/17/2014 11:50:39 PM] [Debug] [PluginLoader] Loading plugin Example.
[10/17/2014 11:50:39 PM] [Exception] [ PluginLoader->LoadPlugin | PluginLoader->ReloadPlugin | pluton->reload | MonoMethod->InternalInvoke | MonoMethod->Invoke | MethodBase->Invoke | <>c__DisplayClass2a-><BuildFunctions>b__25 | ConsoleSystem->RunCommandInternal | ConsoleSystem->OnClientCommand | Node->Call | Router->Route | Server->ReceivedMessage | Server->Cycle | ServerMgr->Update | ]
System.MissingMemberException: 'ScopeStorage' object has no attribute 'Example'
at (wrapper dynamic-method) object.CallSite.Target (System.Runtime.CompilerServices.Closure,System.Runtime.CompilerServices.CallSite,object) <0x001b4>
at System.Dynamic.UpdateDelegates.UpdateAndExecute1<object, object> (System.Runtime.CompilerServices.CallSite,object) <0x00580>
at Microsoft.Scripting.Runtime.DynamicOperations.GetMember (object,string,bool) <0x00075>
at Microsoft.Scripting.Runtime.DynamicOperations.GetMember (object,string) <0x0002f>
at Microsoft.Scripting.Runtime.LanguageContext.ScopeGetVariable (Microsoft.Scripting.Runtime.Scope,string) <0x00047>
at IronPython.Runtime.PythonContext.ScopeGetVariable (Microsoft.Scripting.Runtime.Scope,string) <0x00117>
at Microsoft.Scripting.Hosting.ScriptScope.GetVariable (string) <0x00068>
at (wrapper remoting-invoke-with-check) Microsoft.Scripting.Hosting.ScriptScope.GetVariable (string) <0x00084>
at Pluton.Plugin..ctor (string,string,System.IO.DirectoryInfo,Pluton.Plugin/PluginType) <0x002e6>
at Pluton.PluginLoader.LoadPlugin (string,Pluton.Plugin/PluginType) <0x00182>





Did i do something wrong?


Also now i cant reload Example without restarting server it says couldnt find Example.
 
Last edited:

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
I tried to reload the example and it did this


Code:
[10/17/2014 11:50:39 PM] [Debug] [PluginLoader] Loading plugin Example.
[10/17/2014 11:50:39 PM] [Exception] [ PluginLoader->LoadPlugin | PluginLoader->ReloadPlugin | pluton->reload | MonoMethod->InternalInvoke | MonoMethod->Invoke | MethodBase->Invoke | <>c__DisplayClass2a-><BuildFunctions>b__25 | ConsoleSystem->RunCommandInternal | ConsoleSystem->OnClientCommand | Node->Call | Router->Route | Server->ReceivedMessage | Server->Cycle | ServerMgr->Update | ]
System.MissingMemberException: 'ScopeStorage' object has no attribute 'Example'
at (wrapper dynamic-method) object.CallSite.Target (System.Runtime.CompilerServices.Closure,System.Runtime.CompilerServices.CallSite,object) <0x001b4>
at System.Dynamic.UpdateDelegates.UpdateAndExecute1<object, object> (System.Runtime.CompilerServices.CallSite,object) <0x00580>
at Microsoft.Scripting.Runtime.DynamicOperations.GetMember (object,string,bool) <0x00075>
at Microsoft.Scripting.Runtime.DynamicOperations.GetMember (object,string) <0x0002f>
at Microsoft.Scripting.Runtime.LanguageContext.ScopeGetVariable (Microsoft.Scripting.Runtime.Scope,string) <0x00047>
at IronPython.Runtime.PythonContext.ScopeGetVariable (Microsoft.Scripting.Runtime.Scope,string) <0x00117>
at Microsoft.Scripting.Hosting.ScriptScope.GetVariable (string) <0x00068>
at (wrapper remoting-invoke-with-check) Microsoft.Scripting.Hosting.ScriptScope.GetVariable (string) <0x00084>
at Pluton.Plugin..ctor (string,string,System.IO.DirectoryInfo,Pluton.Plugin/PluginType) <0x002e6>
at Pluton.PluginLoader.LoadPlugin (string,Pluton.Plugin/PluginType) <0x00182>





Did i do something wrong?


Also now i cant reload Example without restarting server it says couldnt find Example.
You cannot name It example, until the class's name is 'Kits'

Sent from my Samsung Galaxy S4