Jump to content

[ayuda]nose que tengo mal en este script


JuanM27

Recommended Posts

hola buenas noches.

bueno le comento, estube haciendo un pequeño script y todo salio.

el script es de un trabajo y funciona bien se podria decir, cuando 1 solo player tiene ese empleo.

pero si hay 2 players haciendo el trabajo es como que se mesclan.

le explico mejor.

actualmente estamos haciendo un server con 2 amigos, y hacemos las pruebas nosotros mismo.

siempre somos 3 en el server.

y por ejemplo si yo me pongo a trabajar el trabajo me funciona de bien

pero si los 3 nos ponemos a trabajar.

el trabajo solo le sirbe al ultimo que acepto el empleo

y a los 2, se le queda el maker y blip marcados en el mapa pero por mas que pasen por el maker con el camion no gana plata y ni tampoco desaparece el maker y blip, mientras que al ultimo que tomo el empleo si le funciona.

de pongo los lua server, cliente,

aver en que le estoy errando.

lua server

local Trailertable = { 
[1] = {584, 2613.9821, -2199.5480, 15, 0, 146, 180}, 
[2] = {584, 2613.9821, -2199.5480, 15, 0, 1422, 180}, 
[3] = {584, 2613.9821, -2199.5480, 15, 0, 6400, 180}, 
[4] = {584, 2613.9821, -2199.5480, 15, 0, 1427, 180}, 
} 
-- los id de los trailers son = 584,435,450,591,606,607,610,611,608 pero en este job utilizamos el trailer nº 584 
local Preciotable = { 
[1] = {200}, 
[2] = {350}, 
[3] = {500}, 
[4] = {550}, 
[5] = {670}, 
[6] = {750}, 
[7] = {800}, 
[8] = {850}, 
[9] = {900}, 
[10] = {950}, 
[11] = {1000}, 
[12] = {1050}, 
[13] = {1100}, 
[14] = {1150}, 
[15] = {1200}, 
[16] = {1400}, 
[17] = {1500}, 
[18] = {1600}, 
[19] = {1700}, 
[20] = {1800}, 
[21] = {1900}, 
[22] = {2000}, 
[23] = {2100}, 
[24] = {2200}, 
[25] = {2300}, 
[26] = {2400}, 
[27] = {2500}, 
[28] = {2600}, 
[29] = {2700}, 
[30] = {2800}, 
[31] = {2900}, 
[32] = {3000}, 
[33] = {3100}, 
[34] = {3200}, 
[35] = {3300}, 
[36] = {3400}, 
[37] = {3500}, 
[38] = {3600}, 
[39] = {3700}, 
[40] = {3800}, 
} 
  
--Tabla de posiciones 
local Posiciontable = { 
[1] = {1959, -1786, 12.5}, 
[2] = {-1574, -2743, 47.5}, 
[3] = {-2251, -2552, 30.5}, 
[4] = {-1697, 390, 6.5}, 
[5] = {-2425, 953, 44.5}, 
[6] = {-1268, 2702, 49.5}, 
[7] = {-1196, 1826, 40.5}, 
[8] = {89, 1207, 18.5}, 
[9] = {585, 1656, 6.5}, 
[10] = {2211, 2466, 9.5}, 
[11] = {989, -926, 41.5}, 
[12] = {-100, -1188, 1.5}, 
} 
  
  
function creablipcirculo() 
 rpBlipOne0 = createBlip ( 2596, -2204, 13, 56 ) -- blip en el mapa y radar (Hospital LS) 
 setBlipVisibleDistance( rpBlipOne0, 250 ) 
end 
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), creablipcirculo) 
  
petro = createMarker (2596,-2204,12.5,"cylinder",2.0,0,0,225,100) 
  
teampetro = createTeam ( "Petrolero", 255, 255, 50 ) 
  
-- abre el gui del cliente 
function menuShow1 (jugador) 
if (source == petro) then 
 if getPlayerTeam ( jugador ) ==getTeamFromName( teampetro) then 
triggerClientEvent (jugador,"menuShow1",getRootElement(),jugador) 
else 
return  
end 
end 
end 
addEventHandler ("onMarkerHit",getRootElement(),menuShow1) 
  
addEvent ("aceptar1", true) 
function aceptar1( id ) 
 if id == "133" then 
 if getElementType (source) == "player" then 
 level = getPlayerWantedLevel(source) 
 if level == 0 then --si es lvl 0 trabaja 
  setPlayerTeam ( source, teampetro ) -- team medico 
  setPedSkin(source,id) -- le ponemos el skin 
  setPedArmor ( source, 0 ) -- le ponemos sin chaleco anti balas 
  outputChatBox("Estas Trabajando Como Petrolero.", source, 0,255,0) 
    else 
    outputChatBox ("Solamente a Personajes que no sea buscados por la policia se le da el trabajo!!!", source, 255,0,0) 
    end 
    end 
    else 
    outputChatBox ("Selecciona un Skin Valido!!", source, 255,0,0, false) 
    end 
    end 
addEventHandler( "aceptar1", getRootElement(), aceptar1 ) 
  
local ambulancia32 = createMarker (2623.8139, -2207.0749, 12.5, "cylinder", 1.5,0,255,0,150) --cilindro que da la ambulancia 
function vehicleMarkerHit1 ( hitElement, matchingDimension ) 
  
  
   if getElementType ( hitElement ) == "player" and  getPlayerTeam ( hitElement ) ==getTeamFromName("Petrolero") then 
if isPedInVehicle(hitElement) then return true end--si esta en un vehiculo no le da la ambulancia 
        Monters = createVehicle ( 403, 2613.9819, -2208.5371, 14.49, 0, 0, 180 )--donde y rotacion que crea el auto hay que probar si pone el semi ^^ 
        warpPedIntoVehicle(hitElement, Monters) 
    local trailer = math.random(#Trailertable) 
        local id,x,y,z,a,b,r = Trailertable[trailer][1],Trailertable[trailer][2],Trailertable[trailer][3],Trailertable[trailer][4],Trailertable[trailer][5],Trailertable[trailer][6],Trailertable[trailer][7] 
        Monters1 = createVehicle (id,x,y,z,a,b,r) 
        attachTrailerToVehicle(Monters,Monters1) 
        else 
    outputChatBox("Solo a Petrolero se le dará el Camion!!", hitElement, 0, 255, 0 ) 
       end 
  
    end 
addEventHandler( "onMarkerHit", ambulancia32 , vehicleMarkerHit1 ) 
  
local ambulancia33 = createMarker (2623.8139, -2211.0749, 12.5, "cylinder", 1.5,0,255,255,150) --cilindro que da la ambulancia 
function vehicleMarkerHit2 ( hitElement, matchingDimension ) 
  
  
   if getElementType ( hitElement ) == "player" and  getPlayerTeam ( hitElement ) ==getTeamFromName("Petrolero") then 
if isPedInVehicle(hitElement) then return true end--si esta en un vehiculo no le da la ambulancia 
        Monters = createVehicle ( 515, 2613.9819, -2208.5371, 14.49, 0, 0, 180 ) 
        warpPedIntoVehicle(hitElement, Monters) 
        local trailer = math.random(#Trailertable) 
        local id,x,y,z,a,b,r = Trailertable[trailer][1],Trailertable[trailer][2],Trailertable[trailer][3],Trailertable[trailer][4],Trailertable[trailer][5],Trailertable[trailer][6],Trailertable[trailer][7] 
        --Monters1 = createVehicle (math.random(#Trailertable), 2613.9821, -2199.5480, 15, 0, 0, 180) 
        Monters1 = createVehicle (id,x,y,z,a,b,r) 
        attachTrailerToVehicle(Monters,Monters1) 
        else 
    outputChatBox("Solo a Petrolero se le dará el Camion!!", hitElement, 0, 255, 0 ) 
       end 
  
    end 
addEventHandler( "onMarkerHit", ambulancia33 , vehicleMarkerHit2 ) 
  
  
function final1(Player) 
setPlayerTeam ( Player, "Civil" ) -- team medico 
  setPedSkin(Player,0) -- le ponemos el skin 
  setPedArmor ( Player, 0 ) -- le ponemos sin chaleco anti balas 
  outputChatBox("Dejaste de Trabajando Como Petrolero.", Player, 0,255,0) 
  
end 
addCommandHandler("finpet",final1); 
  
function truckerJob ( ElPlayer ) 
  theTruckVehicle = ElPlayer 
  theTruckTrailer = source 
  theTruckTrailerID = getElementModel (source) 
  local ElPlayer = getVehicleOccupant ( ElPlayer, 0 ) 
    if ( ElPlayer ) and ( theTruckTrailerID == 584 ) then 
      outputChatBox ("Llevar el remolque a la bandera.", ElPlayer, 255, 0, 0, false) 
      local posi = math.random(#Posiciontable) 
      local x,z,y= Posiciontable[posi][1],Posiciontable[posi][2],Posiciontable[posi][3] 
      theFinishMarker = createMarker ( x, z, y, "cylinder", 4.5, 0, 255, 0, 90, ElPlayer ) 
      theFinishBlip = createBlip ( x, z, y, 53, 2, 255, 0, 0, 255, 0, 99999.0, ElPlayer ) 
    end 
    function truckerJobMarkerHit ( ElPlayer, matchingDimension ) 
  theMarkerID = getElementID (theFinishMarker) 
  if (source == theFinishMarker) then 
    flashRed (ElPlayer) 
  local ganado = math.random(#Preciotable) 
  local pagado = Preciotable[ganado][1] 
    givePlayerMoney ( ElPlayer, pagado ) 
    destroyElement ( theFinishMarker ) 
    destroyElement ( theFinishBlip ) 
    outputChatBox ( "Aprobada la misión, que gana $ ".. pagado, ElPlayer, 255, 0, 0, false ) 
    --aca el nuevo destino 
      NuevaPosicion(hitPlayer) 
  end 
end 
addEventHandler ("onMarkerHit", getRootElement(), truckerJobMarkerHit) 
end 
addEventHandler("onTrailerAttach", getRootElement(), truckerJob) 
  
  
function flashRed (jugador) 
    fadeCamera(jugador, false, 1.0, 0, 0, 0 ) 
    -- set a 500 ms (0.5 sec) timer to fade it back in before it has completely faded out 
    setTimer ( fadeCamera, 700, 1, jugador, true, 0.5 ) 
end 
addEventHandler( "onMarkerHit", getRootElement(), flashRed ) 
  
function NuevaPosicion(Player) 
local posi = math.random(#Posiciontable) 
local x,z,y= Posiciontable[posi][1],Posiciontable[posi][2],Posiciontable[posi][3] 
theFinishMarker = createMarker ( x, z, y, "cylinder", 4.5, 0, 255, 0, 90, Player ) 
theFinishBlip = createBlip ( x, z, y, 53, 2, 255, 0, 0, 255, 0, 99999.0, Player ) 
end 

lua cliente

GUIEditor_Label = {} 
GUIEditor_Label1 = {} 
  
theWindow1 = guiCreateWindow(350,50,250,350,"[Life]Petrolero",false) 
guiWindowSetSizable(theWindow1,false) 
guiSetVisible (theWindow1, false) 
guiLabelSetHorizontalAlign(GUIEditor_Label[1],"left",false) 
guiSetFont(GUIEditor_Label[1],"default-bold-small") 
aceptaBut1 = guiCreateButton(0.15,0.9,0.3,0.1,"Aceptar",true,theWindow1) 
closeBut1 = guiCreateButton(0.47,0.9,0.3,0.1,"Cerrar",true,theWindow1) 
info = guiCreateLabel(0.08,0.05,0.9,0.3,"¿Estas Listo para trabajar de Petrolero?",true,theWindow1) 
guiLabelSetColor(info, 0, 255, 0) 
info2 = guiCreateLabel(0.15,0.12,0.60,0.3,"Selecciona el Skin a Utilizar!",true,theWindow1) 
guiLabelSetColor(info2, 0, 255, 0) 
autos1 = guiCreateGridList ( 0.01, 0.19, 0.91, 0.70, true,theWindow1 ) 
column1 = guiGridListAddColumn( autos1, "Skins Disponibles", 0.93, true, theWindow1 ) 
skin1 = guiGridListAddRow( autos1 ) 
guiGridListSetItemText(autos1, skin1 , column1,"133",false,false) 
skin2 = guiGridListAddRow( autos1 ) 
  
theWindow2 = guiCreateWindow(350,50,250,350,"[Life]Petrolero",false) 
guiWindowSetSizable(theWindow2,false) 
guiSetVisible (theWindow2, false) 
guiLabelSetHorizontalAlign(GUIEditor_Label1[1],"left",false) 
guiSetFont(GUIEditor_Label1[1],"default-bold-small") 
aceptaBut2 = guiCreateButton(0.15,0.9,0.3,0.1,"Aceptar",true,theWindow2) 
closeBut2 = guiCreateButton(0.47,0.9,0.3,0.1,"Cerrar",true,theWindow2) 
info4 = guiCreateLabel(0.15,0.12,0.60,0.3,"Selecciona el Camion a Utilizar!",true,theWindow2) 
guiLabelSetColor(info4, 0, 255, 0) 
autos2 = guiCreateGridList ( 0.01, 0.19, 0.91, 0.70, true,theWindow2 ) 
column2 = guiGridListAddColumn( autos2, "Camiones Disponibles", 0.93, true, theWindow2 ) 
skin2 = guiGridListAddRow( autos2 ) 
guiGridListSetItemText(autos2, skin2 , column2,"Linerunner",false,false) --id nº 403 
skin3 = guiGridListAddRow( autos2 ) 
guiGridListSetItemText(autos2, skin3 , column2,"Roadtrain",false,false) --id nº 515 
  
function menuShow1 () 
    visableornot = guiGetVisible (theWindow1) 
    if (visableornot == true) then 
        guiSetVisible (theWindow1, false) 
        showCursor (false) 
    end 
    if (visableornot == false) then 
        guiSetVisible (theWindow1, true) 
        showCursor (true) 
    end 
end 
  
addEvent ("menuShow1",true) 
addEventHandler ("menuShow1",getRootElement(),menuShow1) 
  
addEvent ("aceptar1", true) 
  
function menuShow2 () 
    visableornot1 = guiGetVisible (theWindow2) 
    if (visableornot1 == true) then 
        guiSetVisible (theWindow2, false) 
        showCursor (false) 
    end 
    if (visableornot1 == false) then 
        guiSetVisible (theWindow2, true) 
        showCursor (true) 
    end 
end 
addEvent ("menuShow2",true) 
addEventHandler ("menuShow2",getRootElement(),menuShow2) 
  
addEvent ("aceptar2", true) 
  
function guiClick (button, state, absoluteX, absoluteY) 
  if (source == aceptaBut1) then 
    if (guiGridListGetSelectedItem (autos1)) then 
      local carName1 = guiGridListGetItemText (autos1, guiGridListGetSelectedItem (autos1)) 
      triggerServerEvent ("aceptar1", getLocalPlayer(), carName1) 
      guiSetVisible ( theWindow1, false ) 
        showCursor ( false ) 
    end 
    elseif (source == closeBut1) then  
        guiSetVisible ( theWindow1, false ) 
        showCursor ( false ) 
  end 
  if (source == aceptaBut2) then 
    if (guiGridListGetSelectedItem (autos2)) then 
      local carName2 = guiGridListGetItemText (autos2, guiGridListGetSelectedItem (autos2)) 
      triggerServerEvent ("aceptar2", getLocalPlayer(), carName2) 
      guiSetVisible ( theWindow2, false ) 
        showCursor ( false ) 
    end 
    elseif (source == closeBut2) then  
        guiSetVisible ( theWindow2, false ) 
        showCursor ( false ) 
  end 
end 
addEventHandler ("onClientGUIClick", getRootElement(), guiClick) 

saludos, y espero que me digan cual es mi error o si me falta alguna funcion para que sea multijugador

Link to comment

Proba si funciona.

-- client side:

GUIEditor_Label = {} 
GUIEditor_Label1 = {} 
  
theWindow1 = guiCreateWindow(350,50,250,350,"[Life]Petrolero",false) 
guiWindowSetSizable(theWindow1,false) 
guiSetVisible (theWindow1, false) 
guiLabelSetHorizontalAlign(GUIEditor_Label[1],"left",false) 
guiSetFont(GUIEditor_Label[1],"default-bold-small") 
aceptaBut1 = guiCreateButton(0.15,0.9,0.3,0.1,"Aceptar",true,theWindow1) 
closeBut1 = guiCreateButton(0.47,0.9,0.3,0.1,"Cerrar",true,theWindow1) 
info = guiCreateLabel(0.08,0.05,0.9,0.3,"¿Estas Listo para trabajar de Petrolero?",true,theWindow1) 
guiLabelSetColor(info, 0, 255, 0) 
info2 = guiCreateLabel(0.15,0.12,0.60,0.3,"Selecciona el Skin a Utilizar!",true,theWindow1) 
guiLabelSetColor(info2, 0, 255, 0) 
autos1 = guiCreateGridList ( 0.01, 0.19, 0.91, 0.70, true,theWindow1 ) 
column1 = guiGridListAddColumn( autos1, "Skins Disponibles", 0.93, true, theWindow1 ) 
skin1 = guiGridListAddRow( autos1 ) 
guiGridListSetItemText(autos1, skin1 , column1,"133",false,false) 
skin2 = guiGridListAddRow( autos1 ) 
  
theWindow2 = guiCreateWindow(350,50,250,350,"[Life]Petrolero",false) 
guiWindowSetSizable(theWindow2,false) 
guiSetVisible (theWindow2, false) 
guiLabelSetHorizontalAlign(GUIEditor_Label1[1],"left",false) 
guiSetFont(GUIEditor_Label1[1],"default-bold-small") 
aceptaBut2 = guiCreateButton(0.15,0.9,0.3,0.1,"Aceptar",true,theWindow2) 
closeBut2 = guiCreateButton(0.47,0.9,0.3,0.1,"Cerrar",true,theWindow2) 
info4 = guiCreateLabel(0.15,0.12,0.60,0.3,"Selecciona el Camion a Utilizar!",true,theWindow2) 
guiLabelSetColor(info4, 0, 255, 0) 
autos2 = guiCreateGridList ( 0.01, 0.19, 0.91, 0.70, true,theWindow2 ) 
column2 = guiGridListAddColumn( autos2, "Camiones Disponibles", 0.93, true, theWindow2 ) 
skin2 = guiGridListAddRow( autos2 ) 
guiGridListSetItemText(autos2, skin2 , column2,"Linerunner",false,false) --id nº 403 
skin3 = guiGridListAddRow( autos2 ) 
guiGridListSetItemText(autos2, skin3 , column2,"Roadtrain",false,false) --id nº 515 
  
function menuShow1 () 
    visableornot = guiGetVisible (theWindow1) 
    if (visableornot == true) then 
        guiSetVisible (theWindow1, false) 
        showCursor (false) 
    end 
    if (visableornot == false) then 
        guiSetVisible (theWindow1, true) 
        showCursor (true) 
    end 
end 
  
addEvent ("menuShow1",true) 
addEventHandler ("menuShow1",getRootElement(),menuShow1) 
   
function menuShow2 () 
    visableornot1 = guiGetVisible (theWindow2) 
    if (visableornot1 == true) then 
        guiSetVisible (theWindow2, false) 
        showCursor (false) 
    end 
    if (visableornot1 == false) then 
        guiSetVisible (theWindow2, true) 
        showCursor (true) 
    end 
end 
addEvent ("menuShow2",true) 
addEventHandler ("menuShow2",getRootElement(),menuShow2) 
  
function guiClick (button, state, absoluteX, absoluteY) 
  if (source == aceptaBut1) then 
    if (guiGridListGetSelectedItem (autos1)) then 
      local carName1 = guiGridListGetItemText (autos1, guiGridListGetSelectedItem (autos1)) 
      triggerServerEvent ("aceptar1", getLocalPlayer(), carName1) 
      guiSetVisible ( theWindow1, false ) 
        showCursor ( false ) 
    end 
    elseif (source == closeBut1) then 
        guiSetVisible ( theWindow1, false ) 
        showCursor ( false ) 
  end 
  if (source == aceptaBut2) then 
    if (guiGridListGetSelectedItem (autos2)) then 
      local carName2 = guiGridListGetItemText (autos2, guiGridListGetSelectedItem (autos2)) 
      triggerServerEvent ("aceptar2", getLocalPlayer(), carName2) 
      guiSetVisible ( theWindow2, false ) 
        showCursor ( false ) 
    end 
    elseif (source == closeBut2) then 
        guiSetVisible ( theWindow2, false ) 
        showCursor ( false ) 
  end 
end 
addEventHandler ("onClientGUIClick", getRootElement(), guiClick) 
  
addEvent("enviarDestino",true) 
addEventHandler("enviarDestino",root, 
function (x,z,y) 
    if isElement(theFinishMarker) then  
        removeEventHandler("onClientMarkerHit", theFinishMarker, truckerJobMarkerHit) 
        destroyElement ( theFinishMarker )  
    end 
    if isElement(theFinishBlip) then destroyElement ( theFinishBlip ) end 
    theFinishMarker = createMarker ( x, z, y, "cylinder", 4.5, 0, 255, 0, 90 ) 
    theFinishBlip = createBlip ( x, z, y, 53, 2, 255, 0, 0, 255, 0, 99999.0 ) 
    addEventHandler("onClientMarkerHit", theFinishMarker, truckerJobMarkerHit) 
end) 
  
function truckerJobMarkerHit ( hitPlayer, dim ) 
    if (hitPlayer == localPlayer and dim and isPedInVehicle(localPlayer)) then 
        if isElement(theFinishMarker) then  
            removeEventHandler("onClientMarkerHit", theFinishMarker, truckerJobMarkerHit) 
            destroyElement ( theFinishMarker )  
        end 
        if isElement(theFinishBlip) then destroyElement ( theFinishBlip ) end 
        triggerServerEvent("misionTerminada",localPlayer) 
    end 
end 

-- server side:

local Trailertable = { 
    [1] = {584, 2613.9821, -2199.5480, 15, 0, 146, 180}, 
    [2] = {584, 2613.9821, -2199.5480, 15, 0, 1422, 180}, 
    [3] = {584, 2613.9821, -2199.5480, 15, 0, 6400, 180}, 
    [4] = {584, 2613.9821, -2199.5480, 15, 0, 1427, 180}, 
} 
-- los id de los trailers son = 584,435,450,591,606,607,610,611,608 pero en este job utilizamos el trailer nº 584 
local Preciotable = { 
    [1] = {200}, 
    [2] = {350}, 
    [3] = {500}, 
    [4] = {550}, 
    [5] = {670}, 
    [6] = {750}, 
    [7] = {800}, 
    [8] = {850}, 
    [9] = {900}, 
    [10] = {950}, 
    [11] = {1000}, 
    [12] = {1050}, 
    [13] = {1100}, 
    [14] = {1150}, 
    [15] = {1200}, 
    [16] = {1400}, 
    [17] = {1500}, 
    [18] = {1600}, 
    [19] = {1700}, 
    [20] = {1800}, 
    [21] = {1900}, 
    [22] = {2000}, 
    [23] = {2100}, 
    [24] = {2200}, 
    [25] = {2300}, 
    [26] = {2400}, 
    [27] = {2500}, 
    [28] = {2600}, 
    [29] = {2700}, 
    [30] = {2800}, 
    [31] = {2900}, 
    [32] = {3000}, 
    [33] = {3100}, 
    [34] = {3200}, 
    [35] = {3300}, 
    [36] = {3400}, 
    [37] = {3500}, 
    [38] = {3600}, 
    [39] = {3700}, 
    [40] = {3800}, 
} 
  
--Tabla de posiciones 
local Posiciontable = { 
    [1] = {1959, -1786, 12.5}, 
    [2] = {-1574, -2743, 47.5}, 
    [3] = {-2251, -2552, 30.5}, 
    [4] = {-1697, 390, 6.5}, 
    [5] = {-2425, 953, 44.5}, 
    [6] = {-1268, 2702, 49.5}, 
    [7] = {-1196, 1826, 40.5}, 
    [8] = {89, 1207, 18.5}, 
    [9] = {585, 1656, 6.5}, 
    [10] = {2211, 2466, 9.5}, 
    [11] = {989, -926, 41.5}, 
    [12] = {-100, -1188, 1.5}, 
} 
  
  
function creablipcirculo() 
    rpBlipOne0 = createBlip ( 2596, -2204, 13, 56 ) -- blip en el mapa y radar (Hospital LS) 
    setBlipVisibleDistance( rpBlipOne0, 250 ) 
end 
addEventHandler("onResourceStart", resourceRoot, creablipcirculo) 
  
petro = createMarker (2596,-2204,12.5,"cylinder",2.0,0,0,225,100) 
  
teampetro = createTeam ( "Petrolero", 255, 255, 50 ) 
  
-- abre el gui del cliente 
function menuShow1 (jugador) 
    if (source == petro) then 
        if getPlayerTeam ( jugador ) == getTeamFromName( teampetro) then 
            triggerClientEvent (jugador,"menuShow1",getRootElement(),jugador) 
        end 
    end 
end 
addEventHandler ("onMarkerHit",getRootElement(),menuShow1) 
  
addEvent ("aceptar1", true) 
function aceptar1( id ) 
    if id == "133" then 
        if getElementType (source) == "player" then 
        local level = getPlayerWantedLevel(source) 
        if level == 0 then --si es lvl 0 trabaja 
            setPlayerTeam ( source, teampetro ) -- team medico 
            setPedSkin(source,id) -- le ponemos el skin 
            setPedArmor ( source, 0 ) -- le ponemos sin chaleco anti balas 
            outputChatBox("Estas Trabajando Como Petrolero.", source, 0,255,0) 
        else 
            outputChatBox ("Solamente a Personajes que no sea buscados por la policia se le da el trabajo!!!", source, 255,0,0) 
        end 
    end 
    else 
        outputChatBox ("Selecciona un Skin Valido!!", source, 255,0,0, false) 
    end 
end 
addEventHandler( "aceptar1", getRootElement(), aceptar1 ) 
  
local ambulancia32 = createMarker (2623.8139, -2207.0749, 12.5, "cylinder", 1.5,0,255,0,150) --cilindro que da la ambulancia 
  
function vehicleMarkerHit1 ( hitElement, matchingDimension ) 
        if getElementType ( hitElement ) == "player" and  getPlayerTeam ( hitElement ) ==getTeamFromName("Petrolero") then 
        if isPedInVehicle(hitElement) then return true end--si esta en un vehiculo no le da la ambulancia 
        Monters = createVehicle ( 403, 2613.9819, -2208.5371, 14.49, 0, 0, 180 )--donde y rotacion que crea el auto hay que probar si pone el semi ^^ 
        warpPedIntoVehicle(hitElement, Monters) 
        local trailer = math.random(#Trailertable) 
        local id,x,y,z,a,b,r = Trailertable[trailer][1],Trailertable[trailer][2],Trailertable[trailer][3],Trailertable[trailer][4],Trailertable[trailer][5],Trailertable[trailer][6],Trailertable[trailer][7] 
        Monters1 = createVehicle (id,x,y,z,a,b,r) 
        attachTrailerToVehicle(Monters,Monters1) 
    else 
        outputChatBox("Solo a Petrolero se le dará el Camion!!", hitElement, 0, 255, 0 ) 
    end 
end 
addEventHandler( "onMarkerHit", ambulancia32 , vehicleMarkerHit1 ) 
  
local ambulancia33 = createMarker (2623.8139, -2211.0749, 12.5, "cylinder", 1.5,0,255,255,150) --cilindro que da la ambulancia 
  
function vehicleMarkerHit2 ( hitElement, matchingDimension ) 
    if ( getElementType ( hitElement ) == "player" and getPlayerTeam ( hitElement ) == getTeamFromName("Petrolero") )then 
        if isPedInVehicle(hitElement) then return true end--si esta en un vehiculo no le da la ambulancia 
        Monters = createVehicle ( 515, 2613.9819, -2208.5371, 14.49, 0, 0, 180 ) 
        warpPedIntoVehicle(hitElement, Monters) 
        local trailer = math.random(#Trailertable) 
        local id,x,y,z,a,b,r = Trailertable[trailer][1],Trailertable[trailer][2],Trailertable[trailer][3],Trailertable[trailer][4],Trailertable[trailer][5],Trailertable[trailer][6],Trailertable[trailer][7] 
        --Monters1 = createVehicle (math.random(#Trailertable), 2613.9821, -2199.5480, 15, 0, 0, 180) 
        Monters1 = createVehicle (id,x,y,z,a,b,r) 
        attachTrailerToVehicle(Monters,Monters1) 
    else 
        outputChatBox("Solo a Petrolero se le dará el Camion!!", hitElement, 0, 255, 0 ) 
    end  
end 
addEventHandler( "onMarkerHit", ambulancia33 , vehicleMarkerHit2 ) 
  
function final1(Player) 
    setPlayerTeam ( Player, "Civil" ) -- team medico 
    setPedSkin(Player,0) -- le ponemos el skin 
    setPedArmor ( Player, 0 ) -- le ponemos sin chaleco anti balas 
    outputChatBox("Dejaste de Trabajando Como Petrolero.", Player, 0,255,0) 
end 
addCommandHandler("finpet",final1); 
  
function truckerJob ( elCamion ) 
    local theTruckTrailerID = getElementModel (source) 
    local ElPlayer = getVehicleOccupant ( elCamion, 0 ) 
    if ( ElPlayer ) and ( theTruckTrailerID == 584 ) then 
        outputChatBox ("Llevar el remolque a la bandera.", ElPlayer, 255, 0, 0, false) 
        NuevaPosicion(ElPlayer) 
    end 
end 
addEventHandler("onTrailerAttach", getRootElement(), truckerJob) 
  
function flashRed (jugador) 
    fadeCamera(jugador, false, 1.0, 0, 0, 0 ) 
    -- set a 500 ms (0.5 sec) timer to fade it back in before it has completely faded out 
    setTimer ( fadeCamera, 700, 1, jugador, true, 0.5 ) 
end 
addEventHandler( "onMarkerHit", getRootElement(), flashRed ) 
  
function NuevaPosicion(Player) 
    local posi = math.random(#Posiciontable) 
    local x,z,y = Posiciontable[posi][1],Posiciontable[posi][2],Posiciontable[posi][3] 
    triggerClientEvent(Player,"enviarDestino",Player,x,z,y) 
end 
  
addEvent("misionTerminada",true) 
addEventHandler("misionTerminada",root, 
function () 
    local ElPlayer = source 
    flashRed (ElPlayer) 
    local ganado = math.random(#Preciotable) 
    local pagado = Preciotable[ganado][1] 
    givePlayerMoney ( ElPlayer, pagado ) 
    outputChatBox ( "Aprobada la misión, que gana $ ".. pagado, ElPlayer, 255, 0, 0, false ) 
    --aca el nuevo destino 
    NuevaPosicion(ElPlayer) 
end) 

Link to comment

hola Solidsnake14, probe lo que me dejaste,

el resultado que me dio es que no anda, no tira error pero no hace cuando pasas por el punto de llegada

osea te da el camion y te pone el blip y el maker bien

pero cuando llegas al maker no hace, no paga, no quita el maker ni el blip

saludos

Link to comment

hola, tengo un problema, asi como esta anda el trabajo para todos

pero cuando pasas por el maker con un auto o moto, te lo toma igual como si pasas con el camion

como podria poner para que cuando pasas en el maker compruebe si pasas con el camion + trailer?

en la parte del server yo le puse esto

addEvent("misionTerminada",true) 
addEventHandler("misionTerminada",root, 
function ( elCamion, MiTrailer ) 
    local ElPlayer = source 
    local ganado = math.random(#Preciotable) 
    local pagado = Preciotable[ganado][1] 
    local theTruckTrailerID = getElementModel ( MiTrailer ) 
    local ElPlayer = getVehicleOccupant ( elCamion, 0 ) 
    if ( ElPlayer ) and ( theTruckTrailerID == 584 ) then 
    givePlayerMoney ( ElPlayer, pagado ) 
    outputChatBox ( "Combustible Entregado, Ganaste $ ".. pagado, ElPlayer, 255, 0, 0 ) 
    NuevaPosicion(ElPlayer) 
    else 
    outputChatBox ( "Necesitas el Trailer!!", ElPlayer, 255, 0, 0 ) 
    return 
    end 
end) 

pero no lo toma, osea siempre me dice Necesitas el Trailer!!

tendria que hacer una funcion nueva?

busque en la wiki sobre getElementModel

pero no hay para el lado del cliente side.

y no se como mandarle el dato del trailer al server asi lo puedo comprobar si tiene o no el camion + trailer

Link to comment

Ok, proba con esto:

-- client side:

GUIEditor_Label = {} 
GUIEditor_Label1 = {} 
  
theWindow1 = guiCreateWindow(350,50,250,350,"[Life]Petrolero",false) 
guiWindowSetSizable(theWindow1,false) 
guiSetVisible (theWindow1, false) 
guiLabelSetHorizontalAlign(GUIEditor_Label[1],"left",false) 
guiSetFont(GUIEditor_Label[1],"default-bold-small") 
aceptaBut1 = guiCreateButton(0.15,0.9,0.3,0.1,"Aceptar",true,theWindow1) 
closeBut1 = guiCreateButton(0.47,0.9,0.3,0.1,"Cerrar",true,theWindow1) 
info = guiCreateLabel(0.08,0.05,0.9,0.3,"¿Estas Listo para trabajar de Petrolero?",true,theWindow1) 
guiLabelSetColor(info, 0, 255, 0) 
info2 = guiCreateLabel(0.15,0.12,0.60,0.3,"Selecciona el Skin a Utilizar!",true,theWindow1) 
guiLabelSetColor(info2, 0, 255, 0) 
autos1 = guiCreateGridList ( 0.01, 0.19, 0.91, 0.70, true,theWindow1 ) 
column1 = guiGridListAddColumn( autos1, "Skins Disponibles", 0.93, true, theWindow1 ) 
skin1 = guiGridListAddRow( autos1 ) 
guiGridListSetItemText(autos1, skin1 , column1,"133",false,false) 
skin2 = guiGridListAddRow( autos1 ) 
  
theWindow2 = guiCreateWindow(350,50,250,350,"[Life]Petrolero",false) 
guiWindowSetSizable(theWindow2,false) 
guiSetVisible (theWindow2, false) 
guiLabelSetHorizontalAlign(GUIEditor_Label1[1],"left",false) 
guiSetFont(GUIEditor_Label1[1],"default-bold-small") 
aceptaBut2 = guiCreateButton(0.15,0.9,0.3,0.1,"Aceptar",true,theWindow2) 
closeBut2 = guiCreateButton(0.47,0.9,0.3,0.1,"Cerrar",true,theWindow2) 
info4 = guiCreateLabel(0.15,0.12,0.60,0.3,"Selecciona el Camion a Utilizar!",true,theWindow2) 
guiLabelSetColor(info4, 0, 255, 0) 
autos2 = guiCreateGridList ( 0.01, 0.19, 0.91, 0.70, true,theWindow2 ) 
column2 = guiGridListAddColumn( autos2, "Camiones Disponibles", 0.93, true, theWindow2 ) 
skin2 = guiGridListAddRow( autos2 ) 
guiGridListSetItemText(autos2, skin2 , column2,"Linerunner",false,false) --id nº 403 
skin3 = guiGridListAddRow( autos2 ) 
guiGridListSetItemText(autos2, skin3 , column2,"Roadtrain",false,false) --id nº 515 
  
function menuShow1 () 
    visableornot = guiGetVisible (theWindow1) 
    if (visableornot == true) then 
        guiSetVisible (theWindow1, false) 
        showCursor (false) 
    end 
    if (visableornot == false) then 
        guiSetVisible (theWindow1, true) 
        showCursor (true) 
    end 
end 
  
addEvent ("menuShow1",true) 
addEventHandler ("menuShow1",getRootElement(),menuShow1) 
  
function menuShow2 () 
    visableornot1 = guiGetVisible (theWindow2) 
    if (visableornot1 == true) then 
        guiSetVisible (theWindow2, false) 
        showCursor (false) 
    end 
    if (visableornot1 == false) then 
        guiSetVisible (theWindow2, true) 
        showCursor (true) 
    end 
end 
addEvent ("menuShow2",true) 
addEventHandler ("menuShow2",getRootElement(),menuShow2) 
  
function guiClick (button, state, absoluteX, absoluteY) 
  if (source == aceptaBut1) then 
    if (guiGridListGetSelectedItem (autos1)) then 
      local carName1 = guiGridListGetItemText (autos1, guiGridListGetSelectedItem (autos1)) 
      triggerServerEvent ("aceptar1", getLocalPlayer(), carName1) 
      guiSetVisible ( theWindow1, false ) 
        showCursor ( false ) 
    end 
    elseif (source == closeBut1) then 
        guiSetVisible ( theWindow1, false ) 
        showCursor ( false ) 
  end 
  if (source == aceptaBut2) then 
    if (guiGridListGetSelectedItem (autos2)) then 
      local carName2 = guiGridListGetItemText (autos2, guiGridListGetSelectedItem (autos2)) 
      triggerServerEvent ("aceptar2", getLocalPlayer(), carName2) 
      guiSetVisible ( theWindow2, false ) 
        showCursor ( false ) 
    end 
    elseif (source == closeBut2) then 
        guiSetVisible ( theWindow2, false ) 
        showCursor ( false ) 
  end 
end 
addEventHandler ("onClientGUIClick", getRootElement(), guiClick) 
  
addEvent("enviarDestino",true) 
addEventHandler("enviarDestino",root, 
function (x,z,y) 
    if isElement(theFinishMarker) then 
        removeEventHandler("onClientMarkerHit", theFinishMarker, truckerJobMarkerHit) 
        destroyElement ( theFinishMarker ) 
    end 
    if isElement(theFinishBlip) then destroyElement ( theFinishBlip ) end 
    theFinishMarker = createMarker ( x, z, y, "cylinder", 4.5, 0, 255, 0, 90 ) 
    theFinishBlip = createBlip ( x, z, y, 53, 2, 255, 0, 0, 255, 0, 99999.0 ) 
    addEventHandler("onClientMarkerHit", theFinishMarker, truckerJobMarkerHit) 
end) 
  
function truckerJobMarkerHit ( hitPlayer, dim ) 
    if (hitPlayer == localPlayer and dim and isPedInVehicle(localPlayer)) then 
        local vehicle = getPedOccupiedVehicle(localPlayer) 
        if (not getVehicleTowingVehicle(vehicle)) then 
            outputChatBox ( "Necesitas el Trailer!!", 255, 0, 0 ) 
            return 
        end 
        if (getElementModel(getVehicleTowingVehicle(vehicle)) ~= 584) then 
            outputChatBox ( "Necesitas el Trailer!!", 255, 0, 0 ) 
            return 
        end 
        if isElement(theFinishMarker) then 
            removeEventHandler("onClientMarkerHit", theFinishMarker, truckerJobMarkerHit) 
            destroyElement ( theFinishMarker ) 
        end 
        if isElement(theFinishBlip) then destroyElement ( theFinishBlip ) end 
        triggerServerEvent("misionTerminada",localPlayer) 
    end 
end 

Link to comment
Ok, proba con esto:

-- client side:

GUIEditor_Label = {} 
GUIEditor_Label1 = {} 
  
theWindow1 = guiCreateWindow(350,50,250,350,"[Life]Petrolero",false) 
guiWindowSetSizable(theWindow1,false) 
guiSetVisible (theWindow1, false) 
guiLabelSetHorizontalAlign(GUIEditor_Label[1],"left",false) 
guiSetFont(GUIEditor_Label[1],"default-bold-small") 
aceptaBut1 = guiCreateButton(0.15,0.9,0.3,0.1,"Aceptar",true,theWindow1) 
closeBut1 = guiCreateButton(0.47,0.9,0.3,0.1,"Cerrar",true,theWindow1) 
info = guiCreateLabel(0.08,0.05,0.9,0.3,"¿Estas Listo para trabajar de Petrolero?",true,theWindow1) 
guiLabelSetColor(info, 0, 255, 0) 
info2 = guiCreateLabel(0.15,0.12,0.60,0.3,"Selecciona el Skin a Utilizar!",true,theWindow1) 
guiLabelSetColor(info2, 0, 255, 0) 
autos1 = guiCreateGridList ( 0.01, 0.19, 0.91, 0.70, true,theWindow1 ) 
column1 = guiGridListAddColumn( autos1, "Skins Disponibles", 0.93, true, theWindow1 ) 
skin1 = guiGridListAddRow( autos1 ) 
guiGridListSetItemText(autos1, skin1 , column1,"133",false,false) 
skin2 = guiGridListAddRow( autos1 ) 
  
theWindow2 = guiCreateWindow(350,50,250,350,"[Life]Petrolero",false) 
guiWindowSetSizable(theWindow2,false) 
guiSetVisible (theWindow2, false) 
guiLabelSetHorizontalAlign(GUIEditor_Label1[1],"left",false) 
guiSetFont(GUIEditor_Label1[1],"default-bold-small") 
aceptaBut2 = guiCreateButton(0.15,0.9,0.3,0.1,"Aceptar",true,theWindow2) 
closeBut2 = guiCreateButton(0.47,0.9,0.3,0.1,"Cerrar",true,theWindow2) 
info4 = guiCreateLabel(0.15,0.12,0.60,0.3,"Selecciona el Camion a Utilizar!",true,theWindow2) 
guiLabelSetColor(info4, 0, 255, 0) 
autos2 = guiCreateGridList ( 0.01, 0.19, 0.91, 0.70, true,theWindow2 ) 
column2 = guiGridListAddColumn( autos2, "Camiones Disponibles", 0.93, true, theWindow2 ) 
skin2 = guiGridListAddRow( autos2 ) 
guiGridListSetItemText(autos2, skin2 , column2,"Linerunner",false,false) --id nº 403 
skin3 = guiGridListAddRow( autos2 ) 
guiGridListSetItemText(autos2, skin3 , column2,"Roadtrain",false,false) --id nº 515 
  
function menuShow1 () 
    visableornot = guiGetVisible (theWindow1) 
    if (visableornot == true) then 
        guiSetVisible (theWindow1, false) 
        showCursor (false) 
    end 
    if (visableornot == false) then 
        guiSetVisible (theWindow1, true) 
        showCursor (true) 
    end 
end 
  
addEvent ("menuShow1",true) 
addEventHandler ("menuShow1",getRootElement(),menuShow1) 
  
function menuShow2 () 
    visableornot1 = guiGetVisible (theWindow2) 
    if (visableornot1 == true) then 
        guiSetVisible (theWindow2, false) 
        showCursor (false) 
    end 
    if (visableornot1 == false) then 
        guiSetVisible (theWindow2, true) 
        showCursor (true) 
    end 
end 
addEvent ("menuShow2",true) 
addEventHandler ("menuShow2",getRootElement(),menuShow2) 
  
function guiClick (button, state, absoluteX, absoluteY) 
  if (source == aceptaBut1) then 
    if (guiGridListGetSelectedItem (autos1)) then 
      local carName1 = guiGridListGetItemText (autos1, guiGridListGetSelectedItem (autos1)) 
      triggerServerEvent ("aceptar1", getLocalPlayer(), carName1) 
      guiSetVisible ( theWindow1, false ) 
        showCursor ( false ) 
    end 
    elseif (source == closeBut1) then 
        guiSetVisible ( theWindow1, false ) 
        showCursor ( false ) 
  end 
  if (source == aceptaBut2) then 
    if (guiGridListGetSelectedItem (autos2)) then 
      local carName2 = guiGridListGetItemText (autos2, guiGridListGetSelectedItem (autos2)) 
      triggerServerEvent ("aceptar2", getLocalPlayer(), carName2) 
      guiSetVisible ( theWindow2, false ) 
        showCursor ( false ) 
    end 
    elseif (source == closeBut2) then 
        guiSetVisible ( theWindow2, false ) 
        showCursor ( false ) 
  end 
end 
addEventHandler ("onClientGUIClick", getRootElement(), guiClick) 
  
addEvent("enviarDestino",true) 
addEventHandler("enviarDestino",root, 
function (x,z,y) 
    if isElement(theFinishMarker) then 
        removeEventHandler("onClientMarkerHit", theFinishMarker, truckerJobMarkerHit) 
        destroyElement ( theFinishMarker ) 
    end 
    if isElement(theFinishBlip) then destroyElement ( theFinishBlip ) end 
    theFinishMarker = createMarker ( x, z, y, "cylinder", 4.5, 0, 255, 0, 90 ) 
    theFinishBlip = createBlip ( x, z, y, 53, 2, 255, 0, 0, 255, 0, 99999.0 ) 
    addEventHandler("onClientMarkerHit", theFinishMarker, truckerJobMarkerHit) 
end) 
  
function truckerJobMarkerHit ( hitPlayer, dim ) 
    if (hitPlayer == localPlayer and dim and isPedInVehicle(localPlayer)) then 
        local vehicle = getPedOccupiedVehicle(localPlayer) 
        if (getVehicleTowingVehicle(vehicle) and getElementModel(getVehicleTowingVehicle(vehicle)) == 584) then 
            if isElement(theFinishMarker) then 
                removeEventHandler("onClientMarkerHit", theFinishMarker, truckerJobMarkerHit) 
                destroyElement ( theFinishMarker ) 
            end 
            if isElement(theFinishBlip) then destroyElement ( theFinishBlip ) end 
            triggerServerEvent("misionTerminada",localPlayer) 
        else 
            outputChatBox ( "Necesitas el Trailer!!", 255, 0, 0 ) 
        end 
    end 
end 

hola amigo, me sigue diciendo Necesitas el Trailer!!

Link to comment

hola, amigo

mira te comento, estube probando los ejemplo que hay en la wiki sobre

getVehicleTowingVehicle 

y

getVehicleTowedByVehicle 

y en los casos

con el camion 515 y el trailer 584 me dio negativo, como si no estaria enganchado al camion.

sera por la version del mta?

mi version es 1.2

saludos

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...