Battlefield Modding Tutorials BFMODS

Battlefield Modding Tutorials
It is currently Mon Nov 20, 2017 2:11 am

All times are UTC




Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 70 posts ]  Go to page 1, 2, 3, 4, 5 ... 9  Next
Author Message
PostPosted: Sun Aug 07, 2005 11:05 am 
Offline

Joined: Fri Sep 17, 2004 12:00 am
Posts: 986
Location: 1.80m above the ground
Ive been doing some python trying to create a nice script, and it seems to work, so i thought it might be a nice thing to place on the ssm.com server as an attraction.

Did it cost me $200? No, my 2 cents. ;)

Most of the stuff written in it comes from the python wiki and all the guys that placed stuff over there. Its really simple actually, but it took me a couple of days to figure it out since i had 0 experience with python ;).

Anyway, here it is:
The script

Its easy configurable. Jst place the file in admin\standart_admin or anywhere else and place these lines in the __init__.py file you want it in:
Code:
import jimmy
jimmy.init()

(youll know where to put it)

If anyone knows an improvement, post it up. I havent been able to make it read its settings from a textfile, somehow it never got to work.
So if you want to make an adjustment, just open up the file and change it. Currently it has the UnrealTournament qoutes and killlimits, because it seems almost everyone wants that i think.

_________________
Time to use the debugger


Last edited by Harry on Sun Aug 07, 2005 3:34 pm, edited 1 time in total.

Top
 Profile Send private message E-mail  
 
 Post subject:
PostPosted: Sun Aug 07, 2005 2:05 pm 
Offline

Joined: Mon Aug 16, 2004 12:00 am
Posts: 2120
I get a 500 error when I click the link, and I cant Save Target As either.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 07, 2005 3:30 pm 
Offline

Joined: Fri Sep 17, 2004 12:00 am
Posts: 986
Location: 1.80m above the ground
Funny, ill see if I can fix it.

Edit
Oh thats jsut too funny, since its an python script the server tries do do something with it i tink. Ive renamed it to .python, and now you can dld it (jsut save it as an .py and youll be fine.)

The script

_________________
Time to use the debugger


Top
 Profile Send private message E-mail  
 
 Post subject:
PostPosted: Mon Aug 08, 2005 1:26 am 
Offline

Joined: Mon Aug 16, 2004 12:00 am
Posts: 2120
If somebody included this into a mod, and placed some sounds in it, they could incorperate sounds into the script to play. But the client would have to have the files too, so that would be left for an actual mod.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 08, 2005 7:19 am 
Offline

Joined: Tue Nov 02, 2004 12:00 am
Posts: 773
Location: Mars
nevermind, stupid question. I figured it out.

_________________
DCon Dev
http://desert-conflict.org

Image

I refuse to buy more garbage from EA. 2142 has crossed the line. If you are with me, copy this into your sig too.


Last edited by Superfuzz on Mon Aug 08, 2005 7:23 am, edited 1 time in total.

Top
 Profile Send private message E-mail  
 
 Post subject:
PostPosted: Mon Aug 08, 2005 7:20 am 
Offline

Joined: Wed Jan 12, 2005 12:00 am
Posts: 63
Here's a little bit so that "jimmy" gets insulted when hes sucking :)
Code:
# A freakin' "Jimmy is on fire" script by Harry                            #
# Thx to bf2 python wiki for about everything and nivekmai for the name ;) #
# Modified by nivekmai(aka Milton) to insult sucky players                 #

import host
import bf2
from bf2 import g_debug
limit1 = 5
limit2 = 10
limit3 = 15
limit4 = 20
limit5 = 25

praise1 = "is on a Killing Spree!"
praise2 = "is on a Rampage!"
praise3 = "is Dominating!"
praise4 = "is Unstoppable!"
praise5 = "is Godlike!"

insult1 = "isn't doing too good..."
insult2 = "must be having a bad day..."
insult3 = "should take a break..."
insult4 = "should find a new game to play..."
insult5 = "doesn't even deserve a computer!"

def init():
    print "Jimmyscript initialisation"
    host.registerHandler('PlayerKilled', onPlayerKilled)
    host.registerHandler('PlayerConnect', onPlayerConnect, 1)
    print "Jimmyscript initialised succesfully"

def onPlayerConnect(p):
    p.killsinarow = 0
    p.deathsinarow = 0

def onPlayerKilled(victim, attacker, weapon, assists, object):
   victimVehicle = victim.getVehicle()
#  print "Someone got killed"
   victim.killsinarow = 0
#  print victim.killsinarow
#  print weapon
   checkForInsult(victim)
   
   # killed by remote controlled vehicle, no score awarded in this game
   if victimVehicle and victimVehicle.getIsRemoteControlled():
      pass
     
   # no attacker, killed by object
   elif attacker == None:
      pass
     
   # killed by self
   elif attacker == victim:
#     host.rcon_invoke("game.sayAll \"" + "Player |cXXXX" + victim.getName() + "|cXXXX killed himself" + "\"")
      pass
 
   # killed by own team
   elif attacker.getTeam() == victim.getTeam():
      pass

   # killed by enemy
   else:
      attacker.deathsinarow = 0
      checkForAward(attacker)

def checkForInsult(p):
   global limit1,limit2,limit3,limit4,limit5,insult1,insult2,insult3,insult4,insult5
#  print "Insultcheck for player " + p.getName()
   p.deathsinarow += 1
#  print p.killsinarow
   if p.deathsinarow == limit1:
      host.rcon_invoke("game.sayAll \"" + "Player |cXXXX" + p.getName() + "|cXXXX " + insult1 + "\"")
   if p.deathsinarow == limit2:
      host.rcon_invoke("game.sayAll \"" + "Player |cXXXX" + p.getName() + "|cXXXX " + insult2 + "\"")
   if p.deathsinarow == limit3:
      host.rcon_invoke("game.sayAll \"" + "Player |cXXXX" + p.getName() + "|cXXXX " + insult3 + "\"")
   if p.deathsinarow == limit4:
      host.rcon_invoke("game.sayAll \"" + "Player |cXXXX" + p.getName() + "|cXXXX " + insult4 + "\"")
   if p.deathsinarow == limit5:
      host.rcon_invoke("game.sayAll \"" + "Player |cXXXX" + p.getName() + "|cXXXX " + insult5 + "\"")

def checkForAward(p):
   global limit1,limit2,limit3,limit4,limit5,praise1,praise2,praise3,praise4,praise5
#  print "Awardcheck for player " + p.getName()
   p.killsinarow += 1
#  print p.killsinarow
   if p.killsinarow == limit1:
      host.rcon_invoke("game.sayAll \"" + "Player |cXXXX" + p.getName() + "|cXXXX " + praise1 + "\"")
   if p.killsinarow == limit2:
      host.rcon_invoke("game.sayAll \"" + "Player |cXXXX" + p.getName() + "|cXXXX " + praise2 + "\"")
   if p.killsinarow == limit3:
      host.rcon_invoke("game.sayAll \"" + "Player |cXXXX" + p.getName() + "|cXXXX " + praise3 + "\"")
   if p.killsinarow == limit4:
      host.rcon_invoke("game.sayAll \"" + "Player |cXXXX" + p.getName() + "|cXXXX " + praise4 + "\"")
   if p.killsinarow == limit5:
      host.rcon_invoke("game.sayAll \"" + "Player |cXXXX" + p.getName() + "|cXXXX " + praise5 + "\"")

This is still untested, but it should work if harry's script works(unfortunately I don't have an unranked server to test it on)

Note: to get this saved as a python file just paste it into notepad and save it as a .py file


Top
 Profile Send private message E-mail  
 
 Post subject:
PostPosted: Fri Aug 12, 2005 4:17 am 
Offline

Joined: Tue Aug 17, 2004 12:00 am
Posts: 172
I am having some problems getting a remote manager to work, but I glanced over that code and it looks pretty cool and hopefully I can get things squared away.

Also, for the time being the server is used by my clan as a practice server. Ranked servers are still most people's #1 choice.


Top
 Profile Send private message E-mail  
 
 Post subject:
PostPosted: Fri Aug 12, 2005 9:11 am 
Offline

Joined: Fri Sep 17, 2004 12:00 am
Posts: 986
Location: 1.80m above the ground
Na-aha, so thats why theres an pw on the ssm.com server. Atleast that problem got figured out.

Anyway, i noticed something people might want to look at before trying to run the script: it seems the bf2 serverlauncher app doesnt start the custom made scripts. So if you want to launch it, run the w32_ded app yourself. Thisdoes however make it necessary to edit the serversettings yourself. Although i think you can copy the ones from the profile to the settings dir.

_________________
Time to use the debugger


Top
 Profile Send private message E-mail  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 70 posts ]  Go to page 1, 2, 3, 4, 5 ... 9  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
Powered by phpBB® Forum Software © phpBB Group