ATM

The best and quickest support by a group of top-notch editing specialists, guaranteed!

Moderator: Forum Guards

ATM

Postby MainMan » Wed Feb 08, 06 8:53 pm

I have tried making an ATM for my RPG, which links to the bank safes. In each safe there is a 'banktakeout' actor, which checks how much money there is in the safe. Now this code works fine in SP, but in MP when i frob the ATM, the window doesn't appear.

Any help appreciated.

Here are all the pieces of code:


Code: Select all
class MMRPGATM extends Computers;

var MMRPGATMWindow termwindow;
Var deusexPlayer Player;
var BankTakeOut Safe;
var DeusExRootWindow root;
var MMRPGCreditCard CredCard;

function Frob(Actor Frobber, Inventory frobWith)
{
local BankTakeOut TakeOut;
local MMRPGCreditCard Card;

   Player = DeusExPlayer(Frobber);

   foreach AllActors(class'BankTakeOut', TakeOut)
   {
      If (TakeOut.SafeOwner == Player)
      {
         Safe = TakeOut;
      }
   }      
   
   foreach AllActors(class'MMRPGCreditCard', Card)
   {
      If (Card.Owner == Player)
      {
         CredCard = Card;
      }
   }   

   if( Player != None )
   {
      root = DeusExRootWindow(Player.rootWindow);
      
      if (root != None)
      {
         termwindow = MMRPGATMWindow(root.InvokeUIScreen(Class'MMRPGATMWindow'));
      
         termwindow.SetATM(Self);
         termwindow.SetVault(Safe);
         termwindow.SetCard(CredCard);
         termwindow.SetCompOwner(Self);
         termwindow.ShowFirstScreen();
         Super.Frob(Frobber, frobWith);

      }
   }
}


Function WithDrawTen()
{
   Safe.TakeOut10();
}

Function WithDrawFive()
{
   Safe.TakeOut5();
}

Function WithDrawOne()
{
   Safe.TakeOut1();
}



defaultproperties
{
     bInvincible=True
     ItemName="CashPoint"
     bPushable=False
     Physics=PHYS_None
     Mesh=LodMesh'DeusExDeco.ATM'
     SoundRadius=8
     SoundVolume=255
     AmbientSound=Sound'DeusExSounds.Generic.ElectronicsHum'
     CollisionHeight=40.000000
     bCollideWorld=False
     Mass=400.000000
     Buoyancy=200.000000
     BindName="ComputerATM"
}






Code: Select all
class MMRPGATMScreen extends ComputerUIWindow;

//var int MoneyInBank;
var BankTakeOut Safe;
var MMRPGATM MainATM;
var DeusExPlayer player;
var MMRPGCreditCard CredCard;


var MenuUIActionButtonWindow btnOne;
var MenuUIActionButtonWindow btnFive;
var MenuUIActionButtonWindow btnTen;
var MenuUILabelWindow        winWarning;
var MenuUILabelWindow        winLoginInfo;
var MenuUISmallLabelWindow   winLoginError;
var MenuUIEditWindow         editAccount;
var MenuUIEditWindow         editPIN;

var TextWindow InBankText;
var TextWindow InHandText;

var ATM atmOwner;      // what ATM owns this window?


var localized String ButtonLabelOne;
var localized String ButtonLabelFive;
var localized String ButtonLabelTen;
var localized String AccountLabel;
var localized String PinLabel;
var localized String LoginInfoText;
var localized String WarningText;
var localized String StatusText;
var localized String InvalidLoginMessage;

// ----------------------------------------------------------------------
// InitWindow()
//
// Initialize the Window
// ----------------------------------------------------------------------

event InitWindow()
{
   Super.InitWindow();
   EnableButtons();
}


// ----------------------------------------------------------------------
// CreateControls()
// ----------------------------------------------------------------------

function CreateControls()
{
   Super.CreateControls();

   btnOne = winButtonBar.AddButton(ButtonLabelOne, HALIGN_Right);
   btnFive  = winButtonBar.AddButton(ButtonLabelFive,  HALIGN_Right);
   btnTen  = winButtonBar.AddButton(ButtonLabelTen,  HALIGN_Right);


   CreateMenuLabel(10, 111, AccountLabel, winClient);
   CreateMenuLabel(10, 141, PINLabel, winClient);


   InBankText = TextWindow(NewChild(Class'TextWindow'));
   InBankText.SetPos(140, 166);
   InBankText.SetSize(140, 12);
   InBankText.SetTextMargins(0, 0);
   InBankText.SetTextAlignments(HALIGN_Center, VALIGN_Center);
   InBankText.SetFont(Font'FontMenuSmall_DS');
   InBankText.SetTextColorRGB(255, 255, 255);

   InHandText = TextWindow(NewChild(Class'TextWindow'));
   InHandText.SetPos(140, 199);
   InHandText.SetSize(140, 12);
   InHandText.SetTextMargins(0, 0);
   InHandText.SetTextAlignments(HALIGN_Center, VALIGN_Center);
   InHandText.SetFont(Font'FontMenuSmall_DS');
   InHandText.SetTextColorRGB(255, 255, 255);


   CreateWarningWindow();
   CreateLoginInfoWindow();
   CreateLoginErrorWindow();

   winTitle.SetTitle(Title);
   winStatus.SetText(StatusText);

   EnableButtons();
   CheckBalance();
}

// ----------------------------------------------------------------------
// UpdateStatus()
// ----------------------------------------------------------------------

function UpdateStatus()
{
   // Update the title, texture and description
   winTitle.SetTitle(Title);
}

// ----------------------------------------------------------------------
// CreateWarningWindow()
// ----------------------------------------------------------------------

function CreateWarningWindow()
{
   winWarning = MenuUILabelWindow(winClient.NewChild(Class'MenuUILabelWindow'));

   winWarning.SetPos(8, 10);
   winWarning.SetSize(273, 50);
   winWarning.SetTextAlignments(HALIGN_Center, VALIGN_Center);
   winWarning.SetTextMargins(0, 0);
   winWarning.SetText(WarningText);
}

// ----------------------------------------------------------------------
// CreateLoginInfoWindow()
// ----------------------------------------------------------------------

function CreateLoginInfoWindow()
{
   winLoginInfo = MenuUILabelWindow(winClient.NewChild(Class'MenuUILabelWindow'));

   winLoginInfo.SetPos(8, 66);
   winLoginInfo.SetSize(273, 31);
   winLoginInfo.SetTextAlignments(HALIGN_Center, VALIGN_Center);
   winLoginInfo.SetTextMargins(0, 0);
   winLoginInfo.SetText(LoginInfoText);
}


function CreateLoginErrorWindow()
{
   winLoginError = MenuUISmallLabelWindow(winClient.NewChild(Class'MenuUISmallLabelWindow'));

   winLoginError.SetPos(80, 172);
   winLoginError.SetSize(287, 25);
   winLoginError.SetTextAlignments(HALIGN_Left, VALIGN_Center);
   winLoginError.SetTextMargins(0, 0);
}


function SetNetworkTerminal(NetworkTerminal newTerm)
{
   Super.SetNetworkTerminal(newTerm);

   // If the user already hacked this computer, then set the
   // "Hack" button to "Return"
   if (winTerm != None)
      winTerm.SetHackButtonToReturn();

}


function bool ButtonActivated( Window buttonPressed )
{
   local bool bHandled;

   bHandled = True;

   switch( buttonPressed )
   {
      case btnOne:
         MainATM.WithDrawOne();
         EnableButtons();
         CheckBalance();
         break;

      case btnFive:
         MainATM.WithDrawFive();
         EnableButtons();
         CheckBalance();
         break;

      case btnTen:
         MainATM.WithDrawTen();
         EnableButtons();
         CheckBalance();
         break;
   }

   if (!bHandled)
      bHandled = Super.ButtonActivated(buttonPressed);

   return bHandled;
}





event bool EditActivated(window edit, bool bModified)
{
   return True;
}


event bool TextChanged(window edit, bool bModified)
{
   EnableButtons();
   CheckBalance();

   return False;
}

function SetATM(MMRPGATM newATM)
{
   MainATM = newATM;

   EnableButtons();
   CheckBalance();
}

function SetVault(BankTakeOut newVault)
{
   Safe = newVault;

   EnableButtons();
   CheckBalance();
}

function SetCard(MMRPGCreditCard newCard)
{
   CredCard = newCard;

   EnableButtons();
   CheckBalance();
}



function EnableButtons()
{
   if (Safe.CanTakeOut10())
      btnTen.EnableWindow(True);
   else
      btnTen.EnableWindow(False);


   if (Safe.CanTakeOut5())
      btnFive.EnableWindow(True);
   else
      btnFive.EnableWindow(False);


   if (Safe.CanTakeOut1())
      btnOne.EnableWindow(True);
   else
      btnOne.EnableWindow(False);

}


function CheckBalance()
{
   local float MoneyInBank;
   local float MoneyInHand;

   Safe.CheckBalance();
   MoneyInBank = Safe.MoneyInBank;
   InBankText.SetText(String(Int(MoneyInBank)) $ " c.");

   MoneyInHand = CredCard.CreditAmount;
   InHandText.SetText(String(Int(MoneyInHand)) $ " c.");
}





defaultproperties
{
     AccountLabel="Money In Vault:"
     PinLabel="Money On Card:"
     LoginInfoText="Your account balance:"
     WarningText="SELECT THE NOTES TO WITHDRAW FROM YOUR BANK VAULT"
     StatusText="MMRPG//BANK//TERMINAL:3902.9571[login]"
     InvalidLoginMessage="NO MORE MONEY"
     ButtonLabelOne="Takeout 1c"
     ButtonLabelFive="Takeout 5c"
     ButtonLabelTen="Takeout 10c"
     Title="MMRPG Banking System"
     ClientWidth=303
     ClientHeight=231
     verticalOffset=30
     clientTextures(0)=Texture'DeusExUI.UserInterface.ComputerGBSLogonBackground_1'
     clientTextures(1)=Texture'DeusExUI.UserInterface.ComputerGBSLogonBackground_2'
     textureRows=1
     textureCols=2
     bAlwaysCenter=True
     statusPosY=206
}







Code: Select all
class MMRPGATMWindow extends NetworkTerminal;

var BankTakeOut Safe;
var MMRPGATM MainATM;
var MMRPGCreditCard CredCard;


function CloseScreen(String action)
{
   Super.CloseScreen(action);


   if (action == "LOGOUT")
   {
      CloseScreen("EXIT");
   }
   else if (action == "LOGIN")
   {
      CloseScreen("EXIT");
   }
   else if (action == "ATMDISABLED")
   {
      CloseScreen("EXIT");
   }
}

function ShowScreen(Class<ComputerUIWindow> newScreen)
{
   // First close any existing screen
   if (winComputer != None)
   {
      winComputer.Destroy();
      winComputer = None;
   }

   // Now invoke the new screen
   if (newScreen != None)
   {
      winComputer = ComputerUIWindow(NewChild(newScreen));
      winComputer.SetWindowAlignments(HALIGN_Center, VALIGN_Center);
      winComputer.SetNetworkTerminal(Self);   
      winComputer.SetCompOwner(compOwner);

      MMRPGATMScreen(WinComputer).SetATM(MainATM);
      MMRPGATMScreen(WinComputer).SetVault(Safe);
      MMRPGATMScreen(WinComputer).SetCard(CredCard);
      MMRPGATMScreen(WinComputer).EnableButtons();
      MMRPGATMScreen(WinComputer).CheckBalance();
      winComputer.Lower();
   }
}




function SetATM(MMRPGATM newATM)
{
   MainATM = newATM;
}

function SetVault(BankTakeOut newVault)
{
   Safe = newVault;
}

function SetCard(MMRPGCreditCard newcard)
{
   CredCard = newCard;
}



defaultproperties
{
   bUsesHackWindow=False
   FirstScreen=Class'Contender.MMRPGATMScreen'
}






Code: Select all
class BankTakeOut extends Decoration;

var(Events) name BankName;
var DeusExPlayer SafeOwner;
var MMRPGCreditCard CredCard;
var int MoneyInBank;


Function CheckBalance()
{
   local MMRPGCreditsProjectileTen Cred;
   local MMRPGCreditsProjectileFive Cred2;
   local MMRPGCreditsProjectile Cred3;
   local MMRPGCreditCard Card;

   MoneyInBank = 0;

   foreach VisibleActors(class'MMRPGCreditsProjectileTen', Cred, CollisionRadius)
   {
      MoneyInBank += 10;
   }

   foreach VisibleActors(class'MMRPGCreditsProjectileFive', Cred2, CollisionRadius)
   {
      MoneyInBank += 5;
   }

   foreach VisibleActors(class'MMRPGCreditsProjectile', Cred3, CollisionRadius)
   {
      MoneyInBank += 1;
   }


}

Function bool CanTakeOut10()
{
   local MMRPGCreditsProjectileTen Cred;
   local MMRPGCreditCard Card;

   Cred = None;

   foreach VisibleActors(class'MMRPGCreditsProjectileTen', Cred, CollisionRadius)
   {
      If(Cred != None)
      {
         foreach AllActors(class'MMRPGCreditCard', Card)
         {
            if (Card.Owner == SafeOwner)
            {
               CredCard = Card;
               return true;
            }
         }
      }
   }
   return false;
}

Function bool CanTakeOut5()
{
   local MMRPGCreditsProjectileFive Cred;
   local MMRPGCreditCard Card;

   Cred = None;

   foreach VisibleActors(class'MMRPGCreditsProjectileFive', Cred, CollisionRadius)
   {
      If(Cred != None)
      {
         foreach AllActors(class'MMRPGCreditCard', Card)
         {
            if (Card.Owner == SafeOwner)
            {
               CredCard = Card;
               return true;
            }
         }
      }
   }
   return false;
}

Function bool CanTakeOut1()
{
   local MMRPGCreditsProjectile Cred;
   local MMRPGCreditCard Card;

   Cred = None;

   foreach VisibleActors(class'MMRPGCreditsProjectile', Cred, CollisionRadius)
   {
      If(Cred != None)
      {
         foreach AllActors(class'MMRPGCreditCard', Card)
         {
            if (Card.Owner == SafeOwner)
            {
               CredCard = Card;
               return true;
            }
         }
      }
   }
   return false;
}

Function TakeOut10()
{
   local MMRPGCreditsProjectileTen Cred;
   local int CheckInt;

   //Thanks to [A]lex for checkint part!

   CheckInt = 0;
   if (CanTakeOut10())
   {
      foreach VisibleActors(class'MMRPGCreditsProjectileTen', Cred, CollisionRadius)
      {
         if(CheckInt == 0)
         {
            Cred.Destroy();
            CredCard.CreditAmount += 10;
            CheckInt = 1;
         }
      }
   }
}

Function TakeOut5()
{
   local MMRPGCreditsProjectileFive Cred;
   local int CheckInt;

   //Thanks to [A]lex for checkint part!

   CheckInt = 0;
   if (CanTakeOut5())
   {
      foreach VisibleActors(class'MMRPGCreditsProjectileFive', Cred, CollisionRadius)
      {
         if(CheckInt == 0)
         {
            Cred.Destroy();
            CredCard.CreditAmount += 5;
            CheckInt = 1;
         }
      }
   }
}


Function TakeOut1()
{
   local MMRPGCreditsProjectile Cred;
   local int CheckInt;

   //Thanks to [A]lex for checkint part!

   CheckInt = 0;
   if (CanTakeOut1())
   {
      foreach VisibleActors(class'MMRPGCreditsProjectile', Cred, CollisionRadius)
      {
         if(CheckInt == 0)
         {
            Cred.Destroy();
            CredCard.CreditAmount += 1;
            CheckInt = 1;
         }
      }
   }
}


defaultproperties
{
     bHidden=True
     Physics=PHYS_None
     DrawType=DT_Sprite
     Texture=Texture'Engine.S_Inventory'
     DrawScale=1.000000
     CollisionRadius=43.000000
     CollisionHeight=40.000000
     Mass=0.000000
     Buoyancy=0.000000
     bBlockActors=False
     bBlockPlayers=False
     bCollideActors=False
     bCollideWorld=False
     bProjTarget=False
}
<center>ty m7
</center>
User avatar
MainMan
<i>Tru' Playa' Fer Defs</i>
 
Posts: 4655
Joined: Sun Jun 05, 05 7:38 am
Location: London, UK

Postby Gishank » Thu Feb 09, 06 5:31 pm

[OffTopic]Erm, if it's only going to be used in MP why not make it MPOnly?
Image
Gishank
Forum Super Hero
 
Posts: 4235
Joined: Sun Aug 28, 05 9:17 am
Location: London, England.

Postby Wasted » Thu Feb 09, 06 6:42 pm

These are top-notch editing specialists I guess yes?
FFS
User avatar
Wasted
Forum Hero
 
Posts: 2861
Joined: Sun Oct 30, 05 6:29 pm
Location: 1337 14ND

Postby MainMan » Thu Feb 09, 06 6:55 pm

~Wasted~ wrote:These are top-notch editing specialists I guess yes?
yeah lol. Klop is about as top-notch as you can get,
<center>ty m7
</center>
User avatar
MainMan
<i>Tru' Playa' Fer Defs</i>
 
Posts: 4655
Joined: Sun Jun 05, 05 7:38 am
Location: London, UK

Postby ~ô¿ô~Nobody~ » Thu Feb 09, 06 6:56 pm

<~>K}Ã?Ã?<~> wrote:[OffTopic]Erm, if it's only going to be used in MP why not make it MPOnly?

klop...

you can't just set some global variable like bUsedForMPMode

basically EVERYTHING that works in MP works in SP too (if the code wasn't explicitly coded not to work in SP)
but everything that works in SP doesn#t necessarily need to work in MP
because in MP exists something that doesn't exist in SP
and that is networking
..so, which actor gets replicated, what functions can a client call on the server, what functions can a server call on the client etc..

MainMan, a userinterface shall appear on the client's display
this means you must make a function which the server can call on the client to open a user interface
Nobody is perfect...
------------------------------
Longc[A]t wrote:I still think Dae is a russian spambot.

~[A]Daedalus~ wrote:There will be a day when my patience goes away and you, along with all who rant with you, will get banned.

ô¿ô¥[GODZ]¥NOCHANC wrote:I can ban any one I want ANY time I want. You have no rights here.
User avatar
~ô¿ô~Nobody~
Alpha
 
Posts: 2520
Joined: Fri Dec 31, 04 3:20 pm
Location: Proclarush Taonas

Postby MainMan » Thu Feb 09, 06 7:14 pm

So i need to check if Role=ROLE_authority, and then call the window?

Btw, i now have a custom player class, if that could make it any easier?
<center>ty m7
</center>
User avatar
MainMan
<i>Tru' Playa' Fer Defs</i>
 
Posts: 4655
Joined: Sun Jun 05, 05 7:38 am
Location: London, UK

Postby ~ô¿ô~Nobody~ » Thu Feb 09, 06 7:27 pm

yeah an own playerclass can make it easier because of the following issue...

in the replication block of every class you can definy which of your declared functions shall get replicated in any way
Code: Select all
replication
{
    //basic server -> client function call
    reliable if(ROLE == ROLE_Authority)
      someFunction;
}

however.. even if you defiied such replication rules it can just work if the actor where you definied this is owned by some player (either directly or indirectly)

in the case that you write some replication rules in the playerclass they will ALWAYS work because the player-actor represents a player
Nobody is perfect...
------------------------------
Longc[A]t wrote:I still think Dae is a russian spambot.

~[A]Daedalus~ wrote:There will be a day when my patience goes away and you, along with all who rant with you, will get banned.

ô¿ô¥[GODZ]¥NOCHANC wrote:I can ban any one I want ANY time I want. You have no rights here.
User avatar
~ô¿ô~Nobody~
Alpha
 
Posts: 2520
Joined: Fri Dec 31, 04 3:20 pm
Location: Proclarush Taonas

Postby Gishank » Thu Feb 09, 06 7:46 pm

Look, [A]Nobody i'm not an idiot this is the code which i meen for only MP.
Code: Select all
class Code extends Coding;

var bool bMPOnly;

function PostBeginPlay()
{
//destroy if in SP
if ( Level.NetMode == NM_StandAlone && bMPOnly)
   Destroy();
}
function ChargedPickupBegin(DeusExPlayer player)
{
local DeusExWeapon wep;
local Actor act;

(Extra shh here.)

Defaultproperties
{
bMPOnly=True
}
Image
Gishank
Forum Super Hero
 
Posts: 4235
Joined: Sun Aug 28, 05 9:17 am
Location: London, England.

Postby MainMan » Thu Feb 09, 06 7:50 pm

No klop, you just proved yourself to be an idiot.

~[A]Nobody~ wrote:basically EVERYTHING that works in MP works in SP too (if the code wasn't explicitly coded not to work in SP)



And, more importantly, nowhere in my code is anything like your mponly thing.
<center>ty m7
</center>
User avatar
MainMan
<i>Tru' Playa' Fer Defs</i>
 
Posts: 4655
Joined: Sun Jun 05, 05 7:38 am
Location: London, UK

Postby Gishank » Thu Feb 09, 06 7:52 pm

I'm using it as an example also if you read [A]Nobodys post carefully and then read my post you will see he is reffering to me as an idiot.
Image
Gishank
Forum Super Hero
 
Posts: 4235
Joined: Sun Aug 28, 05 9:17 am
Location: London, England.

Postby Wasted » Thu Feb 09, 06 7:53 pm

<~>K}Ã?Ã?<~> wrote:Look, [A]Nobody i'm not an idiot this is the code


:lol: Couldve fooled me!
FFS
User avatar
Wasted
Forum Hero
 
Posts: 2861
Joined: Sun Oct 30, 05 6:29 pm
Location: 1337 14ND

Postby MainMan » Thu Feb 09, 06 8:02 pm

Ok so Nobody, which class do i need to set the replication for (ATM, terminal, or screen?) And are you saying it needs to be called from the player?
<center>ty m7
</center>
User avatar
MainMan
<i>Tru' Playa' Fer Defs</i>
 
Posts: 4655
Joined: Sun Jun 05, 05 7:38 am
Location: London, UK

Postby Gishank » Thu Feb 09, 06 8:22 pm

:roll: :x :twisted: :!:
Image
Gishank
Forum Super Hero
 
Posts: 4235
Joined: Sun Aug 28, 05 9:17 am
Location: London, England.

Postby ~ô¿ô~Nobody~ » Thu Feb 09, 06 8:25 pm

ok, here an example if you do it without playerclass but with an owning player..

in the function frob of your ATM..
where there's the part with
Code: Select all
   if( Player != None )
   {
    //code
   }


here you can't open the user interface sine the function frob is serverside and opening a window on the server is quite senseless

so there you need to do some steps

at first.. for the case that the player != none
set the player as ATM's owner
Code: Select all
SetOwner(Player);


now right after that call a server -> client function (which you will need to definy first)
for example

for example
Code: Select all
clientOpenWindow();


now at the top of the class you still need to definy the replication rules
in this case it's just one function which you need to specify
Code: Select all
replication
{
    reliable if(ROLE == ROLE_Authority)
      clientOpenWindow;
}



now when you definy the function clientOpenWindow
you get the player by something like DeusExPlayer(Owner)
Owner is a constant native variable declared in the Actor class (which you assigned over the native function SetOwner before)
and with the gotten player you can now do the window initalizing stuff that you used to have in the function frob before[/code]
Nobody is perfect...
------------------------------
Longc[A]t wrote:I still think Dae is a russian spambot.

~[A]Daedalus~ wrote:There will be a day when my patience goes away and you, along with all who rant with you, will get banned.

ô¿ô¥[GODZ]¥NOCHANC wrote:I can ban any one I want ANY time I want. You have no rights here.
User avatar
~ô¿ô~Nobody~
Alpha
 
Posts: 2520
Joined: Fri Dec 31, 04 3:20 pm
Location: Proclarush Taonas


Return to Editing issues

Who is online

Users browsing this forum: No registered users and 39 guests