• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Switch summons monster

Santi

Theres no way im stopping
Joined
Aug 29, 2010
Messages
1,975
Reaction score
152
Location
00
I'm trying to make a switch with a uniqueid, and when you use it a monster appears.
I tried it but im not really good at scripting.
So I'll show ya what i got so far and could you guys tell me how to fix it or make it (probably its all wrong).

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemuid == 5044 then
doSummonCreature(cid, position x="1550",y="257",z="6")
doSendMagicEffect(frompos, math.random(01,60) )
doSendAnimatedText(frompos, 'Hydra')
return true
end

and I got in actions.xml this:

Code:
<action uniqueid="5044" script="donations/hydra lever.lua" />

And this is the error it gives when I /reload actions

Code:
[12/09/2010 20:32:02] [Error - LuaScriptInterface::loadFile] data/actions/scripts/donations/hydra lever.lua:3: ')' expected near 'x'
[12/09/2010 20:32:02] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/donations/hydra lever.lua)
[12/09/2010 20:32:02] data/actions/scripts/donations/hydra lever.lua:3: ')' expected near 'x'

Thanks in advanced and rep+ for the one who can help me! Please i need it :).
 
1 - you are using one unique id so you don't need to check for uid in the script as you stated it in the action.xml

2- It is called item.uniqueid .

3- the position is like that {x=1,y=1,z=1}

4- I assume you dont want to summon the player himself... So you use the summon creature like that ,
Code:
doSummonCreature("Hydra", {x=1,y=1,z=1})

5- It is called fromPosition(as you have it in the function) not fromPos


6- for the do send animated text it is missing a parameter(of text colour)
Code:
doSendAnimatedText(fromPosition, 'Hydra',[COLOR="blue"]10[/COLOR])

So script will look like that :

LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	
	               --no need to check for the unique id as you stated it in the action.xml
     
  doSummonCreature("hydra", {x=1,y=1,z=1})       ---You need to type the monster name in the first param, and fix the position
        
  doSendMagicEffect(fromPosition, math.random(1,60))  --- fixed the fromPos to match the one in the function.

   doSendAnimatedText(fromPosition, 'Hydra',10)      -- fixin the fromPos again, and adding the missing param of text colour

return true

end
 
Last edited:
Thanks!
I really appreciate you've explained it to me and not made it, thanks :).
Rep+ for you.
 
Faster script: Change only the summonname.
LUA:
local storage = { 
summonName = "Hydra", --dont remove the "" and the ,
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
local ipos = getCreaturePosition(cid) 	
local name = getPlayerStorageValue(cid, storage.summonName) 	
local posit = {x=ipos.x+2,y=ipos.y,z=ipos.z} 	        
    doSummonCreature(name, posit) --- 
    doSendMagicEffect(fromPosition, math.random(1,60))  
   doSendAnimatedText(fromPosition, name,7) 
 
return true
 
end
Credits to:
Me : for make faster
Damadger: script base
 
Back
Top