• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action My first script attempt

GhostX

Mapping Board Moderator
Staff member
Board Moderator
Joined
Nov 2, 2011
Messages
6,049
Reaction score
1,804
Location
UK
Twitch
ghostxpr0
I needed a pretty simple script, but i have no scripting experience at all apart from understanding through editing of functions.

However, i don't necessarily understand what goes where, etc :p

So here is my attempt at making a script where you click use on an item, and you get a bp with items inside:


Guess it's for 0.3~

LUA
XML:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerLevel (cid > 50) do
local backpack = doPlayerAddItemEx(cid, 1988, 1)
doAddContainerItem(backpack, 2457, 1)
doAddContainerItem(backpack, 2173, 1)
doAddContainerItem(backpack, 2524, 1)
doAddContainerItem(backpack, 2463, 1)
doAddContainerItem(backpack, 2152, 1)
doAddContainerItem(backpack, 2383, 1)
doAddContainerItem(backpack, 2647, 1)
doAddContainerItem(backpack, 2394, 1)
doAddContainerItem(backpack, 2643, 1)
doAddContainerItem(backpack, 2387, 1)
doAddContainerItem(backpack, 2389, 1)
doAddContainerItem(backpack, 2182, 1)
doAddContainerItem(backpack, 2190, 1)
doPlayerSendTextMessage (cid,22,"You have received the beginner set!")
else
doPlayerSendCancel(cid,"You don't have the required level to use this.")
return true
end

XML:
XML:
<action actionid="" event="script" value=".lua"/>

If this right?
 
Last edited:
no forget beginner set, it will be edited for different sets, i.e quest instead of using chests in some cases, i i have in my temple beginner, adept and master sets where player gets certain level they use it and poof get a set.

And this is my first script so forget what it's for, i just wanna know if it is correct
 
Why don't you test it on your server?
No offense, but I guess people can't be arsed to test stuff for you just to satisfy your curiosity ;)
Again, I don't want to insult you here, I want to understand you.

*Sidenote*
It would be nice if you added the server version you scripted this.
So people using old engines know that it won't work on theirs.

Edit:
if getPlayerLevel(cid) > 50 do
missed a ")"
 
Yh but atm i don't have a downloaded server, haha i was attempting it, so far i have only made the map.

Also i have no idea whether 0.2 or 0.3 but i probably guess 0.3 since i used evilhero's tutorial.

But regarding my script, it should work ? XD

It is my first script anyway
 
Aaah, gotcha!
But in all honesty and all due to respect, download a server and test it out before actually releasing it.
Somer users here might be ignoring this script and just post stuff like "Noobscript! no work!"
Edit:
no it wont work
See what I mean? ^_^

Just be prepared :)

For the script:
"returnTrue"
should be
"return true"
also
local backpack = doPlayerAddItem(cid, 1988, 1)
I guess it should be
local backpack = doPlayerAddItemEx(cid, 1988, 1)
I can't test it yet, @work right now, maybe someone else will.

Anyway, consider my suggestion please.
 
Ok will do :) thanks, and yh i see, you're the only one who attempting to help me :) thanks,
and i'll download a server anyway since i will need one eventually :)

cheers

regards
 
Well explain how it should be? since it is my very first script, and need a fair amount of "nudging" in the right direction ;)
cheers anyway

And i got that from evil hero's tutorial.. :s
 
it won't work because of " local backpack = doPlayerAddItem(cid, 1988, 1)"
that's not how u do tables

Get your facts straight at first please, you're wrong.
It works.
In fact it's done in quite some standard scripts in any OTengine.
Also check out "firstitems.lua" or the script adding equipment to a new player.

You could also use:
local item = doCreateItem(blabla)
 
@up ahh ok good, i thought it wouldn't be wrong considering evil hero's tutorial states it lol

Thanks for help
 
Yh someone already spotted that, i changed it on here but after editing the script in notepad++ i forgot to change it again when i posted it, cheers for re-noticing it :p:p
 
still wrong
if getPlayerLevel (cid) > 50 then
the ) should be after cid not 50
and do should be then
 
Back
Top