Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Question about with (getplayer) (https://forums.graalonline.com/forums/showthread.php?t=33792)

Googi 07-19-2002 02:43 AM

Question about with (getplayer)
 
Is it possible to use with (getplayer) to get a player who has a certain distance from the current player?

Like this...

NPC Code:

while (oncar) {
with (getplayer(playerx-1)){
hurt 2;
}
}


GrowlZ1010 07-19-2002 02:50 AM

I presume you'd have to use testplayer to check the index of any nearby players, then use something similar to with(getplayer(#a(index))) to select the player for editing. But it should be possible, yes.

Python523 07-19-2002 02:52 AM

use with(players[index])
it can get any player in the level the script is run in

Googi 07-19-2002 10:40 AM

Quote:

Originally posted by Python523
use with(players[index])
it can get any player in the level the script is run in

It can't be used to get a player who is has an x-co-ord of playerx+1 though XD

Python523 07-19-2002 10:59 AM

Quote:

Originally posted by Googi


It can't be used to get a player who is has an x-co-ord of playerx+1 though XD

yes it can? it works like getplayer but with the index of a player in the level

Googi 07-19-2002 11:01 PM

Well for some reason I doubt this would work :-\

NPC Code:

with (players[i].x = playerx-1){
hurt 2;
}


Python523 07-20-2002 12:50 AM

Quote:

Originally posted by Googi
Well for some reason I doubt this would work :-\

NPC Code:

with (players[i].x = playerx-1){
hurt 2;
}


because you have a completelly wrong syntax? getplayer doesnt work like that either, just go through all the players using a for loop and make it so if their x is in a certain part, it continues with with the script

Googi 07-20-2002 02:51 AM

XD, I did get it, but it turns out that it doesn't do what I thought it would.

What about a way to execute a command when two players touch eachother.

CheeToS2 07-20-2002 03:31 AM

googi, use testplayer (i think thats what it is called) to get the index.

format is testplayer(x,y)
it returns the index # of the player at those coordinates

Googi 07-20-2002 05:29 AM

Quote:

Originally posted by CheeToS2
googi, use testplayer (i think thats what it is called) to get the index.

format is testplayer(x,y)
it returns the index # of the player at those coordinates

Okay, but how do I find out the index number and put it into my script.

XD, for some reason I neglected to learn about indexs.

Any good tutorials about indexs?

Googi 07-20-2002 09:57 PM

Quote:

Originally posted by Kaimetsu
Testplayer is a bad idea. And the plural for 'index' is 'indices'.
Okay, where can I learn about indices then?

Googi 07-21-2002 01:20 AM

Quote:

Originally posted by Kaimetsu


commands.rtf

Thanks :D

Okay, now I know what I'm doing (I hope XD)

But how do I get the index without using testplayer (Since you say it is a bad idea)

Python523 07-21-2002 01:22 AM

if you want to go through the players in a level, run a for loop
for(i=0;i<playerscount;i++){
with(players[i]){
//stuff
}
}

Googi 07-21-2002 02:55 AM

NPC Code:

for (i=0;i<playerscount;i++){
with (players[playerx-1]){
hurt 2;
}
}



Once again I doubt that will work.

Googi 07-21-2002 03:22 AM

Quote:

Originally posted by Kaimetsu
Grim Squeaker:

*Zaps*
Try checking if the player is in the area you want him to be, then do the with, silly.

Kai said using testplayer was a bad idea though.


All times are GMT +2. The time now is 10:00 AM.

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