• 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 !
 
PHP:
local t = 
{     
      storage = 15012,
      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 NAME")
	return TRUE
end


Alright, here it is.

Now heres the question!
storage = 15012,
What's that good for ? I dont get it.

These should be enough -
if getPlayerStorageValue(cid,t.storage) < 0 then
setPlayerStorageValue(cid,t.storage,1)
Right?




GOD DAMN! I NEVER WANTED Cykotitan TO SEE THIS :'<
2ng4fh0.jpg
 
Lua:
  local position = {x=693, y=1007, z=7}   
function onLogin(cid)
  return doPlayerPopupFYI(STARTER_OUTFITID, "Welcome! Young master, if you go north east from here you reach Dr. Oak'/s lab. Talk with him and get your starting pokemon!") and doPlayerAddMapMark(STARTER_OUTFITID, position, 0, "Dr. Oak") and if getPlayerStorageValue(cid, 15012) < 0 then,  setPlayerStorageValue(cid, 15012, 1) 
end
 
Lua:
local text = "Welcome! Young master, if you go north east from here you reach Dr. Oak's lab. Talk with him and get your starting pokemon!", 
   local position = {x=693, y=1007, z=7}, 
   local type = "0"  
   
function onLogin(cid)
  return doPlayerPopupFYI(STARTER_OUTFITID, text) and doPlayerAddMapMark(STARTER_OUTFITID, position, type, "Dr. Oak") and if getPlayerStorageValue(cid, 15012) < 0 then,  setPlayerStorageValue(cid, 15012, 1) 
end

................. -.-
 
wibben ffs go to lua kindergarden you ignored return true <.< and other billionesimal errors
 
getPlayerStorageValue() will check if a player has a certain storage value in the database.

if he doesn't it will be value -1, and hidden, that's why I use '< 0'.

and setPlayerStorageValue() will set the certain storage value to a certain value.

So, I made a condition that when a player doesn't have the storage 15012 and the value is below 0 (-1), it will execute the script, but if the storage value is above 0 it will skip that user.

Code:
local t = 
{     
      storage = 15012,
      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 NAME")
        [B]end[/B]
    return TRUE
end
 
hmmmm! When i created a new character, nothin heppend.

Script -
PHP:
local t = 
{     
      storage = 15012,
      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


PHP:
<event type="login" name="PlayerLogin" event="script" value="welcome.lua"/>



edit : Ohh, could it be.. I forgot the outfit ID in "cid" ..
 
change storage to a random one, unused, then reload creature events and login again with any char
 
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'
 
Back
Top