• 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 Good Scripter? Take a Look?

Maxwel1

Legend Of Everything
Joined
Feb 3, 2009
Messages
196
Reaction score
1
Location
In The Jungle
ok here we go ans wish someone really help. i was thinking about doing 2 talkactions 1st is to additem to the player (!reward (player name)) and with that command i will give the player a special item with uid (unique id) . why uniqueid? u will know in the next command.

here is the first script for the !reward command. for sure it's not working that's why i am posting in the support section. the error is: [14/02/2009 06:56:17] Warning: [Event::loadScript] Can not load script. data/talkactions/scripts/additem.lua
[14/02/2009 06:56:17] data/talkactions/scripts/additem.lua:12: '<eof>' expected near 'else'



The script:


Code:
functionOnSay(cid, words, param)

local player = functiontogetplayergroupbyname(param)

local itemid = 2473 --place the id here
local uid = 23223 --place the uid here


getplayergroupbyname(param)
doPlayerAddItem(uid, itemid, 1, 0)

else
			doPlayerSendCancel(cid,"You need to enter a player.")

end



The 2nd command is the opposite it's !unreward this command remove that item that got the uid from anywhere if the player put it in a house in the depot or even fell from him when he died and another player looted it. that's why i need the item to have uid. yea for sure that item will be only one in the whole server. i know that and i want that really


the error of the second command:

[14/02/2009 06:56:17] Warning: [Event::loadScript] Can not load script. data/talkactions/scripts/removeitem.lua
[14/02/2009 06:56:17] data/talkactions/scripts/removeitem.lua:5: '<eof>' expected near 'end'


the script of the second command:


Code:
functionOnSay(cid, words, param)
local itemid = 2473
local uid = 23223
doRemoveItem(uid, 1)
end


yea, i am sure i missed alot of part in that script but i am still learning and the best thing for learning is trying to do something like never made b4 and try to know ur mistakes. but this is not a test script i really need that script and i am sure later ppl will need it as it will be soo useful to do with it alot of events....



if u helped me. will be soo much appreciated but if u know the solution and didn't help that will be soo mean. cuz when u help someone today another will help u later ;)



Thanks alot


Yours:

Lion
 
sorry but didn't work :(. the error: [14/02/2009 07:13:07] Warning: [Event::loadScript] Can not load script. data/talkactions/scripts/additem.lua
[14/02/2009 07:13:07] data/talkactions/scripts/additem.lua:12: 'end' expected (to close 'function' at line 1) near 'else'


Also, what about the other one man? the !unreward?

also when i edited the !unreward one (added space between function and onsay) that error appeared: Warning: [Event::loadScript] Event onSay not found. data/talkactions/scripts/removeitem.lua


Thanks for trying to help really so appreciated.

Edit: After coping ur script i had that error :( :( :( : [14/02/2009 07:27:03] Lua Script Error: [TalkAction Interface]
[14/02/2009 07:27:03] data/talkactions/scripts/additem.lua:onSay

[14/02/2009 07:27:03] data/talkactions/scripts/additem.lua:3: attempt to call global 'functiontogetplayergroupbyname' (a nil value)
[14/02/2009 07:27:03] stack traceback:
[14/02/2009 07:27:03] data/talkactions/scripts/additem.lua:3: in function <data/talkactions/scripts/additem.lua:1>

also no one told me about the second talkaction what's wrong with it?



Yours:

Lion
 
Last edited:
Your scripts where made like by a baby, so here it is fixed:

PHP:
function onSay(cid, words, param)
	if param == "" then
		doPlayerSendCancel(cid,"You need to enter a player.")
return TRUE
end
local itemid = 2473 --place the id here
	if param then
local pid = getPlayerByNameWildcard(param)
		doPlayerAddItem(pid, itemid, 1)
		doPlayerSendTextMessage(cid, 22, "You rewarded "..getCreatureName(pid).." with a "..getItemNameById(itemid)..".")
		doPlayerSendTextMessage(pid, 22, "You received a "..getItemNameById(itemid).." reward from "..getCreatureName(cid)..".")
		doSendMagicEffect(getPlayerPosition(cid), 39)
		doSendMagicEffect(getPlayerPosition(pid), 39)
		return TRUE
	end
return true
end

2.

PHP:
function onSay(cid, words, param)
	if param == "" then
		doPlayerSendCancel(cid,"You need to enter a player.")
return TRUE
end
local itemid = 2473 --place the id here
	if param then
local pid = getPlayerByNameWildcard(param)
	if getPlayerItemCount(pid, itemid) > 0 then
		doPlayerRemoveItem(pid, itemid, 1)
		doPlayerSendTextMessage(cid, 22, "You removed a item from "..getCreatureName(pid)..".")
		doSendMagicEffect(getPlayerPosition(cid), 39)
		doSendMagicEffect(getPlayerPosition(pid), 39)
		return TRUE
	else
		doPlayerSendTextMessage(cid, 22, ""..getCreatureName(pid).." doesnt have that item in his backpack!")
	end
	end
return true
end
 
yea man i said i am not cool at scripting and just beginner but what u did not what i want really i need just to add an item with unique id and it will be special item. just one in the whole server. and the !unreward command removes that item from anywhere it is cuz maybe it fell from the oplayer i gave it to him or he put it in his depot or house. so i need it with uid using the new functions of tfs 0.3 :( not like what u did. it's special talkactions for special events

But really soo appreciated and i mean it and which really someone help me. i am like no way to do that script?!!!!


although there is functions for it?!



Thank you again


Yours:

Lion
 
Back
Top