• 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!

Lua Question

Cloow

Active Member
Joined
May 10, 2010
Messages
1,086
Reaction score
35
Alright, i made a quick script. My first one actually.

Here is my question, if i want the line
if item.itemid == 59281 then
To be UID instead of itemID what should i do?


Also, when im trying to start the server with my script i get this error
16h2sci.png
and i can't just see what i have done wrong.







PHP:
local t = 
{
      monster = "Monster"
	  pos = {x=967, y=1007, z=7},
	  msg = "Monster appears right infront of your eyes!!"
	  tpos = {x=967, y=1007, z=7},
	  cpod = {x=960, y=1007, z=7},
	  bmsg = "How dare you?!"
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
       if item.itemuid == 59281 then
         doSummonCreature(t.monster,t.pos)
		  doCreatureSay(cid, t.msg, TALKTYPE_ORANGE_1)
		   doCreateTeleport(1387, t.tpos, t.cpos)
		     doBroadcastMessage(t.bmsg, TALKTYPE_RED_1)
		    return TRUE
     end
end


If you see any errors, wich will not work when im testing this. I would love to know em =>

Soon enough im gonna be pro on scripting !
 
Oh, I forgot that with commands with 'get' it's easier to just add it to login.lua.

Or else register the creatureevent in login.lua.

e.g.
registerCreatureEvent('PlayerLoginFYI')

Code:
    if getPlayerStorageValue(cid,15012) < 0 then
        setPlayerStorageValue(cid,15012,1)
        doPlayerPopupFYI(cid,"TEXT")
        doPlayerAddMapMark(cid,{x=693, y=1007, z=7},0,"NPC")
    end
Please also use CODE wraps next time, as LUA wraps are harder to edit.

And don't use the same name double.

I suggest you to call it something like 'PlayerLoginFYI'
login/logout events do not need to be registered for players in order to work

we should make some lua tournament here at forum some time
 
excluding cyko ofc, he'd be the judge or somewhat

@unknown
don't regret, it's new knowlegde for you :p

ehm what is pedobear doing here \/
 
Alright.

I changed the number
Code:
local t = 
{     
      [B]storage = 6512,[/B]
      msg = "TEXT",
      pos = {x=693, y=1007, z=7},
	  typ = "0"
}	   
	   
function onLogin(cid)
        if getPlayerStorageValue(cid,t.storage) < 0 then
		 setPlayerStorageValue(cid,t.storage,1)
          doPlayerPopupFYI(cid, t.msg)
           doPlayerAddMapMark(cid, t.pos, t.typ, "NPC")
		   end 
	return TRUE
end


Still nothin~

So i guess register it in Login ? Or what?

NOTE: Im using 0.4 dev
 
Just paste the lines in login.lua, as 'get' commands can sometimes give difficulties.

Code:
if getPlayerStorageValue(cid,15012) < 0 then
        setPlayerStorageValue(cid,15012,1)
        doPlayerPopupFYI(cid,"TEXT")
        doPlayerAddMapMark(cid,{x=693, y=1007, z=7},0,"NPC")
    end
 
why? typ = "0" ??
or typ = 0
0 can be any valid number of the function
 
Im using this script.

Code:
	if getPlayerStorageValue(cid,15012) < 0 then
        setPlayerStorageValue(cid,15012,1)
        doPlayerPopupFYI(cid,"TEXT")
        doPlayerAddMapMark(cid,{x=693, y=1007, z=7},0,"NPC")
    end
in login.lua


Since my script just wont work.
 
Code:
	if getPlayerStorageValue(cid,15012) < 0 then
		setPlayerStorageValue(cid,15012,1)
		doPlayerPopupFYI(cid,"TEXT")
		doPlayerAddMapMark(cid,{x=693, y=1007, z=7},5,"MARK DESC")
    end

try that
 
Naah, nothin heppend.

Isn't there anyway to get these ID's ? ;<
you mean
Lua:
MAPMARK_TICK = 0
MAPMARK_QUESTION = 1
MAPMARK_EXCLAMATION = 2
MAPMARK_STAR = 3
MAPMARK_CROSS = 4
MAPMARK_TEMPLE = 5
MAPMARK_KISS = 6
MAPMARK_SHOVEL = 7
MAPMARK_SWORD = 8
MAPMARK_FLAG = 9
MAPMARK_LOCK = 10
MAPMARK_BAG = 11
MAPMARK_SKULL = 12
MAPMARK_DOLLAR = 13
MAPMARK_REDNORTH = 14
MAPMARK_REDSOUTH = 15
MAPMARK_REDEAST = 16
MAPMARK_REDWEST = 17
MAPMARK_GREENNORTH = 18
MAPMARK_GREENSOUTH = 19
?
 
Code:
doPlayerAddMapMark(cid,{x=693, y=1007, z=7},5,"NPC")

Meybe try to add (") ?

Code:
doPlayerAddMapMark(cid,{x=693, y=1007, z=7},"5","NPC")


you mean
Lua:
MAPMARK_TICK = 0
MAPMARK_QUESTION = 1
MAPMARK_EXCLAMATION = 2
MAPMARK_STAR = 3
MAPMARK_CROSS = 4
MAPMARK_TEMPLE = 5
MAPMARK_KISS = 6
MAPMARK_SHOVEL = 7
MAPMARK_SWORD = 8
MAPMARK_FLAG = 9
MAPMARK_LOCK = 10
MAPMARK_BAG = 11
MAPMARK_SKULL = 12
MAPMARK_DOLLAR = 13
MAPMARK_REDNORTH = 14
MAPMARK_REDSOUTH = 15
MAPMARK_REDEAST = 16
MAPMARK_REDWEST = 17
MAPMARK_GREENNORTH = 18
MAPMARK_GREENSOUTH = 19
?

HEY! Where did u get info? What are you? Some kind of hacker ?
 
Code:
doPlayerAddMapMark(cid,{x=693, y=1007, z=7},5,"NPC")
Meybe try to add (") ?

Code:
doPlayerAddMapMark(cid,{x=693, y=1007, z=7},"5","NPC")

it's

MAPMARK_TEMPLE = 5

not

MAPMARK_TEMPLE = "5"

oh, and 5 = MAPMARK_TEMPLE
 
Back
Top