im very noob in scripting could you do the full script please
Sure thing,
Example 1: Player steps on a magic forcefield (portal) that takes him/her to home city.
In your map, place item 9773 (same graphic as magic forcefield) and assign it an action ID not in use by your server. For this example I'll use AID
1234.
In movements.xml place the following line (remember, actionid="
1234" is the example for this script, please use an AID not in use by your server);
Code:
[COLOR="#0000FF"]<movevent[/COLOR] [COLOR="#FF0000"]event[/COLOR]=[COLOR="#4B0082"]"StepIn"[/COLOR] [COLOR="#FF0000"]actionid[/COLOR]=[COLOR="#4B0082"]"[B]1234[/B]"[/COLOR] [COLOR="#FF0000"]script[/COLOR]=[COLOR="#4B0082"]"cityport.lua"[/COLOR]/>
Create a new file in data/movements/ called
cityport.lua and place the following code in it;
Code:
[COLOR="#0000FF"]function[/COLOR] onStepIn(cid, item, position, fromPosition)
doSendMagicEffect(getCreaturePosition(cid), [COLOR="#FFA500"]10[/COLOR]) [COLOR="#008000"]-- This line displays a magic effect where the player teleports FROM (as it occures BEFORE the teleport line).[/COLOR]
doTeleportThing(cid,getPlayerMasterPos(cid)) [COLOR="#008000"]-- This line teleports the player (cid) to their home city (getPlayerMasterPos(cid)).[/COLOR]
doSendMagicEffect(getCreaturePosition(cid), [COLOR="#FFA500"]10[/COLOR]) [COLOR="#008000"]-- This line displays a magic effect where the player teleports TO (as it occured AFTER the teleport line).[/COLOR]
[COLOR="#0000FF"]return true[/COLOR]
[COLOR="#0000FF"]end[/COLOR]
Example 2: Player flips a switch that teleports them to their home city.
In your map, place item 1945 (switch) and assign it an action ID not is use by your server. For this example I'll use AID
1234.
In actions.xml place the following line (remember, actionid="
1234" is the example for this script, please use an AID not in use by your server);
Code:
[COLOR="#0000FF"]<action[/COLOR] [COLOR="#FF0000"]actionid[/COLOR]=[COLOR="#4B0082"]"1234"[/COLOR] [COLOR="#FF0000"]script[/COLOR]=[COLOR="#4B0082"]"other/cityport.lua"[/COLOR][COLOR="#0000FF"]/>[/COLOR]
Create a new file in data/actions/other called
cityport.lua and place the following code in it;
Code:
[COLOR="#0000FF"]function[/COLOR] onUse(cid, item, frompos, item2, topos)
doSendMagicEffect(getCreaturePosition(cid), [COLOR="#FFA500"]10[/COLOR]) [COLOR="#008000"]-- This line displays a magic effect where the player teleports FROM (as it occures BEFORE the teleport line).[/COLOR]
doTeleportThing(cid,getPlayerMasterPos(cid)) [COLOR="#008000"]-- This line teleports the player (cid) to their home city (getPlayerMasterPos(cid)).[/COLOR]
doSendMagicEffect(getCreaturePosition(cid), [COLOR="#FFA500"]10[/COLOR]) [COLOR="#008000"]-- This line displays a magic effect where the player teleports TO (as it occured AFTER the teleport line).[/COLOR]
[COLOR="#0000FF"]if[/COLOR] item.itemid == [COLOR="#FFA500"]1945[/COLOR] then [COLOR="#008000"]-- Checks position of switch.[/COLOR]
doTransformItem(item.uid, [COLOR="#FFA500"]1946[/COLOR]) [COLOR="#008000"]-- If switch is in position 1945 then transform to 1946.[/COLOR]
[COLOR="#0000FF"]else[/COLOR]
doTransformItem(item.uid, [COLOR="#FFA500"]1945[/COLOR]) [COLOR="#008000"]-- Otherwise transform switch back to 1945.[/COLOR]
[COLOR="#0000FF"]end[/COLOR]
[COLOR="#0000FF"]return true[/COLOR]
[COLOR="#0000FF"]end[/COLOR]
If you have any questions please don't hesitate to ask.
Cheers.