jhylands

trade.js

Jun 23rd, 2013
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //javascripts for trading in the game
  2. //array of your properties
  3. var Pyours = new Array();
  4. //array of their properties
  5. var Ptheirs = new Array();
  6. //Variable to hold the cash transpher +=>you gain -=>them gain
  7. var Transcash = 0;
  8. //variable to hold get out of jail free cards +=>you gain -=>them gain
  9. var Tliberty = 0;
  10. //add a property to the list they would be giving up in the trade
  11. function offerprop(id){
  12. if(Pyours[i]=False){
  13. Pyours[i]=True;
  14. }else{
  15. Pyours[i]=False;
  16. }
  17. }
  18. //add a property to the list of properties they would recive in a traid
  19. function requestprop(id){
  20. if(Ptheirs[i]=False){
  21. Ptheirs[i]=True;
  22. }else{
  23. Ptheirs[i]=False;
  24. }
  25. }
  26. //if the try to include a property they don't own
  27. function badoffer(){
  28. alert('You can only traid with properties you own and that are not built upon!')
  29. }
  30. function moremoney(){
  31. Transcash = Transcash + 100;
  32. if(Transcash>0){
  33. var x=document.getElementById("moneyfromme");
  34. x.innerHTML = 0;
  35. x=document.getElementById("moneytome");
  36. x.innerHTML = Transcash;
  37. }else{
  38. var x=document.getElementById("moneyfromme");
  39. x.innerHTML = Transcash*-1;
  40. x=document.getElementById("moneytome");
  41. x.innerHTML = 0;
  42. }
  43. }
  44. function lessmoney(){
  45. Transcash = Transcash - 100;
  46. if(Transcash>0){
  47. var x=document.getElementById("moneyfromme");
  48. x.innerHTML = 0;
  49. x=document.getElementById("moneytome");
  50. x.innerHTML = Transcash;
  51. }else{
  52. var x=document.getElementById("moneyfromme");
  53. x.innerHTML = Transcash*-1;
  54. x=document.getElementById("moneytome");
  55. x.innerHTML = 0;
  56. }
  57. }
  58. function generateprop(id1,id2,gid){
  59. //generate prop1 and prop2
  60. var prop1 = "";
  61. var prop2 = "";
  62. //cash transfure
  63. if(Transcash!=0){
  64. prop1 = "$" + Transcash + ";" ;
  65. prop2 = "$" + (-1 * Transcash) + ";";
  66. }
  67. //get out of jail transfure
  68. if(Tliberty>0){
  69. for(i=0;i<Tliberty;i++){
  70. prop2 = prop2 + "gooj;";
  71. }}
  72. if(Tliberty<0){
  73. for(i=0;i<Tliberty;i++){
  74. prop1 = prop1 + "gooj;";
  75. }}
  76. //property transpher
  77. for (i=0;i<39;i++){
  78.     if(Pyours[i]!=null){
  79.     prop1 = prop1 + "p" + i + ";";
  80.     }if(Ptheirs[i]!=null){
  81.     prop2 = prop2 + "p" + i + ";";
  82.     }
  83. }
  84.     //send request
  85.         var xmlhttp;
  86.     if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
  87.     xmlhttp=new XMLHttpRequest();
  88.     }
  89.     else{// code for IE6, IE5
  90.         xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  91.     }
  92.     xmlhttp.onreadystatechange=function(){
  93.     if (xmlhttp.readyState==4 && xmlhttp.status==200){
  94.         var resp;
  95.         resp=xmlhttp.responseText;
  96.     }
  97.     }
  98.     xmlhttp.open("GET","noti.php?id=" + gid + "&id1=" + id1 + "&id2=" + id2 + "acpt=False",true);
  99.     xmlhttp.send();
  100. }
  101. function trade(gid,uid){
  102. loading();
  103.                         var xmlhttp;
  104.                         if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
  105.                             xmlhttp=new XMLHttpRequest();
  106.                         }
  107.                         else{// code for IE6, IE5
  108.                             xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  109.                         }
  110.                             xmlhttp.onreadystatechange=function(){
  111.                             if (xmlhttp.readyState==4 && xmlhttp.status==200){
  112.                               var resp = xmlhttp.responseText;
  113.                                                         document.getElementById("the").innerHTML=resp;
  114.                             }
  115.                         }
  116.                         xmlhttp.open("GET","tradesfriend.php?gid=" + gid + "&uid=" + uid ,true);
  117.                         xmlhttp.send();
  118. }
  119. function splayerstraid(uid,id,gid){
  120. loading();
  121. var req = "tradingfloor.php?gid=" + gid  + "&uid=" + uid + "&id=" + id;
  122. var xmlhttp;
  123.                         if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
  124.                             xmlhttp=new XMLHttpRequest();
  125.                         }
  126.                         else{// code for IE6, IE5
  127.                             xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  128.                         }
  129.                             xmlhttp.onreadystatechange=function(){
  130.                             if (xmlhttp.readyState==4 && xmlhttp.status==200){
  131.                               var resp = xmlhttp.responseText;
  132.                                                         document.getElementById("the").innerHTML=resp;
  133.                             }
  134.                         }
  135.                         xmlhttp.open("GET",req,true);
  136.                         xmlhttp.send();
  137. }
  138. //code used in the tradesfriend script to make the pictures have a yellow border onmousover
  139. function createbd(id){
  140. $("#" + id).css({"border-style":"solid","border-width":"5px"});
  141. }
  142. function erasebd(id){
  143. $("#" + id).css({"color":"black","border":"0","border-color":"yellow"});
  144. }
Advertisement
Add Comment
Please, Sign In to add comment