Ryan123 Posted May 22, 2012 Share Posted May 22, 2012 (edited) in this script I want spawn one car with occupation(scoreboard), not team.Example: and here is the script: for i,marker in ipairs(markers) do addEventHandler("onClientMarkerHit", marker, function ( hitElement ) if ( getTeamName(getPlayerTeam(hitElement)) == "Emergency" ) then if (hitElement == localPlayer) then createVehGui ( hitElement ) if (MainGui ~= nil) then guiSetVisible(MainGui, true) showCursor(true) guiSetInputEnabled(true) setElementFrozen(hitElement, true) end end end end ) end Edited Edited May 22, 2012 by Guest Link to comment
Castillo Posted May 22, 2012 Share Posted May 22, 2012 1: You give us a image which the size doesn't let us read. 2: You give us ONE line of code. 3: Nothing makes sense. Do you really expect us to get something out of this? Link to comment
Ryan123 Posted May 22, 2012 Author Share Posted May 22, 2012 Is already modified.I'm trying make script(sorry for give one line) Link to comment
Castillo Posted May 22, 2012 Share Posted May 22, 2012 You have to use getElementData. for i,marker in ipairs ( markers ) do addEventHandler ( "onClientMarkerHit", marker, function ( hitElement ) if ( hitElement == localPlayer ) then if ( getElementData ( hitElement, "Occupation" ) == "Medic" ) then createVehGui ( hitElement ) if ( MainGui ~= nil ) then guiSetVisible ( MainGui, true ) showCursor ( true ) guiSetInputEnabled ( true ) setElementFrozen ( hitElement, true ) end end end end ) end Link to comment
Smart. Posted May 22, 2012 Share Posted May 22, 2012 if getElementData ( hitElement, "Occupation" ) == "Medic" then Link to comment
Ryan123 Posted May 22, 2012 Author Share Posted May 22, 2012 tested and worked.request /lock.thanks for help Link to comment
Castillo Posted May 22, 2012 Share Posted May 22, 2012 You're welcome. P.S: There's no need to lock the topic, someone else may have the same problem. Link to comment
Ryan123 Posted May 22, 2012 Author Share Posted May 22, 2012 hmmm okay. Other help.when I spawn one sultan I want add color and the siren. here is the script: addEvent("spawnVehicle", true) addEventHandler("spawnVehicle", root, function (vehID) if ( isElement(vehicles[source]) ) then destroyElement(vehicles[source]) end vehicles[source] = createVehicle(vehID, getElementPosition(source)) if sultan then local setsultan = setVehicleColor ( "Sultan" , 6, 183, 248) end warpPedIntoVehicle(source, vehicles[source]) triggerClientEvent("closeWindow", root) end ) Link to comment
Castillo Posted May 22, 2012 Share Posted May 22, 2012 addEvent ( "spawnVehicle", true ) addEventHandler ( "spawnVehicle", root, function ( vehID ) if ( isElement ( vehicles [ source ] ) ) then destroyElement ( vehicles [ source ] ) end vehicles [ source ] = createVehicle ( vehID, getElementPosition ( source ) ) if ( vehicles [ source ] ) then -- What is "sultan"?? your vehicle element is: vehicles [ source ] setVehicleColor ( vehicles [ source ], 6, 183, 248 ) -- Here goes the vehicle element, not a string. end setTimer ( warpPedIntoVehicle, 200, 1, source, vehicles [ source ] ) triggerClientEvent ( source, "closeWindow", root ) end ) Link to comment
Ryan123 Posted July 30, 2012 Author Share Posted July 30, 2012 I have more one question, how I can destroyElement when I change the occupation? Link to comment
Castillo Posted July 30, 2012 Share Posted July 30, 2012 Use the event: onElementDataChange to detect when player occupation changes. Link to comment
Ryan123 Posted July 30, 2012 Author Share Posted July 30, 2012 So when I use this, is for destroy when I change Occupation.like this? function destroyelementchanged( vehID ) if not (getElementData(localPlayer == Medic) then destroyElement ( vehicles ) end end addEventHadler("onElementDataChange",root,destroyelementchanged) Link to comment
DNL291 Posted July 30, 2012 Share Posted July 30, 2012 @Ryan123 Read about the event onElementDataChange. Link to comment
Castillo Posted July 30, 2012 Share Posted July 30, 2012 So when I use this, is for destroy when I change Occupation.like this? function destroyelementchanged( vehID ) if not (getElementData(localPlayer == Medic) then destroyElement ( vehicles ) end end addEventHadler("onElementDataChange",root,destroyelementchanged) No, that doesn't make any sense. Link to comment
Ryan123 Posted July 30, 2012 Author Share Posted July 30, 2012 ahhhh, I'm new scripter, and I think, is now fine.Is type this? addEventHandler("onElementDataChange",getElementRoot(), function () if not (getElementData(localPlayer == "Occupation") = "SWAT Member") then vehicles = getElementsByType("vehicle") for i,v in ipairs(vehicle) destroyElement(v) end end end ) I need help only for choose "getElementData" or "getElementRoot" Link to comment
Castillo Posted July 30, 2012 Share Posted July 30, 2012 No offense, but that's just random code. 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