Ryan123 Posted February 13, 2016 Share Posted February 13, 2016 hello there, I'm creating this topic because I already tried fix it but I still to not fix it. Bug: When someone go to that marker, the next one cannot go to that marker Objetive: When someone go to that marker, next one should go there for have for delivery the goods. Script function Mission2(px, py, pz, pb, dx, dy, dz, db, name, t) if (currentlyEvent == true) then outputChatBox("Already an event going on", client) return end pMarker = createMarker ( px, py, pz-1, "cylinder", 2, 255, 167, 0, 255) pBlip = createBlipAttachedTo ( pMarker, pb) dMarker = createMarker ( dx, dy, dz-1, "cylinder", 2, 255, 167, 0, 255) dBlip = createBlipAttachedTo ( dMarker, db) setElementVisibleTo ( dMarker, root, false ) setElementVisibleTo ( dBlip, root, false ) local city = getZoneName(px, py, pz, true) local zone = getZoneName(px, py, pz) eventName = "for delivery their cups of glasses to IKEA!" timer = setTimer(messageForCivilians,50,0,name, eventName, city, zone, pMarker, pBlip) --timing = (deliveryStuff, t*1000*60, 1) outputChatBox("You created an Event: "..eventName, root) currentlyEvent = true addEventHandler ("onMarkerHit", pMarker, pickupStuff) end addEvent("SOEvent.startDeliveryGlasses", true) addEventHandler("SOEvent.startDeliveryGlasses", root, Mission2) function pickupStuff (plr) for i, plr in ipairs(getElementsByType ( "player" )) do if (isPedInVehicle ( plr )) then if (not deliveryVehicles[getElementModel ( getPedOccupiedVehicle ( plr ) )] ) then outputChatBox("You need one vehicle of delivery man!", plr) return end if (getElementHealth(getPedOccupiedVehicle ( plr ))/10 <= 95) then outputChatBox("You need fix your car. Is below 95%", plr) return end if (not isPlayerInTeam(plr, "Civilian Workers")) then return end removeEventHandler ("onMarkerHit", pMarker, pickupStuff) setElementVisibleTo ( pMarker, plr, true ) setElementVisibleTo ( pBlip, plr, true ) setElementVisibleTo ( dMarker, plr, true ) setElementVisibleTo ( dBlip, plr, true ) setElementVisibleTo ( pMarker, plr, false ) setElementVisibleTo ( pBlip, plr, false ) addEventHandler ("onMarkerHit", dMarker, deliveryStuff ) outputChatBox("Delivery the glasses at IKEA!", plr) end end end Link to comment
Dimos7 Posted February 13, 2016 Share Posted February 13, 2016 use debugscript 3 and see what error makes also put whole code Link to comment
tosfera Posted February 13, 2016 Share Posted February 13, 2016 isPlayerInTeam is an usefull function and requires you to add that piece of code in the script itself too. If you forgot that, it's simply not going to work. either add this to the same file; function isPlayerInTeam(player, team) assert(isElement(player) and getElementType(player) == "player", "Bad argument 1 @ isPlayerInTeam [player expected, got " .. tostring(player) .. "]") assert((not team) or type(team) == "string" or (isElement(team) and getElementType(team) == "team"), "Bad argument 2 @ isPlayerInTeam [nil/string/team expected, got " .. tostring(team) .. "]") return getPlayerTeam(player) == (type(team) == "string" and getTeamFromName(team) or (type(team) == "userdata" and team or (getPlayerTeam(player) or true))) end or change this; if (not isPlayerInTeam(plr, "Civilian Workers")) then return end to if ( getPlayerTeam ( plr ) ~= getTeamFromName ( "Civilian Workers" ) ) then return end Link to comment
Ryan123 Posted February 13, 2016 Author Share Posted February 13, 2016 (edited) I've that usefull function at my script. I just posted only that 2 functions cause I want do that: One player hit the marker and then another should do too it. And what's happening now is one player hit the marker and then another one cannot pick the marker. If I remove the "removeEventHandler", the script will appear that "[2016-02-12 23:32:48] WARNING: event\server.lua:117: Bad usage @ 'addEventHandler' ['onMarkerHit' with this function is already handled]" This is mentioning that part: addEventHandler ("onMarkerHit", dMarker, deliveryStuff ) Edited February 13, 2016 by Guest Link to comment
tosfera Posted February 13, 2016 Share Posted February 13, 2016 Might be caused by the currentlyEvent, you should try to play around with that. I don't have my own computer here so I can't mess around too much without being caught by my boss. Link to comment
Ryan123 Posted February 13, 2016 Author Share Posted February 13, 2016 So no away for fix it? Edit: Already fixed local hit = {} function Mission2(px, py, pz, pb, dx, dy, dz, db, name, t) if (currentlyEvent == true) then outputChatBox("Already an event going on", client) return end pMarker = createMarker ( px, py, pz-1, "cylinder", 2, 255, 167, 0, 255) pBlip = createBlipAttachedTo ( pMarker, pb) dMarker = createMarker ( dx, dy, dz-1, "cylinder", 2, 255, 167, 0, 255) dBlip = createBlipAttachedTo ( dMarker, db) setElementVisibleTo ( dMarker, root, false ) setElementVisibleTo ( dBlip, root, false ) local city = getZoneName(px, py, pz, true) local zone = getZoneName(px, py, pz) eventName = "for delivery their cups of glasses to IKEA!" timer = setTimer(messageForCivilians,50,0,name, eventName, city, zone, pMarker, pBlip) --timing = (deliveryStuff, t*1000*60, 1) outputChatBox("You created an Event: "..eventName, root) currentlyEvent = true addEventHandler ("onMarkerHit", pMarker, pickupStuff) end addEvent("SOEvent.startDeliveryGlasses", true) addEventHandler("SOEvent.startDeliveryGlasses", root, Mission2) function pickupStuff (plr) for i, plr in ipairs(getElementsByType ( "player" )) do if (isPedInVehicle ( plr )) then if (not deliveryVehicles[getElementModel ( getPedOccupiedVehicle ( plr ) )] ) then outputChatBox("You need one vehicle of delivery man!", plr) return end if (getElementHealth(getPedOccupiedVehicle ( plr ))/10 <= 95) then outputChatBox("You need fix your car. Is below 95%", plr) return end if (not isPlayerInTeam(plr, "Civilian Workers")) then return end if ((hit[plr] == true) and (isElementWithinMarker ( plr, pMarker)) then cancelEvent () return end hit[plr] = true setElementVisibleTo ( pMarker, plr, true ) setElementVisibleTo ( pBlip, plr, true ) setElementVisibleTo ( dMarker, plr, true ) setElementVisibleTo ( dBlip, plr, true ) setElementVisibleTo ( pMarker, plr, false ) setElementVisibleTo ( pBlip, plr, false ) addEventHandler ("onMarkerHit", dMarker, deliveryStuff ) outputChatBox("Delivery the glasses at IKEA!", plr) end end end 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