• 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 Take A Look At My Own Made Script

bochy1234

Mr. Orange
Joined
Jan 29, 2012
Messages
136
Reaction score
3
Location
Cairo,Egypt
Hello
I Am A Beginner LUA Scripter
And Thats My Very First Script

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.item id ==8977 then
if getplayerlevel =< 180 then
doplayersendtextmessage (cid,COLOR_DARKYELLOW,"It Works !")
getPlayerLevel(cid) ==190
doSendAnimatedText(pos,"Congratulations Your Now Level 190",5)
Else
Doplayersendcancel (cid,"Your Level Is Too Low To Use It")
End
If getplayerlevel >= 190 then
Dosendplayercancel (cid,"Your Level Is Too High")
End
if item.itemid ==9002 then
DoplayersendCancel (Cid,"Seems Like You Used The Wrong Book")
end
Return TRUE
end
 
And you want help with it making it work?
Well, I can start by saying you used the capitals wrong, you have to write (cid) after getPlayerLevel, like this: if getPlayerLevel(cid) >= 180 then, you can write them in 1 line like this: if getPlayerLevel(cid) >= 180 and getPlayerLevel(cid) <= 190 then.
About the capitals, never use them with words like: if, end, return, else, cid and with functions, start without capital and use capitals for the other words.
For the animated text you have pos, but no local of it and the text is to long, you can use it like this: doSendAnimatedText(getPlayerPosition(cid),"text", TEXTCOLOR_BLUE)
Also the textmessage type (from doPlayerSendTextMessage) isn't for this function. you can look in 000-constant.lua for MESSAGE_ to see which ones you can use and it's doPlayerSendCancel and not doSendPlayerCancel.
 
Last edited:
Oh, I read it wrong :p
Well I don't really need a script, at least, not 1 you can make (for beginners) :D and I'm not sure if this is the right board for this.
But lets think of a really easy script to make that isn't completely worthless...

Try this:
You use an item, it gives you 500 experience, you get a green textmessage with: you got 500 experience, then the item disappears. If you try to use the item again it says: You can only use this item once.

Or try a bit harder one:
You use an item, it gives you 500 extra movement speed for 10 seconds, it shows an animated text in red with: speed, you get a magic effect (your choise) and then the item disappears.

Btw you can also look in requests or support if people need help with easy scripts, you can test them yourself in a server and your console will show with errors what is wrong with the script.
 
The code: COLOR_DARKYELLOW exists, but it's not for the doPlayerSendTextMessage function like I said in my first post, so ye it will give an error if you use it like that.
 
Here Is The First One ( Can't Make The Second Use Stuff)

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.item id ==6103 then
doPlayerAddExperience(cid, 500)
doSendAnimatedText(getPlayerPosition(cid),"You Got 500 Experience!", TEXTCOLOR_GREEN)
end
return TRUE
end

And Ill Try Helping Newbies On Requests :)
 
You don't have to use this line "if item.itemid == 6103 then" if you are only using 1 item in a script, I said textmessage not animated text :p, you forgot to let the script remove the item and to add storage, but good luck and don't forget to use a server to test your scripts. With the errors you get, you can understand your own mistakes.
 
Back
Top