• 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 Problem in Script of a weapon

ZORAM

New Member
Joined
Aug 6, 2013
Messages
27
Reaction score
0
Hello Guys,

I have a script of a weapon, that uses ammo, and i get a error in console because this function.
Code:
getItemNameById(item.itemid)

Here my script:

>> actions.xml
Code:
<actionitemid="8927"script="new2.lua"/>

Actions > script > new2.lua

Code:
function onUse(cid, item, frompos, item2, topos)


local config = {
storageativ = 76650, -- storage que será utilizado
ammo = 1294  --- id do item que será a munição.
}




if getPlayerStorageValue(cid, config.storageativ) > 0 then
setPlayerStorageValue(cid, config.storageativ, 0)
doPlayerSendTextMessage(cid, 19, "You desactivated your "..getItemNameById(item.itemid)..", you're no longer attacking in area!") 
elseif getPlayerStorageValue(cid, config.storageativ) <= 0 then
setPlayerStorageValue(cid, config.storageativ, 1)
doPlayerSendTextMessage(cid, 19, "You activated your "..getItemNameById(item.itemid)..", now you'll attack in area for the price of a "..getItemNameById(config.ammo).."!") 
end
return true
end

ScreenShot Error:

ZjkB1n2.png


I thank for Help, and with be God! :)
 
Use getItemName instead of getItemNameById.
Now i get a error, that my weapon not function, i only get the feadback of script.

Code:
doPlayerSendTextMessage(cid, 19, "You desactivated your "..getItemNameById(item.itemid)..", you're no longer attacking in area!")

and

Code:
doPlayerSendTextMessage(cid, 19, "You activated your "..getItemNameById(item.itemid)..", now you'll attack in area for the price of a "..getItemNameById(config.ammo).."!")

But thank you for help me!
 
You have to change getItemNameById to getItemName there aswell.
This error means the function doesn't exist in your server, so you have to change all getItemNameById to getItemName.
You can also add this in global.lua.
Code:
getItemNameById = getItemName
 
Back
Top