Pareil j'ai commençais un autre plugin cette nuit x) (je débute alors il me faut du temps)
Je sais pas pourquoi à la fin du vote sa dit comme quoi que le vote est passé mais sans kick la personne
__version__ = '2.0'
__author__ = '=KsL=General'
import b3, time, thread, string #b3,temps,start
import b3.events # Importation des events
import b3.plugin
import b3.cron
from b3 import clients
class Vote:
Vote = 0
#-------------------------------------------------------------------------------------------------
class VotingPlugin(b3.plugin.Plugin):
requiresConfigFile = False
_kickTime = 31
lastingvote = 1
voteyes = 0
voteno = 0
percentage = 0
_clientvar_name = 'vote'
def startup(self):
"""\
Initialize plugin settings
"""
self._adminPlugin = self.console.getPlugin('admin')
if not self._adminPlugin:
self.error('Could not find admin plugin')
return False
else: #Enregistrement des commandes
self._adminPlugin.registerCommand(self, 'vote', 60, self.cmd_vote, 'v')
self._adminPlugin.registerCommand(self, 'voteyes', 0, self.cmd_voteyes, 'vy')
self._adminPlugin.registerCommand(self, 'voteno', 0, self.cmd_voteno, 'vn')
self._adminPlugin.registerCommand(self, 'resetvote', 0, self.cmd_resetvote, 'rv')
def get_Vote(self, client):
if not client.isvar(self, self._clientvar_name):
client.setvar(self, self._clientvar_name, Vote())
return client.var(self, self._clientvar_name).value
def cmd_vote(self, data, client, cmd=None):
"""\
<vote> <player/map/other> - for callvote.
"""
m = self._adminPlugin.parseUserCmd(data)
if not m[0]:
client.message('^1ERROR: ^7You must supply a vote: kick, nextmap, cyclemap...')
return False
if not m[1]:
client.message('^1ERROR: ^7You must supply a player/map/nextmap...')
return False
sclient = self._adminPlugin.findClientPrompt(m[1], client)
if sclient and m[0]=='kick':
self.lastingvote == 1
sclient.message('%s, ^3Callvote kick ^7you...' % (client.exactName))
thread.start_new_thread(self.kickvote, (sclient, client))
def kickvote(self, sclient, client):
self.voteno = 0
self.voteyes = 0
c = 0
while c < self._kickTime: #Temp kick
self.console.write('bigtext "^3Callvote kick %s ^1[^5%s^7/^530^1] ^3[^7Yes:^2%s ^7No:^1%s^7]"' % (sclient.exactName, c, self.voteyes, self.voteno))
time.sleep(1)
c += 1
if(c >= self._kickTime):
if(self.voteyes > self.voteno):
if sclient:
self.console.say('Vote ^2accepter^7: ^7Yes: ^2%s ^7No ^1%s ' % (self.voteyes, self.voteno))
self.console.write('kick %s callvote_kick' % (sclient.id)) <---------------------------------------------------------------------------
ICI
else:
self.console.say('Vote ^1refuser^7: ^7Yes: ^2%s ^7No ^1%s ' % (self.voteyes, self.voteno))
def cmd_voteyes(self, data, client, cmd=None):
"""\
Vote "voteyes" to the vote
"""
if self.lastingvote == 1:
stats = self.get_Vote(client)
if stats.Vote == 0:
self.voteyes = self.voteyes + 1
client.message('^7You voted on ^2YES ^7( ^2%s FOR ^7/ ^1%s AGAINST^3)' % (self.voteyes, self.voteno))
stats.Vote = 1
else:
client.message('^1You can vote only once')
def cmd_voteno(self, data, client, cmd=None):
"""\
Vote "voteno" to the vote
"""
if self.lastingvote == 1:
stats = self.get_Vote(client)
if stats.Vote == 0: #On active
self.voteno = self.voteno + 1
client.message('^7You voted on ^1NO ^7(^2%s FOR ^7/ ^1%s AGAINST^3)' % (self.voteno, self.voteno))
stats.Vote = 1 # on desactive
else:
client.message('^1You can vote only once')
def cmd_resetvote(self, data, client, cmd=None):
self.resetVote()
def resetVote(self): #reactiver les votes
clist = self.console.clients.getClientsByLevel(0)
if len(clist) > 0:
for c in clist:
stats = self.get_Vote(c)
stats.Vote = 0