Scripts: Difference between revisions
m (→Comments?) |
|||
(One intermediate revision by one other user not shown) | |||
Line 109: | Line 109: | ||
---- | ---- | ||
Hmmm does anyone happen to have the Sentinel Scripts? | '''August 21th, 2008''' - Hmmm does anyone happen to have the Sentinel Scripts? | ||
'''March 19th, 2014''' - I see this page has not been updated in a long time, but I have an idea that I would love to get working. My issue is when attempting the login the resulting output page says "Invalid username or password". | |||
Now I have triple-checked those, yet login still fails. I was wondering if the Urban Dead login mechanism may have been changed to affect this? I checked the login form values are still "username" and "password", with no hidden inputs. I tried prepending the www subdomain too, just in case. Aside the fact that the '~' token does not expand (so I use the full path), I am at a loss on how to proceed. | |||
And for the record, this is for a script I want to log in, grab the "since your last visit" messages and have me notified of any notable events. I certainly do not approve of automated players or zerging. I realize this will add to my IP hits, but find this more an exercise in see-if-it-works than something I need to have. --[[User:Wez|<span style="background-color: #000; color:#fff;">wez</span>]] 17:25, 19 March 2014 (UTC) | |||
[[Category:Metagame Tools]] | [[Category:Metagame Tools]] |
Latest revision as of 17:25, 19 March 2014
User Scripts for Unix/Linux/Cygwin/*BSD
On this page you will find sample scripts for automating certain tasks related to Urban Dead. This is not cheating. Please don't use these scripts to Zerg.
Requirements:
On a basic level, you'll need a few things for these scripts to run. First, you need to be running unix/Linux/Cygwin/*BSD. If you're not doing that yet, these scripts can't help you. Secondly, all of these scripts depend on BASH. Why did I choose BASH? Because every modern OS has it, or can have it, and it takes about 30 seconds to learn to write code for it. There are other things you should also have; curl, sed, awk, grep, cat.
Login
The first step is to make sure that you are properly logged in. Curl is the only application that I've found that handles cookies properly.
login.sh:
#!/usr/bin/bash OUTPUTFILE="~/urbandead/page" CURL="/usr/bin/curl" COOKIEFILE="~/urbandead/cookies.txt" if [ -z $1 ] then echo "Usage: $0 <username> <password>" else $CURL -c $COOKIEFILE -o $OUTPUTFILE "http://urbandead.com/map.cgi?username=$1&password=$2" fi
Healing
When in a building with 200+ survivors, finding the right person in the drop down menu to heal is a pain in the butt. If you already know the ID of the person you want to heal, the following script can be very useful. I haven't tried it, but I suspect that it will also work when healing the undead.
heal.sh:
#!/usr/bin/bash OUTPUTFILE="~/urbandead/page" CURL="/usr/bin/curl" COOKIEFILE="~/urbandead/cookies.txt" if [ -z $1 ] then echo "Usage: $0 <numeric id of player to heal>" else $CURL -s -b $COOKIEFILE -o $OUTPUTFILE -d "target=$1" "http://urbandead.com/map.cgi?use-h" fi
Dropping pesky items
When working in a hospital, and looking for a first aid kit, some of the time you'll end up with a newspaper. The drop.sh script in conjunction with Items internal codes can be used to quickly drop a whole bunch of items. For example ./drop.sh n can be used to drop newspapers.
drop.sh:
#!/usr/bin/bash OUTPUTFILE="~/urbandead/page" CURL="/usr/bin/curl" COOKIEFILE="~/urbandead/cookies.txt" if [ -z $1 ] then echo "Usage: $0 <item code to drop>" else $CURL -s -b $COOKIEFILE -o $OUTPUTFILE -d "drop=$1" "http://urbandead.com/map.cgi" fi
Getting list of players and their current HP
Although this is not a script, it can be issued as a series of commands in a script-like way. You'll have to click to edit this page because wiki software doesn't deal well with the square brackets that are required for the regular expressions.
The purpose of these commands is to give you a file (page.hp-player-list) with a sorted listing of player IDs and the amount of HP they have. IE: people at the bottom of the list are in more urgent need of healing.
cat page | awk '/$/{printf "%s",$0; next}{print}' \ | sed -r -e "s/.*<table[^>]*>(.*)<table[^>]*>.*<\/table>(.*)<\/table>.*$/\1\2/" \ > page.lost-map-table cat page.lost-map-table | sed -r -e "s/<tr>(.*?)<\/tr>/\1/" > page.lost-tr cat page.lost-tr | sed -r -e 's/<td[^>]*>.*<\/td[^>]*><td[^>]*>(.*)<\/td[^>]*>/\1/' \ > page.lost-first-td cat page.lost-first-td | sed -r -e "s/(<\/form>) /\1\n/g" | sed -e "s/>.*/>/g" \ > page.commands-and-inv cat page.lost-map-table | sed -r -e "s/.*Also here are (.*\))\..*/\1/" \ | sed -r -e "s/, (<a href)/\n\1/g" > page.player-list cat page.player-list \ | sed -r -e "s/^<a href=\"profile.cgi\?id=([[:digit:]]+)\".*<\/a> \(([[:digit:]]+).*/\2 \1/" \ | sort -n -r | grep -v "^60" | grep -v "^50" > page.hp-player-list
User Scripts for Windows XP
As per the scripts for unix-based systems, it is possible to get some basic functionality via the Windows DOS Command Line. Especially useful is when these commands are used in a .bat file.
Requirements: You need the win32 version cURL, which you can easily find with an internet search engine. Try to find one that is already compiled- these may be referred to as "bin," or binary. Drop cURL.exe into a folder. This is the folder we will place our .bat files into. You'll also need Notepad and the ability to rename .txt files into .bat files, which is as easy as it sounds. Open Notepad, type in the necessary batch commands, and then save it as a .bat file. Double clicking this file will activate the script. To access these scripts with the Command Line, go to Start > Run > cmd.exe. Type "cd <directory you are keeping the script and curl.exe in>", press enter, then "<script's filename> <option 1> <option 2> <etc>", and press enter again.
Login
This is the Windows DOS version of the same script.
login.bat:
@ECHO OFF IF "%1" == "" ( ECHO "Usage: login <username> <password>") ELSE ( curl -c "cookies.txt" -o "page.html" "http://urbandead.com/map.cgi?username=%1&password=%2") PAUSE
Greasemonkey Scripts
There are a number of Greasemonkey scripts for UD on the External Links page.
Comments?
I've reserved a section of this page for comments, complaints, feedback, etc. If you want to request a script or more information, please do it below the horizontal line:
August 21th, 2008 - Hmmm does anyone happen to have the Sentinel Scripts?
March 19th, 2014 - I see this page has not been updated in a long time, but I have an idea that I would love to get working. My issue is when attempting the login the resulting output page says "Invalid username or password".
Now I have triple-checked those, yet login still fails. I was wondering if the Urban Dead login mechanism may have been changed to affect this? I checked the login form values are still "username" and "password", with no hidden inputs. I tried prepending the www subdomain too, just in case. Aside the fact that the '~' token does not expand (so I use the full path), I am at a loss on how to proceed.
And for the record, this is for a script I want to log in, grab the "since your last visit" messages and have me notified of any notable events. I certainly do not approve of automated players or zerging. I realize this will add to my IP hits, but find this more an exercise in see-if-it-works than something I need to have. --wez 17:25, 19 March 2014 (UTC)