Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-28-2008, 08:24 PM
[email protected] sid.gottlieb@googlemail.com is offline
Banned
Join Date: Mar 2008
Posts: 861
sid.gottlieb@googlemail.com will become famous soon enough
mouse clicky player

HTML Code:
function onMouseDown(temp.click) {
  if (!player.guild.starts("Events Team")) return false;
  if (click != "left") return false;
  
  temp.playera = players[testplayer(mousex, mousey)];
  if (playera.account != null) 
    player.chat = "selected" SPC playera.account;
}
pretty cool and simple code, thought i'd share !!!
just click a player with an "events team" tag, and it'll find out who they are! good for event thingys
Reply With Quote
  #2  
Old 05-28-2008, 09:14 PM
Programmer Programmer is offline
Coder
Programmer's Avatar
Join Date: Jan 2008
Location: -78.464422, 106.837328
Posts: 449
Programmer has a spectacular aura aboutProgrammer has a spectacular aura about
Send a message via AIM to Programmer Send a message via MSN to Programmer Send a message via Yahoo to Programmer
Quote:
Originally Posted by [email protected] View Post
HTML Code:
function onMouseDown(temp.click) {
  if (!player.guild.starts("Events Team")) return false;
  if (click != "left") return false;
  
  temp.playera = players[testplayer(mousex, mousey)];
  if (playera.account != null) 
    player.chat = "selected" SPC playera.account;
}
pretty cool and simple code, thought i'd share !!!
just click a player with an "events team" tag, and it'll find out who they are! good for event thingys
Simplicity. I like it.
__________________
- Iᴀɴ Zɪᴍᴍᴇʀᴍᴀɴ
Reply With Quote
  #3  
Old 05-28-2008, 11:54 PM
Dan Dan is offline
Daniel
Join Date: Oct 2007
Posts: 383
Dan is an unknown quantity at this point
Send a message via MSN to Dan
rep ++
__________________
Reply With Quote
  #4  
Old 05-29-2008, 12:57 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
I think testplayer is the function that only returns an account if the player is able to be hit by default weapons i.e. won't work in no-pk zones or when the player is paused. I do something like this

PHP Code:
//#CLIENTSIDE
function onMouseDown(mode
{
  if (
player.guild.starts("Events")) return;
  if (
mode != "left") return;

  
temp.pl grabPlayer();
  if (!
pl.account)
    
player.chat "No players found!";
  else
    
player.chat format("Grabbed %s!",pl.account);
}

function 
grabPlayer()
{
  for (
players)
  {
    if (
mousex in |p.+0.3p.2.5|)
    {
      if (
mousey in |p.yp.y+2.6|)
        return 
p;
    }
  }
  return 
false;

Can't test it (at work) but it should be right...or close. You could expand that by adding all players within the area into an array and returning that. If the array has more than one person, you could create a quick gui popup control to display the users then click the one you wish to grab.
Reply With Quote
  #5  
Old 05-29-2008, 01:11 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
I've usually done things such as say

:get

and click a player.
__________________
Reply With Quote
  #6  
Old 05-29-2008, 11:20 PM
[email protected] sid.gottlieb@googlemail.com is offline
Banned
Join Date: Mar 2008
Posts: 861
sid.gottlieb@googlemail.com will become famous soon enough
Quote:
Originally Posted by Twinny View Post
I think testplayer is the function that only returns an account if the player is able to be hit by default weapons i.e. won't work in no-pk zones or when the player is paused. I do something like this
strange, mine works fine

tyvm
Reply With Quote
  #7  
Old 08-02-2008, 05:56 PM
_Z3phyr_ _Z3phyr_ is offline
Banned
Join Date: Sep 2003
Location: Louisiane
Posts: 390
_Z3phyr_ is an unknown quantity at this point
testplayer returns the playerindex # of a player (if there is one) at the given (x,y)
Reply With Quote
  #8  
Old 08-07-2008, 09:03 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Clientside it only returns other players when the level is a pk zone. Somewhat annoying
Reply With Quote
  #9  
Old 08-19-2008, 05:09 AM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
Quote:
Originally Posted by Crow View Post
Clientside it only returns other players when the level is a pk zone. Somewhat annoying
It also only returns the player index if they're unpaused.
Reply With Quote
  #10  
Old 08-19-2008, 09:01 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by Mark Sir Link View Post
It also only returns the player index if they're unpaused.
Kinda sucky but it is only meant for hit detection in the end. You will have to make your own using a loop of players array
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 02:29 AM.


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