Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Player Dragging (https://forums.graalonline.com/forums/showthread.php?t=84826)

Tigairius 03-25-2009 08:12 AM

Player Dragging
 
1 Attachment(s)
Now you can smoothly drag players with your mouse!

It's been a while since I posted anything in the code gallery and I've been wanting to script this for a while now, so I decided to do it tonight while I was free.

What it does:
You click & drag on a player and it will smoothly drag the player behind your mouse.

It decides the position of the player being dragged and then calculates the best way to smoothly move the player to the mouse position. This way we don't have to use multiple 'triggerserver' updates in a timeout and it's not all jumpy.

How to Install:
This is a two-part script. Before you pass it up and say "oh god, I'm not installing multiple things," just read, it's really easy to set up.

You will have two weapons, our "control weapon," which is given to staff members who need the tool to drag players, and the "player weapon," which is added to the players being dragged.

We'll use Weapon1 as our example of the "control weapon." Use Weapon1 for the staff members, who can use it to drag players.

Weapon 1:
PHP Code:

// NPC made by Tig
function onActionServerside(commandacct) {
  switch (
command) {
    case 
"StartDrag":
      
with (findplayer(acct)) {
        
player.addWeapon("Weapon2");
        
client.controller playero.account;
        
findWeapon("Weapon2").trigger("StartDrag"playero);
      }
      
player.attr[20] = acct;
    break;
  }
}

//#CLIENTSIDE
function onCreated() {
  
this.catchEvent(GraalControl"onMouseDragged""onMouseDragged");
}

function 
onMouseDown() {
  for (
temp.pplayers) {
    if (
mousex in |temp.p.1temp.p.3| && mousey in |temp.p.ytemp.p.2|) {
      
this.trigger("StartDrag"temp.p);
      break;
    }
  }
}

function 
onStartDrag(pl) {
  
triggerserver("gui"name"startDrag"pl.account);
}

function 
onMouseUp() {
  
player.attr[28] = player.attr[20] = "";
}

function 
onMouseDragged(objmodmxmy) {
  
player.attr[28] = "\"" mousex SPC mousey "\"";


Now, make sure you replace Weapon2 with the name of your "player weapon."

Here is Weapon2:
PHP Code:

// NPC made by Tig
function onStartDrag(control) {
  
triggerclient("gui"name"startDrag"control.account);
}
//#CLIENTSIDE
function onCreated() {
}

function 
onActionClientside(commandacct) {
  switch (
command) {
    case 
"startDrag":
      
onTimeout();
    break;
  }
}

function 
onTimeout() {
  
temp.speed 0.5;
  
temp.findplayer(client.controller);
  if (
temp.c.attr[20] == player.account) {
    
temp.pos = (temp.c.attr[28].substring(1temp.c.attr[28].length() -2)).tokenize();
  }else {
    
client.controller "";
    
setTimer(0);
    return;
  }

  if (
temp.pos != NULL) {
    if (
player.player.!= temp.pos[0] + temp.pos[1]) {
      
temp.dist = {temp.pos[0] - player.xtemp.pos[1] - player.y};
      
temp.mx dist[0] / (speed 16);
      
temp.my dist[1] / (speed 16);
      
player.+= mx;
      
player.+= my;
    }
  }
  
setTimer(0.05);


Weapon2 will be given to the player that is being dragged. This retrieves data from the dragger and moves the player to the dragger's mouse position.

A lot of servers use this kind of tool for ETs, so have fun but in moderation!

If you're lazy or still don't understand, I've zipped it up for you. All you have to do is drop these two files into your "weapons/" folder on RC and then restart the NPC-Server.

After you've done that, add the weapon to yourself (it's called MouseC).

xXziroXx 03-25-2009 08:18 AM

It's nice and all, but something tells me it'll mainly be used by people who loves abusing staff tools on their impopular UC servers :frown:

Tigairius 03-25-2009 08:20 AM

Quote:

Originally Posted by xXziroXx (Post 1477627)
It's nice and all, but something tells me it'll mainly be used by people who loves abusing staff tools on their impopular UC servers :frown:

Lol, as for anything else! It is a good example for other scripts and uses though. :D

Crono 03-25-2009 03:16 PM

This is why I can't take up scripting, so much technical logic stuff. :(

Admins 03-25-2009 06:40 PM

Sounds nice, might use it for a weapon on Zone :D

MiniOne 03-26-2009 07:14 AM

Quote:

Originally Posted by Stefan (Post 1477714)
Sounds nice, might use it for a weapon on Zone :D

What do you have in mind?

cyan3 03-26-2009 09:46 AM

Quote:

Originally Posted by MiniOne (Post 1477954)
What do you have in mind?

A gravity gun would be fun to use :)

Gothika 03-26-2009 10:47 AM

Quote:

Originally Posted by cyan3 (Post 1477966)
A gravity gun would be fun to use :)

If it was adapted to pick up objects instead. Barrels, mines ect.

MiniOne 03-26-2009 10:53 AM

Quote:

Originally Posted by cyan3 (Post 1477966)
A gravity gun would be fun to use :)

Depending on how it's tested, and if its not Overpowered then yes it could :D

Deas_Voice 03-26-2009 05:20 PM

Quote:

Originally Posted by Stefan (Post 1477714)
Sounds nice, might use it for a weapon on Zone :D

i hope you don't mean that ETs are going to have dragging a player as a "weapon".

irock1 09-08-2011 01:50 PM

Hi the script worked but how can I setani drag.gani?

Gunderak 09-08-2011 06:16 PM

By doing this at this part of the script in the being dragged weapon
PHP Code:

function onTimeout() {
  
temp.speed 0.4;
  
temp.findplayer(client.controller);
  
disabledefmovement();
  
//This is what your after
  
setani("INSERT BEING DRAGGED ANI HERE EXCLUDING .gani"""); 


furry_mougle 09-08-2011 10:31 PM

why did he settimer(0)? isn't the minimum 0.05? why even time at all?

DustyPorViva 09-08-2011 10:32 PM

Quote:

Originally Posted by furry_mougle (Post 1667489)
why did he settimer(0)? isn't the minimum 0.05? why even time at all?

Probably to try to cancel the timeout.


All times are GMT +2. The time now is 05:12 AM.

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