Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   mouse -> ID (https://forums.graalonline.com/forums/showthread.php?t=50896)

Jimmii 02-06-2004 12:01 PM

mouse -> ID
 
you pass a players ID into with(allplayers(i)) do you not?

how would i say, get this ID # from a player when i say, click on them... i don't think its testplayer, because that gets index...

Termina_Owner 02-06-2004 02:18 PM

NPC Code:

with (players[i])

with (allplayers[i])

testplayer(x,y)



All players ID can't be found unless you check the logs (Alt+0) for when the player entered:

Added player Termina_Owner (id: 2)

Clear?

Loriel 02-06-2004 02:39 PM

Re: mouse -> ID
 
Quote:

Originally posted by Jimmii
you pass a players ID into with(allplayers(i)) do you not?
Nope. Allplayers takes a global index that is different from both the local index and the player ID.
Player IDs are not neccessarily sequential, because if a player with a lower ID logs off, the higher ones to not change their ID. Thus, you could not do for (i = 0; i < allplayerscount; i ++) ...
If you want to find a certain player, you can use testplayer to get his index, then use that index with #a() to get his account name, and use with (getplayer()).

Termina_Owner 02-06-2004 10:55 PM

Erm... Global Player ID is shown in two places: Log Frame, and RC.

But programming-speaking, the only way would be doing the for loop with allplayerscount, which would produce somewhat a lot of lag.

Duwul 02-07-2004 12:58 AM

Would be easier if we could use mousex/y serverside.

You could do

NPC Code:

with (players[testplayer(mousex,mousey)])



if it was serverside.

I suppose you could check for mousedown on the clientside, triggeraction the mouse coordinates, then do

NPC Code:

with players[testplayer(strtofloat(#p(0)),strtofloat(#p(1)))])


Termina_Owner 02-07-2004 02:25 AM

Erm.. Save work for serverside: Send the value of testplayer.

NPC Code:

with (players[strtofloat(#p(0)))
//#CLIENTSIDE
triggeraction 0,0,serverside,#w,#v(testplayer(mousex,mousey));



Though, that's ineffective: It'll send when the index is -1.

Duwul 02-07-2004 02:58 AM

So check that id != -1

Loriel 02-07-2004 06:19 AM

Quote:

Originally posted by Termina_Owner
Erm.. Save work for serverside: Send the value of testplayer.
A player's index is not guaranteed to be the same serverside and clientside. Use playerid and loop again, or just pass the mouse coordinates.


All times are GMT +2. The time now is 01:19 AM.

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