Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   Quick help please (https://forums.graalonline.com/forums/showthread.php?t=74259)

PrinceOfKenshin 05-28-2007 11:53 PM

Quick help please
 
Ok i'm trying to fix this script but i am having a problem.
NPC Code:
  this.hosplvls = {"mafia_hospital-room1.nw","mafia_hospital-room2.nw","mafia_hospital-room3.nw","mafia_hospital-room4.nw","mafia_hospital-room5.nw","mafia_hospital-room6.nw","mafia_hospital-room7.nw","mafia_hospital-room8.nw","mafia_hospital-room9.nw","mafia_hospital-room10.nw","mafia_hospital-room11.nw","mafia_hospital-room12.nw","mafia_hospital-room13.nw","mafia_hospital-room14.nw"}; 
this.coords0 = {{28.75,44.5},{42.5,45.5}};
this.coords1 = {{24,15.5},{45.125,15.5},{57.75,15.5},{10.25,43.5} ,{40.25,47.5}};
this.coords2 = {{29.1875,43.5},{42.6875,43.75}};
this.coords3 = {{29.25,43},{42.6875,43.6875}};
this.coords4 = {{28.5625,44.25},{42.9375,44.25}};
this.coords5 = {{28.9375,44.0625},{42.6875,44.0625}};
this.coords6 = {{29,44.5},{42.6875,44.5}};
this.coords7 = {{28.5,44.25},{42.75,44.5}};
this.coords8 = {{28.5625,44.25},{42.4375,44.5}};
this.coords9 = {{29.0625,44.25},{42.5625,44.25}};
this.coords10 = {{28.9375,44.25},{42.4375,44.5}};
this.coords11 = {{28.9375,44.5},{42.9375,44.5}};
this.coords12 = {{28.9375,44.25},{44.5,44.125}};
this.coords13 = {{28.5625,44.25},{42.6875,44.5}};
this.warplvl = int(random(0,1));
this.warpxy = int(random(0,5));
setlevel2(this.hosplvls[this.warplvl],makevar("this.coords" @ this.warplvl)[this.warpxy][0],makevar("this.coords" @ this.warplvl)[this.warpxy][1]);




What it is for is when you die you get randomly warped to a hospital room. But it warps the player to the corner of the level not where the cord is. Can Someone help me?

Inverness 05-29-2007 12:13 AM

Are you checking for the condition that the random index is 3 and yet you have only two coordinate sets for that level? And please use PHP tags next time ^_^

cbk1994 05-29-2007 12:41 AM

Try something like this ... I didn't really understand what you were doing in your code.

PHP Code:

function warpToHosptial()
{
  
this.locations = {
                          { 
"level1.nw"x},
                          { 
"level2.nw"x},
                          { 
"level3.nw"x}
                        };
  
temp.ran random0this.locations.size() );
  
temp.coords this.locations[temp.ran];
  
player.setlevel2temp.coords[0], temp.coords[1], temp.coords[2] );



PrinceOfKenshin 05-29-2007 12:41 AM

Quote:

Originally Posted by Inverness (Post 1312741)
Are you checking for the condition that the random index is 3 and yet you have only two coordinate sets for that level? And please use PHP tags next time ^_^

i just don't know what to do :cry: lol i'm still new to scripting

cbk1994 05-29-2007 12:43 AM

Read my post above, in case you didn't see it ... You posted several seconds after I did.

PrinceOfKenshin 05-29-2007 12:50 AM

Quote:

Originally Posted by cbkbud (Post 1312752)
Try something like this ... I didn't really understand what you were doing in your code.

PHP Code:

function warpToHosptial()
{
  
this.locations = {
                          { 
"level1.nw"x},
                          { 
"level2.nw"x},
                          { 
"level3.nw"x}
                        };
  
temp.ran random0this.locations.size() );
  
temp.coords this.locations[temp.ran];
  
player.setlevel2temp.coords[0], temp.coords[1], temp.coords[2] );



ok you are just putting the levels and x,y's in one flag so that it's easier to call them randomly?

PrinceOfKenshin 05-29-2007 12:52 AM

but i have more than one x,y for the level

DustyPorViva 05-29-2007 01:01 AM

Why do you have multiple sets of coordinates per each this.coords*?
Are they all the possible warp coordinates for each hospital warp level?

Try this:
PHP Code:

this.hosplvls = {"mafia_hospital-room1.nw","mafia_hospital-room2.nw","mafia_hospital-room3.nw","mafia_hospital-room4.nw","mafia_hospital-room5.nw","mafia_hospital-room6.nw","mafia_hospital-room7.nw","mafia_hospital-room8.nw","mafia_hospital-room9.nw","mafia_hospital-room10.nw","mafia_hospital-room11.nw","mafia_hospital-room12.nw","mafia_hospital-room13.nw","mafia_hospital-room14.nw"}; 
this.coords0 = {{28.75,44.5},{42.5,45.5}}; 
this.coords1 = {{24,15.5},{45.125,15.5},{57.75,15.5},{10.25,43.5} ,{40.25,47.5}}; 
this.coords2 = {{29.1875,43.5},{42.6875,43.75}};
this.coords3 = {{29.25,43},{42.6875,43.6875}};
this.coords4 = {{28.5625,44.25},{42.9375,44.25}};
this.coords5 = {{28.9375,44.0625},{42.6875,44.0625}};
this.coords6 = {{29,44.5},{42.6875,44.5}};
this.coords7 = {{28.5,44.25},{42.75,44.5}};
this.coords8 = {{28.5625,44.25},{42.4375,44.5}};
this.coords9 = {{29.0625,44.25},{42.5625,44.25}};
this.coords10 = {{28.9375,44.25},{42.4375,44.5}};
this.coords11 = {{28.9375,44.5},{42.9375,44.5}};
this.coords12 = {{28.9375,44.25},{44.5,44.125}};
this.coords13 = {{28.5625,44.25},{42.6875,44.5}};
this.warplvl int(random(0,this.hosplvls.length()));
this.newcoords "this.coords" this.warplvl;
this.warpxy int(random(0,this.newcoords.length()));
setlevel2(this.hosplvls[this.warplvl],this.newcoords[this.warpxy][0],this.newcoords[this.warpxy][1]); 


cbk1994 05-29-2007 01:10 AM

Quote:

Originally Posted by PrinceOfKenshin (Post 1312760)
but i have more than one x,y for the level

Then add the level more than once ...

PHP Code:

function warpToHosptial()
{
  
this.locations = {
                          { 
"level1.nw"1012 },
                          { 
"level1.nw"2056 },
                          { 
"level1.nw"3019 },
                          { 
"level1.nw"4023 },
                          { 
"level1.nw"5015 }
                        };
  
temp.ran random0this.locations.size() );
  
temp.coords this.locations[temp.ran];
  
player.setlevel2temp.coords[0], temp.coords[1], temp.coords[2] );



PrinceOfKenshin 05-29-2007 01:15 AM

It still does the same thing it warps the player to the corner of the level

DustyPorViva 05-29-2007 01:21 AM

Well that means it's returning 0's for the coordinates, so something must be in getting the numbers from the arrays.

I think cbkbud's is the best way to go, and a lot easier for adding/removing levels/coordinates.

PrinceOfKenshin 05-29-2007 01:22 AM

Could i just put all the coords in this.coords0 and this.coords1?

PrinceOfKenshin 05-29-2007 01:32 AM

xD wow i'm stupid i found the problem thanks for your guys help


All times are GMT +2. The time now is 05:25 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.