Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   testplayer x.x (https://forums.graalonline.com/forums/showthread.php?t=63645)

talkingnoodle 01-22-2006 05:07 PM

testplayer x.x
 
I'm making a profile system and when I use rightmousebutton and testplayer, the profile only works when both of the players are on a gmap !pissed!

help?

Skyld 01-22-2006 05:16 PM

How about you give us more details about how you're doing this? Also, please explain how this is a problem.

Kronan 01-22-2006 05:20 PM

Quote:

Originally Posted by talkingnoodle
I'm making a profile system and when I use rightmousebutton and testplayer, the profile only works when both of the players are on a gmap !pissed!

help?

What? how? why? testplayer(x,y) only gets a players ID from the x,y you specify. And yes, provide more information so we can help you..

talkingnoodle 01-22-2006 05:52 PM

ok well heres part of the script...and its a problem because when you right click inside a level the profile wont show up :-/
NPC Code:

if (mousedown){
if (rightmousebutton){
pid = testplayer(mousex,mousey);
if (pid > -1){
close();
triggeraction 0,0,serverside,-System/Profiles,mouse,#v(mousex),#v(mousey);

...

if i make (pid > -1) it only works on a gmap or when you click yourself...if i make it -2 then anyhwere you click on the screen it shows the last profile you clickd...if i make it 0 it just doesnt work :(

Yen 01-22-2006 07:03 PM

-1 is what's returned when you get no player.
0 is your own ID.
1 and above is another player.

Why is it sending mousex and mousey to the serverside?
Why not send #a(pid) ?

talkingnoodle 01-22-2006 08:57 PM

Quote:

Originally Posted by Yen
Why is it sending mousex and mousey to the serverside?
Why not send #a(pid) ?

because on the serverside it uses testplayer agin x.x

is that bad?

ZeLpH_MyStiK 01-22-2006 09:11 PM

You should just send the account name of the player you found on clientside through the triggeraction. Why do testplayer twice (especially there is the consideration of lag when going from clientside to serverside and vice-versa)?

Admins 01-22-2006 11:43 PM

Yes just send #a(pindex) to the server

talkingnoodle 01-23-2006 05:24 AM

Quote:

Originally Posted by Stefan
Yes just send #a(pindex) to the server

I did that and it still only works on gmaps (when they are not idle), when they are idle it doesnt work either x_x

Yen 01-23-2006 05:37 AM

That made no sense.

Try testplayer(mousex % 65,mousey % 65), but I doubt it'll make a difference. :/

Rick 01-23-2006 05:47 AM

Quote:

Originally Posted by Yen
That made no sense.

Try testplayer(mousex % 65,mousey % 65), but I doubt it'll make a difference. :/

How would that help?

ZeLpH_MyStiK 01-23-2006 07:25 AM

Quote:

Originally Posted by Rick
How would that help?

It doesn't.
NPC Code:

//#CLIENTSIDE
if (mousedown) {
if (rightmousebutton) {
this.pid = testplayer(mousex,mousey);
setplayerprop #c,#a(this.pid);
}
}


See if that detects the players. If it doesn't, you can always loops through the players in the level and check if the mouse coordinates are within the coordinates used by the players. I.E.
NPC Code:

//#CLIENTSIDE
if (mousedown) { // checks to see if mouse is used
if (rightmousebutton) { // checks to see if right mouse button was used
for(i=0; i<playerscount; i++) { // loops through players in the level
this.pid = -1; // presets the id var to -1 just in case there are no players at the mouse coordinates
if (mousex in |players[i].x,players[i].x+1.5| && mousey in |players[i].y,players[i].y+2|) { // checks for players at the coordinate
this.pid = i; // if player exists sets id var to player's id
}
}
if (this.pid == -1) { // does the player exist?
setplayerprop #c,Player not detected;
}else setplayerprop #c,#a(this.pid);
}
}


napo_p2p 01-23-2006 07:31 AM

Quote:

Originally Posted by Yen
Try testplayer(mousex % 65,mousey % 65), but I doubt it'll make a difference. :/

That even got me confused... (talkingnoodle/Rabidwolve don't consider doing that).

Zelph has got it better.

And Yen. I'm just wondering. What is the reasoning behind that?

talkingnoodle 01-23-2006 05:35 PM

ok thx

Yen 01-23-2006 09:56 PM

There's absolutely no reasoning behind it, but the only reason I could think of for testplayer() not returning anything on a gmap is that testplayer only checks on the individual level, but mousex and mousey are using coordinates on the gmap.

Lance 01-24-2006 12:12 AM

Quote:

Originally Posted by Yen
There's absolutely no reasoning behind it, but the only reason I could think of for testplayer() not returning anything on a gmap is that testplayer only checks on the individual level, but mousex and mousey are using coordinates on the gmap.

Even if that were true, why would you use 65? :confused:

Yen 01-24-2006 12:28 AM

Levels are 64x64 tiles. The 64th tile is valid, so % 65 will begin at 0,0 of your current level.

Lance 01-24-2006 12:45 AM

Quote:

Originally Posted by Yen
Levels are 64x64 tiles. The 64th tile is valid, so % 65 will begin at 0,0 of your current level.

Coordinates start at 0,0, not 1,1. From the origin, the 64th tile would be at coordinate 63. The first tile on the next level would be at coordinate 64. If you mod this value by 65 you aren't ensuring anything about the current level.

Yen 01-24-2006 01:13 AM

PHP Code:

function onKeyPressed() {
  
player.chat player.65;


I warped to the third level (on the x-axis) of a gmap, at 30,30. I made sure it attached me to the gmap.

It set my chat to 30, not 33.

Lance 01-24-2006 01:47 AM

Quote:

Originally Posted by Yen
PHP Code:

function onKeyPressed() {
  
player.chat player.65;


I warped to the third level (on the x-axis) of a gmap, at 30,30. I made sure it attached me to the gmap.

It set my chat to 30, not 33.

You're nuts.

http://lance.vip.graal.net/screenshots/modproof.png

http://lance.vip.graal.net/screenshots/modproof2.png

Yen 01-24-2006 02:59 AM

No, I warped to a03.. Which was 3 down on the y-axis, not the x-axis..

-Wanders off.-

Lance 01-24-2006 03:11 AM

Quote:

Originally Posted by Yen
No, I warped to a03.. Which was 3 down on the y-axis, not the x-axis..

-Wanders off.-

Well, you said x.

Either way:

http://lance.vip.graal.net/screenshots/modproofb.png

NPC Code:
    else if (player.chat == "coordtest") {
player.chat = "x: " @ player.x @ ", x % 64: " @ player.x%64 @ ", x % 65: " @ player.x%65 @ "; " @ "y: " @ player.y @ ", y % 64: " @ player.y%64 @ ", y % 65: " @ player.y%65;
}



All times are GMT +2. The time now is 02:36 PM.

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