Es.sexec

From EventScripts Community Encyclopedia
This article is a stub. Please help by adding to it.



Method: sexec

Module: es
Class: (no class)
EventScripts version: 2.0

Method Overview

Table of Contents

Contents


Syntax

{{{syntax}}}

Arguments

  • userid (String) - The users id of whom we are going to abuse! :)
  • command (String) - The command to run. E.g. kill.


Description

Forces a userid to execute a command on the server console (bypassing client console).

This is the Python equivalent of: http://www.eventscripts.com/pages/es_sexec

Examples

es.sexec("4", "kill")
import es
import playerlib
 
 
def load():
        # Check to see if the say command exists
        if not es.exists('saycommand', 'slap'):
           # Register the say command to the function block!
           es.regsaycmd('slap', 'healthyaddon/slap')
 
def slap():
        # Players name
        name = es.getargv(1)
        # Amount of health to deduct
        amount = es.getargv(2)
        # Grab userid from the name
        userid = es.getuserid(name)
        # Check to see if there is such a player!
        if userid <= 0:
                # Inform the abuser that there is no such name! :)
                es.tell(es.getcmduserid(), name + " does not exists.. try gain? :P")
        # Else create PAIN!
        else:
                # Use the playerlib to help us hurt the player
                player = playerlib.getPlayer(userid)
                # Get the current health
                curhealth = player.attributes["health"]
                # Remove all armor.. You don't have to do this though.
                player.set("armor", "0")
                # Calculate the new health
                newhealth = int(curhealth) - int(amount)
                # Set the new health!
                player.set("health", str(newhealth))
                # Check to see if the player has any health left. If not.. Kill Muwhahaha
                if newhealth <= 0:
                        # Execute the kill command! :D
                        es.sexec(userid, "kill")

Notes


See Also

blog comments powered by Disqus