Changing players[i].x and players[i].y!

Ok, so I encountered a problem with this script:

if (playerenters) {
 toweapons Player Manipulator;
}
if (weaponfired) {
 if (this.on == 0) {
  this.on = 1;
  setplayerprop #c, On!;
  timeout = 0.05;
 } else {this.on = 0;  setplayerprop #c, Off!;}
}
if (mousedown) {
 if (this.on == 1) {
  if (this.baddymove == 0) {
   for (i=0;i<playerscount;i++){
    if (abs(players[i].x-mousex)<=2&&abs(players[i].y-mousey)<=2) {
     this.baddytarget = i;
     this.baddymove = 1;
     setplayerprop #c,Got Player!;
    }
   }
  } else { setplayerprop #c, Released Player!; this.baddytarget = 0; this.baddymove = 0;}
 }
}
if (timeout) {
 if (this.on == 1) {
  if (this.baddymove == 1) {
   players[this.baddytarget].y = mousey;
   players[this.baddytarget].x = mousex;
  }
  timeout = 0.05;
 }
}

Well no matter WHO I click on, it moves ME. But if I click on NOBODY, nothing happens. So it is DETECTING that I'm clicking on somebody, or myself, but it always moves ME… Help here?

P.S.- You are supposed to be able to click on a player, drag him around, and release him when clicking again.

Re: Changing players[i].x and players[i].y!

Eh my guess is player"s"count should be playercount. Player"s"count picks up all the showcharacter npcs in the level aswell, playercount only counts players.
You might also want to put i = playercount; after this.baddytarget = i; just so it quits going thru the loop(tho it doesn’t really matter I guess).

playercount should fix it tho.

Re: Changing players[i].x and players[i].y!

ill be making a gs1 scripting guide in a few days after i rember how to not incorprate a nc that will come soon after we get the nc up for everyserver

Re: Changing players[i].x and players[i].y!

[quote=Handuponyohip ]just so it quits going thru the loop
[/quote]

break;

Re: Changing players[i].x and players[i].y!

break;
[/quote]

Simple enough.

Re: Changing players[i].x and players[i].y!

No, I've done it to move NPCs, and its the same script, only with npcscount replacing playerscount and npcs[i].x and whatever… I think you can't change another player's X and Y…
Heres my NPC dragging script:

if (playerenters) {
 toweapons NPC Manipulator;
}
if (weaponfired) {
 if (this.on == 0) {
  this.on = 1;
  setplayerprop #c, On!;
  timeout = 0.05;
 } else {this.on = 0;  setplayerprop #c, Off!;}
}
if (mousedown) {
 if (this.on == 1) {
  if (this.baddymove == 0) {
   for (i=0;i<npcscount;i++){
    if (abs(npcs[i].x-mousex)<=2&&abs(npcs[i].y-mousey)<=2) {
     this.baddytarget = i;
     this.baddymove = 1;
     setplayerprop #c,Got NPC!;
    }
   }
  } else { setplayerprop #c, Released NPC!; this.baddytarget = 0; this.baddymove = 0;}
 }
}
if (timeout) {
 if (this.on == 1) {
  if (this.baddymove == 1) {
   npcs[this.baddytarget].y = mousey;
   npcs[this.baddytarget].x = mousex;
  }
  timeout = 0.05;
 }
}

There is no value named playercount x_X…
And my point is that even if I manually input this.baddytarget to something, I need to know if you can even CHANGE another player's X and Y values.

Re: Changing players[i].x and players[i].y!

Yeah I Believe you. Can't change the x & y of an item either :frowning:

Re: Changing players[i].x and players[i].y!

So is the original script possible/ fixed? If so, can you post the working one here?

Re: Changing players[i].x and players[i].y!

lol. Well, you see a script commonly on graal servers nowadays, why?
with(getplayer(account)) { } (NPC Server)

Re: Changing players[i].x and players[i].y!

eh, then you'd need to put something in the players system npc. And make a few server strings. So like,

if (strequals(#s(client.id),#I(server.dragged,0)){ 
playerx = strtofloat(#I(server.dragged,1)); 
playery = strtofloat(#I(server.dragged,2));
}

then on the mouse script just put,
replacestring server.dragged,0,this.baddytarget;
replacestring server.dragged,1,mousey;
replacestring server.dragged,2,mousex;

But that only works because I have my server setup to give every new player a playerid. If you want to just put an npc on your onlinestartlocal.nw, that runs once for a player then sets a flag to not run again, have it add 1 to a counter, and assigns the counter to client.id. Its also good to make a string list inserting the players name at their id into the list. So you know which player belongs to that id.

Re: Changing players[i].x and players[i].y!

I'm too lazy to put that all together. :stuck_out_tongue:

Re: Changing players[i].x and players[i].y!

I know how to do it like that, but I thought I could do it this simpler way, so that way theres not a mess of server strings.

Re: Changing players[i].x and players[i].y!

eh server strings are the only way to do things server wide really. You could also do it with trigger action. Put the action in their system npc, and then when calling the action pass the 2 parameters of mousex and mousey.

Re: Changing players[i].x and players[i].y!

I thought triggeractions were fucked up? (Not broken)

Re: Changing players[i].x and players[i].y!

not sure, maybe. Only problems i've heard about is with npcserver, lol and since we don't have one? It's worked anytime i've tryed it in this version, anyone else have more info on it?

Re: Changing players[i].x and players[i].y!

Triggeractions that are not built in to Graal’s system, like triggerpush is one thats built in I think, don’t work when acting on a player. They DO work when acting on an NPC though, but what you CAN do is use an invisible actionprojectile with a lifetime of 0.01, then check its X and Y when it “dies” to see if its within the player’s X and Y, and do your shit from there. Something like that is pretty simple.