Jokeℝ1472771893 Posted July 24, 2012 Share Posted July 24, 2012 teamcivil = createTeam ("Civilian Jobs",255,255,0) local hook= createMarker (1978.3990478516,-1784.8236083984,13, "cylinder", 1.5,255,0,255) function hookjob( hitPlayer, matchingDimension ) fadeCamera(hitPlayer,false,1 ) setTimer(fadeCamera,1000,1,hitPlayer,true,5 ) setPlayerTeam ( hitPlayer, teamcivil ) setElementData ( hookjob, "Occupation", "Hooker" ) takeAllWeapons ( hitPlayer ) giveWeapon ( hitPlayer, 12, 1 ) setPlayerNametagColor ( hitPlayer,255,0,255 ) setElementModel ( hitPlayer, 85 ) end addEventHandler( "onMarkerHit",hook,hookjob ) when i hit marker my team set to Civilian Jobs i don't have occupation please help Link to comment
TAPL Posted July 24, 2012 Share Posted July 24, 2012 line 7 change hookjob to hitPlayer Edit: and try to organize your code. Link to comment
Jokeℝ1472771893 Posted July 24, 2012 Author Share Posted July 24, 2012 thnx and how to make this job by Occupation now by team? addEventHandler("onPlayerLogin", root, function() setTimer( function(source) if isPlayerInTeam(source, "Mechanics") then triggerClientEvent(source, "setMechanic", source) setElementData(source, "canFix", true) end setElementData(source, "orderedMechanic", false) end , 500, 1, source) end ) Edit:look line 5 Link to comment
TAPL Posted July 24, 2012 Share Posted July 24, 2012 replace if isPlayerInTeam(source, "Mechanics") then to local team = getPlayerTeam(source) if team and getTeamName(team) == "Mechanics" then Link to comment
Jokeℝ1472771893 Posted July 24, 2012 Author Share Posted July 24, 2012 Tapl i mean i whant it works not by team.i whant it work by occupation (if player occupation is Mechanic hecan spawn vehicle for exampl) Link to comment
TAPL Posted July 24, 2012 Share Posted July 24, 2012 Tapl i mean i whant it works not by team.i whant it work by occupation (if player occupation is Mechanic hecan spawn vehicle for exampl) ah you mean using the element data? if getElementData(source, "Occupation") == "Mechanics" then Link to comment
Jokeℝ1472771893 Posted July 24, 2012 Author Share Posted July 24, 2012 ya thnx wait i will try okey Link to comment
Jokeℝ1472771893 Posted July 24, 2012 Author Share Posted July 24, 2012 can i ask another question here? or i need to open new topic? Link to comment
Jokeℝ1472771893 Posted July 24, 2012 Author Share Posted July 24, 2012 ok when i go to destanation the car destroyed and i can' see another blip how to fix it? addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function () missionXML = xmlLoadFile("truckmissions.xml"); end ) TruckMissionMarker = createMarker (-76, -1136, 1, "cylinder", 2, 255, 0, 0, 127, getRootElement()) TruckingMinigameBlip = createBlipAttachedTo ( TruckMissionMarker, 51, 2, 0, 0, 255, 255, 0, 250, getRootElement() ) addEventHandler ("onMarkerHit", getRootElement(), function (hitElement, matchingDim) if (source == TruckMissionMarker) and (getElementType(hitElement) == "player") then if not (isGuestAccount (getPlayerAccount (hitElement))) then local lastTruckMission = getAccountData (getPlayerAccount (hitElement), "lastTruckMission") if (lastTruckMission) then preTruckMission (hitElement, tonumber(lastTruckMission)+1) else preTruckMission (hitElement, 0) end end end if (getElementType (hitElement) == "vehicle") and (getElementID (hitElement) == "missiontruck") and (getElementID (source) == "TruckFinishMarker") and (getVehicleOccupant (hitElement)) then local markerParent = getElementParent (source) local truckParent = getElementParent (hitElement) if (markerParent == truckParent) then local reward = getElementData (markerParent, "reward") local damage = getElementHealth (hitElement) local exactReward = (damage / 1000 * reward ) local actualReward = math.round(tonumber(exactReward)) givePlayerMoney (getVehicleOccupant(hitElement), actualReward) local thePlayer = getVehicleOccupant(hitElement) outputChatBox ("#00aafftruck Mission:#ffffff Mission passed! You've won $" .. tostring(actualReward) .. "!", getVehicleOccupant(hitElement), 255, 255, 255, true) destroyElement (markerParent) triggerClientEvent (thePlayer, "ClientHideTruckMissionGUI", thePlayer) if not isGuestAccount (getPlayerAccount(thePlayer)) then local lastTruckMission = getAccountData (getPlayerAccount (thePlayer), "lastTruckMission") if (lastTruckMission) then setAccountData ( getPlayerAccount (thePlayer), "lastTruckMission", tonumber(lastTruckMission) +1) else setAccountData ( getPlayerAccount (thePlayer), "lastTruckMission", 0) end end end end end ) function preTruckMission (thePlayer, number) local missionroot = xmlFindChild (missionXML, "mission", number) if (missionroot) and (xmlNodeGetAttributes (missionroot)) then local misAtt = xmlNodeGetAttributes (missionroot) local title = misAtt["title"] local time = tostring (tonumber(misAtt["time"])) .. " seconds" local truckname = getVehicleNameFromModel(tonumber(misAtt["truck"])) local reward = tostring (misAtt["reward"]) .. " $" local description = xmlNodeGetValue (missionroot) triggerClientEvent (thePlayer, "ClientStartTruckMission", thePlayer, number, title, time, truckname, description, reward) else outputChatBox ("#00aaffTruck Mission:#ffffff All missions sucessfully done", thePlayer, 255, 255, 255, true) end end addEvent ("ServerStartTruckMission", true) addEventHandler ("ServerStartTruckMission", getRootElement(), function() if not (getElementByID (getPlayerNametagText (source) .. "_mission")) then if not (isGuestAccount (getPlayerAccount (source))) then local lastTruckMission = getAccountData (getPlayerAccount (source), "lastTruckMission") if (lastTruckMission) then number = tonumber(lastTruckMission) +1 else number = 0 end end local missionroot = xmlFindChild (missionXML, "mission", number) local misAtt = xmlNodeGetAttributes (missionroot) local title = misAtt["title"] local time = tonumber(misAtt["time"]) local truckId = tonumber(misAtt["truck"]) local x = tonumber(misAtt["x"]) local y = tonumber(misAtt["y"]) local z = tonumber(misAtt["z"]) local reward = tonumber(misAtt["reward"]) local description = xmlNodeGetValue (missionroot) local truck = createVehicle (truckId, -81, -1127, 2, 0, 0, 65, "MISSION") local trailer = createVehicle (584, 0, 0, 0, 0, 0, 0, "MISSION") attachTrailerToVehicle(truck, trailer) local destinationMarker = createMarker (x, y, z, "cylinder", 5, 0, 255, 255, 128, source) destinationBlip = createBlipAttachedTo (destinationMarker, 53, 2, 255, 255, 255, 255, 0, 9999, source ) local truckJobElement = createElement ("truckMission", getPlayerNametagText(source) .. "_mission") setElementData (truckJobElement, "reward", reward) warpPedIntoVehicle (source, truck) setVehicleLocked (truck, true) setElementData (truck, "TruckMisison", true) setElementID (truck, "missiontruck") setElementID (destinationMarker, "TruckFinishMarker") setElementID (destinationBlip, "TruckDestinationBlip") setElementParent (truck, truckJobElement) setElementParent (destinationMarker, truckJobElement) setElementParent (destinationBlip, truckJobElement) setElementParent (trailer, truckJobElement) setTimer(endTruckMission, time*1000, 1, source) triggerClientEvent (source, "ClientShowTruckMissionGUI", source) else outputChatBox ("#00aaffTruck Mission:#ffffff First finish your current mission!", source, 255, 255, 255, true) end end ) function math.round(number, decimals, method) decimals = decimals or 0 local factor = 10 ^ decimals if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor else return tonumber(("%."..decimals.."f"):format(number)) end end Link to comment
TwiX! Posted July 24, 2012 Share Posted July 24, 2012 (edited) createBlipAttachedTo https://wiki.multitheftauto.com/wiki/Cre ... AttachedTo blip createBlipAttachedTo ( element elementToAttachTo, [int icon=0, int size=2, int r=255, int g=0, int b=0, int a=255, int ordering=0, float visibleDistance=99999.0, visibleTo = getRootElement()] ) createBlipAttachedTo ( theDestination, 0, 3, 0, 0, 255, 255, 0, 99999, thePlayer ) too much big size(distance) visibleDistance: The maximum distance from the camera at which the blip is still visible (0 - 65535) ok when i go to destanation the car destroyed and i can' see another blip how to fix it? Coz you make marker ONE time (when the player started working/when reousrce start) Edited July 24, 2012 by Guest Link to comment
Jokeℝ1472771893 Posted July 24, 2012 Author Share Posted July 24, 2012 Twix what is that? O_o? Link to comment
TwiX! Posted July 24, 2012 Share Posted July 24, 2012 Twix what is that? O_o? it was your code, you changed it @if i will hotfix your code, you will never understand(learn) lua @will ctrl+c,ctrl+v Link to comment
Jokeℝ1472771893 Posted July 24, 2012 Author Share Posted July 24, 2012 but Tapl how to make if player occupation is Pilot then i can see marker for exampl? Link to comment
Castillo Posted July 24, 2012 Share Posted July 24, 2012 You can use: setElementVisibleTo Link to comment
Jokeℝ1472771893 Posted July 24, 2012 Author Share Posted July 24, 2012 but this is by team Link to comment
Castillo Posted July 24, 2012 Share Posted July 24, 2012 Hide the blip to everyone, then loop all players of that team and set it visible to them. Link to comment
Jokeℝ1472771893 Posted July 24, 2012 Author Share Posted July 24, 2012 i know what i need to do but i don't know script Link to comment
scratcher911 Posted July 24, 2012 Share Posted July 24, 2012 setElementVisibleTo( element, getRootElement(), false ) for k, v in ipairs (getElementsByType("player")) do if getTeamName(getPlayerTeam(v)) == "TEAMNAME" then setElementVisibleTo(element, v, true ) end end Link to comment
Castillo Posted July 24, 2012 Share Posted July 24, 2012 It's easier to get the players in the team using: getPlayersInTeam Link to comment
scratcher911 Posted July 24, 2012 Share Posted July 24, 2012 I didn't know that this function exist. Thanks Solid 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