Dzsozi (h03) Posted November 2, 2016 Share Posted November 2, 2016 (edited) Hello! I made a passive mode script for players, so when they type in /passive they can go into passive mode, so they can't get killed, etc. But I am also making a free time event system, where you can hijack cars, be a bounty and etc, and I would like to prevent people going into passive mode while doing the mission. So for example when they get into the car that needs to be hijacked, they can't use passive mode, but when they exit that specific car they can use the passive mode again. I made a script for that, and it works, but I keep getting these errors: vice_events/bounty/bountyS.lua:43 Bad usage @ 'addEventHandler' ['onPlayerCommand' with this function is already handled] Here's a part of the bounty script where I made these event handlers: local function preventPassiveMode(command) if command == "passive" then exports.vice_notification:addNotificationGTA(source, "Jelenleg nem használhatod a passzív módot!") cancelEvent() end end function bountyThatGuy() if #players > 1 then p = getRandomPlayer() if (getElementData(p, "passivezoneprotected") == false) and (getElementData(p, "passivemode") == false) then randomReward = math.random(#possibleRewards) currentReward = possibleRewards[randomReward][1] if isTimer(bountySurviveTimer) then killTimer(bountySurviveTimer) bountySurviveTimer = nil end for i = 1, #players do v = players[ i ] if v ~= p then exports.vice_notification:addNotificationGTA(v, "" .. getPlayerName( p ) .. " fejére $" .. currentReward .. " vérdíjat tűztek ki!") end triggerClientEvent(p, "sendBountyNotification", p, p, currentReward) setElementData(p, "playerbounty", true) addEventHandler("onPlayerCommand", p, preventPassiveMode) end bountySurviveTimer = setTimer(function() if v ~= p then exports.vice_notification:addNotificationGTA(v, "" .. getPlayerName( p ) .. " túlélte a vadászatot, ezért megkapta a fejére kitűzött vérdíjat jutalmul!") end exports.vice_notification:addNotificationGTA(p, "Túlélted a vadászatot, ezért megkaptad a fejedre kitűzött vérdíjat jutalmul!") setElementData(p, "playerbounty", false) removeEventHandler("onPlayerCommand", p, preventPassiveMode) end, timeToSurvive*60000, 1) else setTimer( bountyThatGuy, 1000, 1 ) end else setTimer( bountyThatGuy, 10000, 1 ) end end setTimer( bountyThatGuy, 5000, 1 ) And where I set the "playerbounty" element data of the player to false I removed the event handler. Why do I keep getting these errors/warnings if the script itself works? And how can I fix it? Edited November 2, 2016 by Dzsozi Link to comment
pa3ck Posted November 3, 2016 Share Posted November 3, 2016 (edited) Please don't bump your topic, this is not an advertising website, somebody will come along and help you when / if they can. The onPlayerCommand is inside the loop, meaning it will run number of times. Shouldn't it be inside the if v ~= p then .. statement? By the way, you will probably want to use this somewhere else (player can't go passive). I think it would be better to use use a table or setElementData to save their status, because that way you will be able to prevent it from other resources as well. Edited November 3, 2016 by pa3ck Link to comment
Dzsozi (h03) Posted November 6, 2016 Author Share Posted November 6, 2016 Sorry for the bumping, and thank you for your help! 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