Splizes Posted February 17, 2010 Share Posted February 17, 2010 Now this doesnt work correctly, but I just thought I would show what I've done my first day fucking around with it (a couple hours worth) please don't fix it because I want to do it tomorrow import es, playerlib, popuplib, usermsg info = es.AddonInfo() info['name'] = "Vote TeamSwitch" info['basename'] = "votefk" info['version'] = "0.0" info['author'] = "Splizes" info['url'] = "www.Hellsgamers.com" info['description'] = "Adds the functionality to teamswap a player, specifically to Terrorist" es.ServerVar(info['basename'], info['version'], info['description']).makepublic() voteFK_Dict = {} voteFK_votes = {} voteFK_voted = {} # def load(): # es.msg('#multi', '#default[#greenVoteFK#default]: by #lightgreenSplizes #defaultLoaded Successfully!')) # Temporal variables: # votefk_pCount - player count # player - temporary player used to show each player in a loop def player_say(ev): if ev['text'] == "!votefk": votefk_pCount = len(playerlib.getPlayerList('#human')) vkPopup = popuplib.easymenu('vkPopup', '_popup_choice', vkPopup_select) vkPopup.settitle("Player to Vote Kick:") for player in playerlib.getUseridList('#all'): vkPopup.addoption(player, es.getplayername(player)) vkPopup.send(int(ev['userid'])) def vkPopup_select(userid, choice, popupid): global voteFK_Dict if userid not in voteFK_Dict[choice]["voted"]: voteFK_Dict[choice]["voted"].append(userid) voteFK_Dict[choice]["votes"] += 1 es.msg('#multi', '#default[#greenVote Free-killer#default]: #lightgreen%s #defaultvoted to team swap #lightgreen%s#default!'%(es.getplayername(userid), es.getplayername(choice))) es.msg(voteFK_Dict[choice]["votes"]) voteFK_Needed = 2 #(len(playerlib.getPlayerList('#t')) / 2) if voteFK_Dict[choice]["votes"] >= voteFK_Needed: changeteam(choice, 2) voteFK_Dict[choice]["votes"] = 0 del voteFK_Dict[choice]["voted"][:] elif userid in voteFK_Dict[choice]["voted"]: es.tell(userid, '#multi', '#defaultYou have already voted to team swap #lightgreen%s#default!'%es.getplayername(choice)) def player_spawn(ev): global voteFK_Dict user = int(ev['userid']) if user not in voteFK_Dict: voteFK_Dict[user] = {} voteFK_Dict[user]["votes"] = 0 voteFK_Dict[user]["voted"] = [] def player_disconnect(ev): global voteFK_Dict user = int(ev['userid']) if user in voteFK_Dict: del voteFK_Dict[user] #1 spec, 2 t, 3 ct def changeteam(userid, teamid): es.server.queuecmd('es_xchangeteam %s %s' % (userid, teamid)) Quote Link to comment Share on other sites More sharing options...
Cr(+)sshair Posted February 17, 2010 Share Posted February 17, 2010 You have to replace *MESSAGE DELETED* with *MESSAGE DELETED* in order to get the *MESSAGE DELETED* working. Otherwise, good job! =P Quote Link to comment Share on other sites More sharing options...
Splizes Posted February 17, 2010 Author Share Posted February 17, 2010 (edited) I'm not exactly sure what I changed lolz but it works now (at least during this mornings test it did): import es, playerlib, popuplib info = es.AddonInfo() info['name'] = "Vote TeamSwitch" info['basename'] = "votefk" info['version'] = "0.1" info['author'] = "Splizes" info['url'] = "www.Hellsgamers.com" info['description'] = "Adds the functionality to teamswap a player, specifically to Terrorist" es.ServerVar(info['basename'], info['version'], info['description']).makepublic() voteFK_Dict = {} def player_say(ev): if ev['text'] == "!votefk" or ev['text'] == "/votefk": votefk_pCount = len(playerlib.getPlayerList('#human')) vkPopup = popuplib.easymenu('vkPopup', '_popup_choice', vkPopup_select) vkPopup.settitle("Player to Vote Kick:") for player in playerlib.getUseridList('#all'): vkPopup.addoption(player, es.getplayername(player)) vkPopup.send(int(ev['userid'])) def vkPopup_select(userid, choice, popupid): global voteFK_Dict if userid not in voteFK_Dict[choice]["voted"]: voteFK_Dict[choice]["voted"].append(userid) voteFK_Dict[choice]["votes"] += 1 voteFK_Needed = (len(playerlib.getPlayerList('#t')) / 3) es.msg('#multi', '#default[#greenVote Free-killer#default]: #lightgreen%s #defaultvoted to team swap #lightgreen%s#default [%s/%s]!'%(es.getplayername(userid), es.getplayername(choice), voteFK_Dict[choice]["votes"], voteFK_Needed)) es.msg(voteFK_Dict[choice]["votes"]) if voteFK_Dict[choice]["votes"] >= voteFK_Needed: changeteam(choice, 2) voteFK_Dict[choice]["votes"] = 0 del voteFK_Dict[choice]["voted"][:] elif userid in voteFK_Dict[choice]["voted"]: es.tell(userid, '#multi', '#defaultYou have already voted to team swap #lightgreen%s#default!'%es.getplayername(choice)) def player_spawn(ev): global voteFK_Dict user = int(ev['userid']) if user not in voteFK_Dict: voteFK_Dict[user] = {} voteFK_Dict[user]["votes"] = 0 voteFK_Dict[user]["voted"] = [] def player_disconnect(ev): global voteFK_Dict user = int(ev['userid']) if user in voteFK_Dict: del voteFK_Dict[user] #1 spec, 2 t, 3 ct def changeteam(userid, teamid): es.server.queuecmd('es_xchangeteam %s %s' % (userid, teamid)) Edited February 17, 2010 by Splizes Quote Link to comment Share on other sites More sharing options...
bort Posted February 17, 2010 Share Posted February 17, 2010 python is such a nice language. <3 except for self I hate self. And it can also be compiled into a binary (if you wanted to not use the python interpreter like normally), so it can be fast fast fast (even running in the interpreter as bytecode it can be arguably faster than PHP) Quote Link to comment Share on other sites More sharing options...
Splizes Posted February 18, 2010 Author Share Posted February 18, 2010 What I worked on today not anywhere near done, but a nice start import es, playerlib, popuplib info = es.AddonInfo() info['name'] = "Rubber bullet obstacle" info['basename'] = "lr_rbo" info['version'] = "0.0" info['author'] = "Splizes" info['url'] = "www.HellsGamers.com" info['description'] = "A rubber bullet last request in which a bullet two players are teleported to obstacles and are allowed to fire one bullet a peice which is rubber and is able to knock a player off of a tier" es.ServerVar(info['basename'], info['version'], info['description']).makepublic() def load(): global ct_userid, t_userid, rbo_activated ct_coordinates = [0, 0, 0] t_coordinates = [0, 0, 0] ct_userid = 0 t_userid = 0 rbo_activated = 0 def player_say(ev): if ev['text'] == "!lr" or ev['text'] == "/votefk": votefk_pCount = len(playerlib.getPlayerList('#human')) vkPopup = popuplib.easymenu('vkPopup', '_popup_choice', vkPopup_select) vkPopup.settitle("Player to LR with:") for player in playerlib.getUseridList('#all'): vkPopup.addoption(player, es.getplayername(player)) vkPopup.send(int(ev['userid'])) def vkPopup_select(userid, choice, popupid): initiate_lr(choice, userid) es.msg("Game Start") def initiate_lr(userid_ct, userid_t): global ct_userid, t_userid, rbo_activated #es.server.queuecmd('es_setpos %s %s %s %s'%(userid_ct, ct_coordinates[0], ct_coordinates[1], ct_coordinates[2])) #es.server.queuecmd('es_setpos %s %s %s %s'%(userid_t, t_coordinates[0], t_coordinates[1], t_coordinates[2])) es.server.queuecmd('es_xfire %s player_weaponstrip Kill' % userid_t) es.server.queuecmd('es_xgive %s player_weaponstrip' % userid_t) es.server.queuecmd('es_xgive %s player_weaponstrip Strip' % userid_t) es.server.queuecmd('es_xgive %s weapon_usp'%(userid_t)) #es.server.queuecmd('es_xgive %s %s'%(userid_ct, weapon_usp)# es.server.queuecmd('es_xfire %s player_weaponstrip Kill' % userid_t) es.server.queuecmd('es_xgive %s player_weaponstrip' % userid_ct) es.server.queuecmd('es_xgive %s player_weaponstrip Strip' % userid_ct) ct_userid = userid_ct #lolz t_userid = userid_t rbo_activated = 1 def player_hurt(event_var): global ct_userid, t_userid, rbo_activated if rbo_activated == 1: #This line might not be needed but should prevent a lot of unnecesary expansion if (event_var['attacker'] == ct_userid) or (event_var['attacker'] == t_userid): if (event_var['userid'] == ct_userid) or (event_var['userid'] == t_userid): if (event_var['attacker'] != event_var['userid']) and (int(event_var['attacker']) != 0): hurtPlayer = playerlib.getplayer(event_var['userid']) hPVector = hurtPlayer.get('viewvector') dMultiplier = 450 # test pushback = [] pushback[0] = float(hPVector[0]) * dMultiplier pushback[1] = float(hPVector[1]) * dMultiplier pushback[2] = float(hPVector[2]) * dMultiplier es.server.queuecmd('est_physpush %s %i %i %i' % (event_var['userid'], pushback[0], pushback[1], pushback[2])) if (eventvar['attacker'] == ct_userid): tmp_id1 = ct_userid tmp_id2 = t_userid elif (eventvar['attacker'] == t_userid): tmp_id1 = t_userid tmp_id2 = ct_userid es.server.queuecmd('es_xfire %s player_weaponstrip Kill' % tmp_id1) es.server.queuecmd('es_xgive %s player_weaponstrip' % tmp_id1) es.server.queuecmd('es_xgive %s player_weaponstrip Strip' % tmp_id1) es.server.queuecmd('es_xgive %s weapon_awp' % tmp_id2) Quote Link to comment Share on other sites More sharing options...
n1ckkkkk Posted February 18, 2010 Share Posted February 18, 2010 Do you go to school for this? Quote Link to comment Share on other sites More sharing options...
Splizes Posted February 18, 2010 Author Share Posted February 18, 2010 No I just started learning it yesterday O.o just looked at a script and some more scripts and put 2 and 2 together to start learning it, I'm treating this as a blog for my progress in learning it. Quote Link to comment Share on other sites More sharing options...
n1ckkkkk Posted February 18, 2010 Share Posted February 18, 2010 teach me or send me somewhere Quote Link to comment Share on other sites More sharing options...
Splizes Posted February 18, 2010 Author Share Posted February 18, 2010 http://python.eventscripts.com/pages/My_First_Addon Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.