matthewharrison
New Member
- Joined
- Nov 21, 2011
- Messages
- 42
- Reaction score
- 1
Ok, I made this script for my server, it took me a while to make but it seemed like I finally got it working perfectly. It allows a player to double click a door on a room before even moving and it will teleport them in, then back out (normally with any teleport doors you wouldn't have the time to double click before teleporting, and even if you did it wouldn't teleport you back out).
This is a method of hunting used on my server, the player double clicks the door then hits their attack hotkey once they see themselves inside the room (there's a short delay before you're teleported back out), if done right, the player jumps into the room, attacks, and jumps out quickly.
Here's the problem. Today when I was hunting on my server (using these doors), someone else was using a different door at the same time, when I double clicked and attacked, the other player did the same at the same time, and when we teleported back out the player teleported over on top of me instead of back infront of his own door.
Anyways here's the scripts (won't work without both scripts)
Script 1:
Script 2
I'm not completely sure how script functions work, but I'm guessing the server is storing the information of both player positions, and when it goes to perform the second teleport (the one back out the door), it doesn't know which position to use and just picks one.
If anyone understands this, can you please help! I've been working so long on this script and its almost finished!
This is a method of hunting used on my server, the player double clicks the door then hits their attack hotkey once they see themselves inside the room (there's a short delay before you're teleported back out), if done right, the player jumps into the room, attacks, and jumps out quickly.
Here's the problem. Today when I was hunting on my server (using these doors), someone else was using a different door at the same time, when I double clicked and attacked, the other player did the same at the same time, and when we teleported back out the player teleported over on top of me instead of back infront of his own door.
Anyways here's the scripts (won't work without both scripts)
Script 1:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local cidPosition = getPlayerPosition(cid)
--config--
delay = 600
--endconfig--
local a = {cid = cid}
backlocation = {x=cidPosition.x,y=cidPosition.y,z=cidPosition.z}
if (item.itemid == 1249) then
if cidPosition.y == toPosition.y and cidPosition.x == toPosition.x-1 then
doTransformItem(item.uid, item.itemid + 1)
addEvent(tpback, delay, a)
elseif cidPosition.y == toPosition.y and cidPosition.x == toPosition.x+1 then
doTeleportThing(cid, {x=cidPosition.x-2,y=cidPosition.y,z=cidPosition.z}, TRUE)
doTransformItem(item.uid, item.itemid + 1)
end
end
end
function tpback(a)
doTeleportThing(a.cid, backlocation, TRUE)
end
Script 2
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local cidPosition = getPlayerPosition(cid)
--config--
delay = 600
--endconfig--
local a = {cid = cid}
backlocation = {x=cidPosition.x,y=cidPosition.y,z=cidPosition.z}
if (item.itemid == 1250) then
if cidPosition.y == toPosition.y and cidPosition.x == toPosition.x+1 then
doTransformItem(item.uid, item.itemid - 1)
addEvent(tpback, delay, a)
elseif cidPosition.y == toPosition.y and cidPosition.x == toPosition.x-1 then
doTeleportThing(cid, {x=cidPosition.x+2,y=cidPosition.y,z=cidPosition.z}, TRUE)
doTransformItem(item.uid, item.itemid - 1)
end
end
end
function tpback(a)
doTeleportThing(a.cid, backlocation, TRUE)
end
I'm not completely sure how script functions work, but I'm guessing the server is storing the information of both player positions, and when it goes to perform the second teleport (the one back out the door), it doesn't know which position to use and just picks one.
If anyone understands this, can you please help! I've been working so long on this script and its almost finished!