That'll give you an error. Try using getrandom like I didAlso ! Is the not operand in torquescript. So !a is not a.If you wanted to do 'if player is not in minigame' you'd do if(!isobject(%client.minigame)) as opposed to if(isobject(%client.minigame))
%array[1] = "-29.6914 6.556 9.68498";%array[2] = "-19.6014 7.51866 3.68498";$spawnVec = %array[getrandom(1,2)];package YourPackageif(!isobject(%client.minigame))then { function GameConnection::spawnPlayer(%this) { Parent::spawnPlayer(%this); %this.player.setTransform($spawnVec); }}activatePackage(YourPackage);
Yes on the array.The if statement must be within the function. Also there's no then statement in torquescript
Also make sure the parent part stays outside of the if statement. Parent ensures that all game code attached to the function is called. If you put it inside an if statement, you'll never spawn if the condition is false
%array[1] = "-29.6914 6.556 9.68498";%array[2] = "-19.6014 7.51866 3.68498";$spawnVec = %array[getrandom(1,2)];package YourPackage { if(!isobject(%client.minigame)); function GameConnection::spawnPlayer(%this) { Parent::spawnPlayer(%this); %this.player.setTransform($spawnVec); }}activatePackage(YourPackage);
%array[1] = "-29.6914 6.556 9.68498";%array[2] = "-19.6014 7.51866 3.68498";$spawnVec = %array[getrandom(1,2)];package YourPackage{ function GameConnection::spawnPlayer(%this) { Parent::spawnPlayer(%this); If(!isobject(%this.minigame)) %this.player.setTransform($spawnVec); }};activatePackage(YourPackage);
Here I'll justCode: [Select]%array[1] = "-29.6914 6.556 9.68498";%array[2] = "-19.6014 7.51866 3.68498";$spawnVec = %array[getrandom(1,2)];package YourPackage{ function GameConnection::spawnPlayer(%this) { Parent::spawnPlayer(%this); If(!isobject(%this.minigame)) %this.player.setTransform($spawnVec); }};activatePackage(YourPackage);
thats how mine looks like lol, gonna testeeeeee
it's a bit different. In the future you should read up a bit on torquescript syntax if you plan on doing stuff like this You learn a lot when you learn
Make sure you change the package name from your package to something specific, like uh... mapSpawnPackageSomeone else's add-on might conflict if they use the same name
%array[1] = 5;%array[2] = 88;announce(%array[getrandom(1,2)]);
As a token of appreciation heres a pic what I was working on!https://imgur.com/pSqTdcH.png
I know you probably did it this way for simplicity's sake. But I feel I should mention that arrays usually start at "0" by convention. So it "should" start at %array[0] instead of %array[1]. That also means %array[getrandom(1,2)] would instead be %array[getrandom(0,1)].It good to see people making maps again! What's the theme, by the way?