Elite Diviner
- Joined
- Feb 27, 2012
- Messages
- 446
- Reaction score
- 46
Ok so i am working on a pvp script but i dont know javascript (well i do know the basics) so if somebody could help me debug/figure this out that would be great. One of the main things i need to figure out is how to send messages to the player being requested for a pvp match.
I am pretty sure the command works its the function that just needs to be finished. Also I still don't know how to use the database so that makes a bigger problem xD.
anyway here is my code so far:
Commands
Function:
I was also trying to add a check to keep players with extremely high lvl pokemon battle players with low levels but i am like 90% sure i completely got that wrong xD:
I am pretty sure the command works its the function that just needs to be finished. Also I still don't know how to use the database so that makes a bigger problem xD.
anyway here is my code so far:
Commands
Code:
if(str.indexOf("/reqpvp ") == 0 && pokemmo.Game.accountLevel >= 0) {
pokemmo.Connection.socket.emit("pvpPlayer",{ username : str.substr("/reqpvp ".length)});
pokemmo.Chat.resetChat();
pokemmo.Main.jq(pokemmo.Main.onScreenCanvas).focus();
return;
}
if(str.indexOf("/pvpreply ") == 0 && pokemmo.Game.accountLevel >= 0) {
pokemmo.Connection.socket.emit("pvpAcceptDecline",{ username : str.substr("/pvpreply ".length)});
pokemmo.Chat.resetChat();
pokemmo.Main.jq(pokemmo.Main.onScreenCanvas).focus();
return;
}
Code:
if(client.accountLevel >= 0) client.socket.on("pvpPlayer",function(data) {
pokemmo_s.GameServer.pvpPlayer(data.username);
}
);
if(client.accountLevel >= 0) client.socket.on("pvpAcceptDecline",function(data) {
pokemmo_s.GameServer.pvpPlayer(data.username);
});
Function:
Code:
var ispvp=false
pokemmo_s.GameServer.pvpAcceptDecline = function() {
if (ispvp=true){
return //something saying "This player is already being requested for pvp";
}else{
var $char = client.character;
if (str.indexOf("accept")){
return true;
}else{
return false;
}
}
}
pokemmo_s.GameServer.pvpPlayer = function(username) {
if (ispvp=true){
return ;//something saying "This player is already being requested for pvp";
}else{
//send a message about /pvpreply accept/decline
while (x<=60000){
x++;
$char.ispvp=true;
username.ispvp=true;
if(pokemmo_s.GameServer.pvpAcceptDecline==false){
$char.ispvp=false;
username.ispvp=false;
x=60000;
}else{
//initiate battle with player, check who wins and display instance announcement
}
}
$char.ispvp=false;
username.ispvp=false;
client.character.restorePokemon();
}
}
I was also trying to add a check to keep players with extremely high lvl pokemon battle players with low levels but i am like 90% sure i completely got that wrong xD:
Code:
var $char = client.character;
var mypvplevel=$char.pokemon[0].level+$char.pokemon[1].level+$char.pokemon[2].level+$char.pokemon[3].level+$char.pokemon[4].level+$char.pokemon[5].level;
var theirpvplevel=username.pokemon[0].level+username.pokemon[1].level+username.pokemon[2].level+username.pokemon[3].level+username.pokemon[4].level+username.pokemon[5].level
Last edited: