Discord Moderators Pirulax Posted August 8, 2017 Discord Moderators Share Posted August 8, 2017 Okey, i have made this small function: addEvent("onClientWantToExecuteCommandHandler",true) addEventHandler("onClientWantToExecuteCommandHandler",resourceRoot,function(playername, item,value,count,source) if (getElementData(source,"acc:admin") or 0 >= 6) then local sourcePlayer = source local rovid = "#398FB1[GreenStone - Inventory] #ffffff" if id and item and value and count and source then local targetPlayer, targetPlayerName = exports.mta_main:findPlayer(sourcePlayer, playername) if targetPlayer then if giveItem(targetPlayer, tonumber(item), tostring(value), tonumber(count), 0) then -- 0 -> dutyitem if not (source==targetPlayer) then outputChatBox(rovid.. " Adott egy itemet neked: #43cd80".. getElementData(playerSource,"char:anick") .."#ffffff (" ..exports["mta_item2"]:getItemName(tonumber(item))..")", targetPlayer,255,255,255,true) end outputChatBox(rovid.. " Adtál egy itemet neki: #43cd80".. targetPlayerName:gsub("_", " ") .."#ffffff (" ..exports["mta_item2"]:getItemName(tonumber(item))..")", source,255,255,255,true) dbExec(con, adminlog, getElementData(playerSource, "char:anick"), getElementData(playerSource, "acc:id"), "GIVEITEM", getElementData(playerSource, "char:anick") .. " adott " .. count .. " db " .. exports["mta_item2"]:getItemName(tonumber(item)) .. " -t. Érték: " .. value .. "", getPlayerName(targetPlayer), getElementData(targetPlayer, "acc:id")) exports.mta_admin:outputAdminMessage("#43cd80" .. getElementData(playerSource, "char:anick") .. "#ffffff adott " .. count .. " darab " .. exports["mta_item2"]:getItemName(tonumber(item)) .. " -t #43cd80" .. targetPlayerName .. "#ffffff játékosnak.") else outputChatBox("#43cd80[" .. serverName .. " #43cd80- Inventory]: #ffffffNem fér el több tárgy az adott játékosnál!", playerSource, 255 ,255, 255, true) end end end end end) Its throwing the error on the line 7, but i dont know why... Link to comment
NeXuS™ Posted August 8, 2017 Share Posted August 8, 2017 Are you sure that it's throwing the error at line no. 7? Whats the error? 1 Link to comment
Discord Moderators Pirulax Posted August 8, 2017 Author Discord Moderators Share Posted August 8, 2017 @NeXuS™ [string "?"]:34: attempt to call global 'type'(a number value) as it stays in the title.Im not totally sure, because that "34" is not the actual line where the error is, in the original script its a blank line. Link to comment
NeXuS™ Posted August 8, 2017 Share Posted August 8, 2017 Are you sure you have opened the right file? 1 Link to comment
Discord Moderators Pirulax Posted August 8, 2017 Author Discord Moderators Share Posted August 8, 2017 but if i comment out the 7. line it doesnt throw any error. local targetPlayer, targetPlayerName = exports.mta_main:findPlayer(sourcePlayer, playername) Yeah, im sure. @NeXuS™ Link to comment
NeXuS™ Posted August 8, 2017 Share Posted August 8, 2017 Go to your mta_main and search for the findPlayer function. 1 Link to comment
Discord Moderators Pirulax Posted August 8, 2017 Author Discord Moderators Share Posted August 8, 2017 It should work just perfectly, because with other commands it work. but, i'll take a look at the function Same. @NeXuS™ Link to comment
NeXuS™ Posted August 8, 2017 Share Posted August 8, 2017 I'm pretty sure you are doing something wrong, because the error is referring to a variable called "type", and you don't have that variable used in the script above. 1 Link to comment
Addlibs Posted August 8, 2017 Share Posted August 8, 2017 (edited) The error is, in fact, referring to an attempt to use type as a function (which is, in fact, a function by default) but it seems it's been overridden with a number value. In other words, some part of the code is trying to call type() but type is a number, not a function. Try looking through the code to find something like type = ... -- or local type = ... and change the variable name, don't use type as a variable name as it's already a function. Of course, changing a variable name also means you'll need to change it everywhere else in the code where you referenced it. Edited August 8, 2017 by MrTasty Link to comment
Discord Moderators Pirulax Posted August 8, 2017 Author Discord Moderators Share Posted August 8, 2017 18 hours ago, MrTasty said: The error is, in fact, referring to an attempt to use type as a function (which is, in fact, a function by default) but it seems it's been overridden with a number value. In other words, some part of the code is trying to call type() but type is a number, not a function. Solved the problem, placed the event into another res., isnt the best solution at all, but works Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now