SpawnSwitch Error...

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

Moderator: Forum Guards

SpawnSwitch Error...

Postby Allan » Sun Feb 12, 06 4:37 pm

Code: Select all
class SpawnButton expands AAPickupSet;

#exec OBJ LOAD FILE=Ambient
var() Class product;
Var() int CreditCost;

function Frob(actor Frobber, Inventory frobWith)
{
   local DeusExPlayer player;
   local Vector loc;
   local Pickup product;
   
   player = DeusExPlayer(Frobber);

   if (player != None)
   {

      if (player.Credits >= CreditCost)
      {
         PlaySound(sound'Beep5', SLOT_None);
         loc = Vector(Rotation) * CollisionRadius * 0.8;
         loc.Z -= CollisionHeight * 0.7;
         loc += Location;


         if (product != None)
         {
            product.Velocity = Vector(Rotation) * 100;
            product.bFixedRotationDir = True;
            product.RotationRate.Pitch = (32768 - Rand(65536)) * 4.0;
            product.RotationRate.Yaw = (32768 - Rand(65536)) * 4.0;
         }

         player.Credits -= CreditCost;
      }
      else
         player.ClientMessage("Insufficient Funds");
   }
}

Function Prebeginplay()
{ItemName="RPG Shop Summon Switch.";}


This is my spawnswitch code, it works, but i want it to summon a class settable in the properties, and it doesnt summon anything at the moment.(I havent added the code to, i dont know it...)

Can someone give me the code to make a summonable class that you can change in the properties plz :)
User avatar
Allan
Alpha
 
Posts: 4545
Joined: Wed Dec 21, 05 1:41 pm
Location: Northamptonshire, England.

Postby ~ô¿ô~Nobody~ » Sun Feb 12, 06 5:46 pm

er.. indeed.. where do you actually summon the class? :shock:


i.e.
something like
Code: Select all
product = Spawn(productClass,,,SpawnLocation);

i guess you get a load of accessed nones
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 Allan » Sun Feb 12, 06 6:23 pm

Where in the script?

In the script i borrowed it from (VendingMachine), it was after the line:
Code: Select all
loc += Location;


That code you gave me is what i used, but it doesn't allow variables in the class name place... It's so sad... :'(
User avatar
Allan
Alpha
 
Posts: 4545
Joined: Wed Dec 21, 05 1:41 pm
Location: Northamptonshire, England.

Postby ~ô¿ô~Nobody~ » Mon Feb 13, 06 7:42 pm

er.. sure you can use a class variable instead of a static class name :)

here's the code
Code: Select all
class SpawnButton expands AAPickupSet;

#exec OBJ LOAD FILE=Ambient
var() Class product;
Var() int CreditCost;

function Frob(actor Frobber, Inventory frobWith)
{
   local DeusExPlayer player;
   local Vector loc;
//   local Pickup product;  //you can definy local variables that have the same
                            //name like variables declared on the top but i do not recommend this
   //this will do the job
   //but keep in mind!
   //you just declared a variable, in there is no actor saved yet!
   local Pickup spawnProduct;
   
   player = DeusExPlayer(Frobber);

   if (player != None)
   {

      if (player.Credits >= CreditCost)
      {
         PlaySound(sound'Beep5', SLOT_None);
         loc = Vector(Rotation) * CollisionRadius * 0.8;
         loc.Z -= CollisionHeight * 0.7;
         loc += Location;


         //here you create an Actor of zhe class saved in the Product variable
         //and put it in the spawnProduct variable
         spawnProduct=Spawn(product,,,location);
         //now you can access the variable and communicate with the Actor saved in,
         //without getting accessed ones
         if (spawnProduct != None)
         {
            spawnProduct.Velocity = vector(Rotation) * 100;
            spawnProduct.bFixedRotationDir = True;
            spawnProduct.RotationRate.Pitch = (32768 - Rand(65536)) * 4.0;
            spawnProduct.RotationRate.Yaw = (32768 - Rand(65536)) * 4.0;
         }

         player.Credits -= CreditCost;
      }
      else
         player.ClientMessage("Insufficient Funds");
   }
}

Function Prebeginplay()
{
    ItemName="RPG Shop Summon Switch.";
}
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 Allan » Mon Feb 13, 06 11:10 pm

Hmm... All seems to be in order now. Thanks for bringing that variable with 2 meanings up, never noticed it :P

but... i get this error now. :

Call to 'Spawn': type mismatch in parameter 1

with "spawnProduct=Spawn(product,,,location); " highlighted... seems it doesnt like that code... :'(
User avatar
Allan
Alpha
 
Posts: 4545
Joined: Wed Dec 21, 05 1:41 pm
Location: Northamptonshire, England.

Postby ~ô¿ô~Nobody~ » Tue Feb 14, 06 4:58 pm

ahh yeah

the problem is most possibly
Code: Select all
var() Class product;


if you declare a variable that shall carry a class type, then you also need to specify which is the basic class type that the variable is able to contain

so cahnge it to
Code: Select all
var() Class<Actor> product;
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 Allan » Tue Feb 14, 06 5:09 pm

Hooray! After a slight bit of tweaking, it finally works :)

Thanks a million :D
User avatar
Allan
Alpha
 
Posts: 4545
Joined: Wed Dec 21, 05 1:41 pm
Location: Northamptonshire, England.


Return to Editing issues

Who is online

Users browsing this forum: No registered users and 48 guests