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

!up Playername


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
emza
Member
Join Date: Sep 2010
Location: Paracin/Srbija
Old 11-13-2011 , 05:25   !up Playername
Reply With Quote #1

Hello everyone, I have a question regarding Plugin. !up PlayerName
Plugin already exists for EventScript, but I'm not a fan of ES, but SourceMod

here are the data, who is interested to make plugin for SourceMod
this plugin is like FinallBatleGround


PHP Code:
import escmdlibcfglibcPickle
from path import path

# === RESPECT POINTS PLUGIN ==================================
# ========= CREATED BY HANNIBAL AND CRAZIEST =================
# ================ DO NOT EDIT ANYTHING BELOW THIS LINE ======
# ========================= OPEN & EDIT THE CONFIG.CFG FILE ==

''' Addon Information '''
info es.AddonInfo()
info.name 'Respect'
info.version '1.0'
info.basename 'respect'
info.author 'Craziest & Hannibal'
info.description 'Give respect points to your friends, or take it from them'

es.ServerVar("respect_version"info.version).makepublic()

''' Config Generator '''
cfg cfglib.AddonCFG(es.getAddonPath("respect") + "/config/config.cfg")

cfg.text("******************************")
cfg.text("****** RESPECT SETTINGS ******")
cfg.text("******** BY CRAZIEST *********")
cfg.text("")
cfg.text("Load this plugin with: es_load respect")
cfg.text("")
cfg.text("Edit the following settings:")
cfg.text("")
cfg.text("-- Command Options --")
cfg.text("")
upCommand cfg.cvar("respect_give_command""!up""The command used to give someone a respect point")
downCommand cfg.cvar("respect_take_command""!down""The command used to take a respect point from someone")
viewCommand cfg.cvar("respect_view_command""!repview""The command to view your respect points / given respect points")
helpCommand cfg.cvar("respect_help_command""!rephelp""The command used to tell players how to use the respect system")
cfg.text("")
cfg.text("-- Other Options --")
cfg.text("")
maxUses cfg.cvar("respect_max_uses"2"The maximum times the player can give/take respect - resets on map change (0 = Unlimited)")
announce cfg.cvar("respect_announce_plugin"1"Announce on round start the plugin is running")
saveRespect cfg.cvar("respect_save"1"Save the respect to a database on map start/unload so the data isn't lost")
cfg.text("")
cfg.text("End of config!")
cfg.text("Post on the forums if you have any suggestions/problems")
cfg.text("")
cfg.text("Coded by .craziesT")

cfg.write()

# =========================================================
usedList= []

class 
RespectManagerMain(object):
    
''' The engine of the script '''
    
helpCommand None
    
    def __init__
(self):
        
''' Called everytime the script initiates '''
        
self.respect = {}

    
def registerSay(selfcommand):
        
''' Manages registering the give command '''
        
cmdlib.registerSayCommand(commandself.useCommand'Respect Plugin Commands')
        
self.helpCommand command
    
    def unregisterSay
(self):
        
''' Unregisters the command when told to '''
        
cmdlib.unregisterSayCommand(self.helpCommand)
        
    
def message(selftextuserid=Nonetype=None):
        
''' Message Handler '''
        
if userid and type == True
            
es.tell(userid'#multi''#green--- ' text)   
        else:
            
es.msg('#multi''#green--- ' text)
            
    
def checkPlayer(selfuserid):
        
''' Check and adds the player to the database if he doesn't exist '''
        target = '
0'
        
        if userid:
            if es.isbot(userid):
                uid = es.getplayername(userid)
            else:
                uid = es.getplayersteamid(userid)
                
            if uid not in self.respect:
                self.respect[uid] = {}
                self.respect[uid]['
total'] = 0
                self.respect[uid]['
uses'] = 0
                
    def resetTries(self, userid):
        ''' 
Sets the players uses to 0 when told to '''
        if es.isbot(userid):
            uid = es.getplayername(userid)
        else:
            uid = es.getplayersteamid(userid)
                
        self.respect[uid]['
uses'] = 0
                
    def addPlayerRelation(self, uid, tid):
        ''' 
Checks player relationship and adds it if it doesn\'t exist '''
        
if tid not in self.respect:
            
self.respect[tid] = {}
            
self.respect[tid]['total'] = 0
        
        
if tid not in self.respect[uid]:
            
self.respect[uid][tid] = {}
            
self.respect[uid][tid]['rep'] = 0
            
    def useCommand
(selfuseridargs):
        
self.message('Type #lightgreen%s#green to give respect, #lightgreen%s#green to take respect and #lightgreen%s#green to view your stats or given points to others!' % (upCommanddownCommandviewCommand), useridTrue)
            
    
def announcer(self):
        if 
announce:
            
self.message('Respect plugin is running. Type #lightgreen%s#green to get more help ---' helpCommand)
                
    
def saveRespect(self):
        
''' Manages saving the respect points to a database file '''
        
open(es.getAddonPath("respect") + '/respect.db''wb')
        
cPickle.dump(self.respectp)
        
p.close()
    
    
def openRespect(self):
        
''' Manages opening the respect database '''
        
es.getAddonPath("respect") + '/respect.db'
        
if path(p).isfile():
            
open(p'rb')
            
self.respect cPickle.load(f)
            
f.close()

mainManager RespectManagerMain()

class 
RespectManagerGive(RespectManagerMain):
    
''' Manages giving respect to someone '''
    
giveCommand None
    
    def registerSay
(selfcommand):
        
''' Manages registering the give command '''
        
cmdlib.registerSayCommand(commandself.upCommand'Respect Plugin Commands')
        
self.giveCommand command
    
    def unregisterSay
(self):
        
''' Unregisters the command when told to '''
        
cmdlib.unregisterSayCommand(self.giveCommand)
        
    
def upCommand(selfuseridargs):
        
''' Manages the give command functions '''
        
uid es.getplayersteamid(userid)
        
        if 
args:
            
target es.getuserid(args)
            if 
target in (0None):
                
self.message('The specified player doesnt not exist.'useridTrue)
                return
            if 
es.isbot(target):
                
tid es.getplayername(target)
            else:
                
tid es.getplayersteamid(target)
                
            if 
userid != target:
                if 
mainManager.respect[uid]['uses'] < maxUses or maxUses == 0:
                    
                    
mainManager.addPlayerRelation(uidtid)
                    
                    
mainManager.respect[uid]['uses'] += 1
                    mainManager
.respect[uid][tid]['rep'] += 1
                    mainManager
.respect[tid]['total'] += 1
                        
                    self
.checkSituationGive(uidtid)
                        
                else:
                    
self.message('You have used all of your respect points!'useridTrue)
                    
usedList.append(userid)
            else:
                
self.message('You can not give respect to yourself.'useridTrue)
        else:
            
self.message('Invalid syntax! #green%s <name/userid/steamid>' self.giveCommanduseridTrue)
            
    
def checkSituationGive(selfuidtid):
        
''' Checks the current respect between the two players '''
        
targetName es.getplayername(es.getuserid(tid))
        
useridName es.getplayername(es.getuserid(uid))
        
        if 
mainManager.respect[uid][tid]['rep'] == 0:
            
self.message('#lightgreen%s#green has neutral respect towards #lightgreen%s#green!' % (useridNametargetName))
            
        else:
            
self.message('#lightgreen%s#green gave a respect point to #lightgreen%s#green (Score: #lightgreen%s#green)' % (useridNametargetNamemainManager.respect[uid][tid]['rep']))
            
giveManager RespectManagerGive()
            
class 
RespectManagerTake(RespectManagerMain):
    
''' Manages giving respect to someone '''
    
takeCommand None
    
    def registerSay
(selfcommand):
        
''' Manages registering the give command '''
        
cmdlib.registerSayCommand(commandself.downCommand'Respect Plugin Commands')
        
self.takeCommand command
    
    def unregisterSay
(self):
        
''' Unregisters the command when told to '''
        
cmdlib.unregisterSayCommand(self.takeCommand)
        
    
def downCommand(selfuseridargs):
        
''' Called when the person uses the !down command '''
        
uid es.getplayersteamid(userid)
        
        if 
args:
            
target es.getuserid(args)
            if 
target in (0None):
                
self.message('The specified player doesnt not exist.'useridTrue)
                return
            if 
es.isbot(target):
                
tid es.getplayername(target)
            else:
                
tid es.getplayersteamid(target)
                
            if 
userid != target:
                if 
mainManager.respect[uid]['uses'] < maxUses or maxUses == 0:
                    
                    
mainManager.addPlayerRelation(uidtid)
                    
                    if 
mainManager.respect[tid]['total'] > 0:
                        
mainManager.respect[tid]['total'] -= 1
                            
                    
if mainManager.respect[uid][tid]['rep'] > -1:
                        
mainManager.respect[uid][tid]['rep'] -= 1
                            
                    self
.checkSituationTake(uidtid)
                else:
                    
self.message('You have used all of your respect points!'useridTrue)
                    
usedList.append(userid)
            else:
                
self.message('You can not give respect to yourself.'useridTrue)
        else:
            
self.message('Invalid syntax! #lightgreen%s <name/userid/steamid>' self.takeCommanduseridTrue)
                        
                        
    
def checkSituationTake(selfuidtid):
        
''' Checks the current respect between the two players '''
        
targetName es.getplayername(es.getuserid(tid))
        
useridName es.getplayername(es.getuserid(uid))
        
        if 
mainManager.respect[uid][tid]['rep'] == 0:
            
self.message('#lightgreen%s#green has neutral respect towards #lightgreen%s#green!' % (useridNametargetName))
            
        
elif mainManager.respect[uid][tid]['rep'] == -1:
            
self.message('#lightgreen%s#green has negative respect towards #lightgreen%s#green!' % (useridNametargetName))
            
        else:
            
self.message('#lightgreen%s#green took a respect point from #lightgreen%s#green (Score: #lightgreen%s#green)' % (useridNametargetNamemainManager.respect[uid][tid]['rep']))
            
takeManager RespectManagerTake()

class 
RespectManagerView(RespectManagerMain):
    
''' Manages giving respect to someone '''
    
lookCommand None
    
    def registerSay
(selfcommand):
        
''' Manages registering the give command '''
        
cmdlib.registerSayCommand(commandself.viewCommand'Respect Plugin Commands')
        
self.lookCommand command
    
    def unregisterSay
(self):
        
''' Unregisters the command when told to '''
        
cmdlib.unregisterSayCommand(self.lookCommand)
        
    
def viewCommand(selfuseridargs):
        
''' Handles the !view command and it\'s functions '''
        
uid es.getplayersteamid(userid)
        
        if 
args:
            
target es.getuserid(args)
            if 
target in (0None):
                
self.message('The specified player doesnt not exist.'useridTrue)
                return
            
            if 
es.isbot(target):
                
tid es.getplayername(target)
            else:
                
tid es.getplayersteamid(target)
                
            if 
userid != target:
                
mainManager.addPlayerRelation(uidtid)
                
                
self.checkSituationView(uidtid)
            else:
                
self.message('To view your points #lightgreendo not#green type any arguments with the command!'useridTrue)
                
        else:
            if 
mainManager.respect[uid]['total'] > 0:
                
self.message('#lightgreen%s#green has #lightgreen%s#green respect points on his account!' % (es.getplayername(userid), mainManager.respect[uid]['total']))
            
elif mainManager.respect[uid]['total'in (0None):
                
self.message('#lightgreen%s#green has no respect points currently.' es.getplayername(userid))
            else:
                
self.message('Invalid syntax! #lightgreen%s <name/userid/steamid>#green or no arguments for your stats.' self.lookCommanduseridTrue)
                
    
def checkSituationView(selfuidtid):
        
''' Checks the current respect between the two players '''
        
targetName es.getplayername(es.getuserid(tid))
        
useridName es.getplayername(es.getuserid(uid))
        
        if 
mainManager.respect[uid][tid]['rep'] == 0:
            
self.message('#lightgreen%s#green has neutral respect towards #lightgreen%s#green!' % (useridNametargetName))
            
        
elif mainManager.respect[uid][tid]['rep'] == -1:
            
self.message('#lightgreen%s#green has negative respect towards #lightgreen%s#green!' % (useridNametargetName))
            
        else:
            
self.message('#lightgreen%s#green has positive respect towards #lightgreen%s#green (Score: #lightgreen%s#green)' % (useridNametargetNamemainManager.respect[uid][tid]['rep']))
            
viewManager RespectManagerView()
    
# ========================================================

def load():
    
''' Called when the script loads '''
    
for xy in [(giveManagerupCommand), (takeManagerdownCommand), (viewManagerviewCommand), (mainManagerhelpCommand)]:
        
x.registerSay(y)    
    for 
userid in es.getUseridList():
        
mainManager.checkPlayer(userid)
    if 
saveRespect:
        
mainManager.openRespect()
        
    
del usedList[:]    
    for 
userid in es.getUseridList(): mainManager.resetTries(userid)
    
def unload():
    for 
x in [giveManagertakeManagerviewManagermainManager]:
        
x.unregisterSay()
    if 
saveRespect:
        
mainManager.saveRespect()   
    
del usedList[:]
    
    for 
userid in es.getUseridList(): mainManager.resetTries(userid)
        
def es_map_start(ev):
    if 
saveRespect:
        
mainManager.saveRespect()
    if 
userid in usedList:
        
mainManager.resetTries(userid)
        
def round_start(ev):
    
mainManager.announcer()
    
def player_activate(ev):
    
userid int(ev['userid'])
    
mainManager.checkPlayer(userid)
    if 
userid in usedList:
        
mainManager.resetTries(userid)
    
# =========================================================== 

Sorry for my BAD ENGLISH
emza is offline
InB
AlliedModders Donor
Join Date: Aug 2012
Location: Los Angeles
Old 11-22-2012 , 03:53   Re: !up Playername
Reply With Quote #2

It will be here soon.
__________________
InB 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 12:26.


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