Ascla Posted June 28, 2014 Posted June 28, 2014 (edited) Hey guys, I need your help for use the function call. My script : function hunter(pickupID, pickupType, vehicleModel) if (pickupType == "vehiclechange") then if (vehicleModel == 425) then outputDebugString ("Hunter !") call(getResourceFromName("race_toptimes"), "SMaptimes:getTimeForPlayer", source ) end end end addEventHandler('onPlayerPickUpRacePickup', source, hunter) addEvent('onPlayerPickUpRacePickup', true) function SMaptimes:getTimeForPlayer(player) outputDebugString("Function getTimeForPlayer appelé !") local i = self:getIndexForPlayer( player ) if not i then return false end return self.dbTable.rows[i].timeMs end TopTime meta : ... <export function="SMaptimes:getTimeForPlayer" type="server"/> ... I got this error : ERROR: attempt to call a nil valueERROR: [gamemodes]/..../main.lua:212: call: failed to call 'race_toptimes:SMaptimes:getTimeForPlayer Thank for your help, Edited June 28, 2014 by Guest
Ascla Posted June 28, 2014 Author Posted June 28, 2014 Resource running because I got the Debug "outputDebugString("Function getTimeForPlayer appelé !")".
codeluaeveryday Posted June 28, 2014 Posted June 28, 2014 Quite the problem you have here bro, I think it has to do with the Map Times using OOP. I'm going to give you a small edit and we will see if it works. In the "race_toptimes" resource, add this near the getTimeForPlayer function: local callTimeForPlayer = function(player) sMaptimes:getTimeForPlayer(player) end In the "race_toptimes" resource, export the callTimeForPlayer function. We can now modify your original script: function hunter(pickupID, pickupType, vehicleModel) if (pickupType == "vehiclechange") then if (vehicleModel == 425) then outputDebugString ("Hunter !") call(getResourceFromName("race_toptimes"), "callTimeForPlayer", source ) end end end addEvent('onPlayerPickUpRacePickup', true) addEventHandler('onPlayerPickUpRacePickup', source, hunter) Let me know of your findings, this problem intrigues me.
Ascla Posted June 28, 2014 Author Posted June 28, 2014 I tryed your code but i have always the same error Thank for your help ERROR: attempt to call a nil valueERROR: [gamemodes]/..../main.lua:212: call: failed to call 'race_toptimes:callTimeForPlayer
Ascla Posted June 28, 2014 Author Posted June 28, 2014 I find a solution. I've transfer the script file who called in the script file who was called. I just use the function : TriggerEvent Thanks you so much.
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