/    Sign up×
Community /Pin to ProfileBookmark

TPPCRPG auto log-in and attack script not working

This script logs into tppcrpg.net, starts a battle with this trainer, and automatically kills the first pokemon. Is there anything wrong with this that anyone sees? because I can’t get it to work properly. it automatically resets the battle to a gym battle. this has been bugging me all day because it should be so simple but i cant get it to work.

[code=php]
<?php
// this function gets the encryption key
// i think this might be the problem
// it works but then it adds some other part of the string to the end which
// makes the key useless
function get_encryption($string){
$position=strlen(‘name=”Encrypt” value=”‘)+strpos($string, ‘name=”Encrypt” value=”‘);
$length=strpos($string, ‘”><input type=”button” value=”Attack!” onclick=’)-$position;
$extraction=substr($string, $position, $length);
return $extraction;
}
// this function is repeated
function pokemanz(){
$ch = curl_init();
//login
curl_setopt($ch, CURLOPT_URL, ‘http://tppcrpg.net/login.php’);
curl_setopt($ch, CURLOPT_POST, 1);
//username and password
curl_setopt($ch, CURLOPT_POSTFIELDS, ‘LoginID=username&NewPass=pass’);
curl_setopt($ch, CURLOPT_COOKIEJAR, cookiefile);
curl_setopt($ch, CURLOPT_COOKIEFILE, cookiefile);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_exec($ch);
//select battle trainer
curl_setopt($ch, CURLOPT_URL, ‘http://tppcrpg.net/battle.php?Battle=Trainer&Against=1212849’);
$string=curl_exec($ch);
echo $string;
//keep attacking until someone faints
while (strpos($string, ‘fainted’)==FALSE) {
//find encryption key in $string
$encrypt=get_encryption($string);
echo $encrypt;
curl_setopt($ch, CURLOPT_URL, ‘http://tppcrpg.net/battle.php’);
//set move and encryption key
curl_setopt($ch, CURLOPT_POSTFIELDS, “Encrypt={$encrypt}&Move=FIREBLAST”);
$string=curl_exec($ch);
echo $string;
}

echo $string;
curl_close($ch);
}
//run script until i feel like stopping it (dont worry its on my own server)
while (1<2)
{
pokemanz();
}
?>
[/code]

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @chesemonkyloma spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...