Jump to content

[HELP] Buyer and seller on marker


Recommended Posts

Good morning everyone, I'm trying to make a script to sell drugs, the drugs are stored in the account Data and elements Data of each player, I want to define a marker that when the other user (Buyer) enters the marker, he opens the window of purchases and see the prices that the seller previously defined, I do not know how to synchronize this interaction with two users, buyer and seller, many thanks!

Server Side:

function drug( ) 
    local x, y, z = getElementPosition ( source ) 
    marker =  createMarker ( x, y, z-1, "cylinder", 1.5, 255, 255, 0, 170 ) 
end 
addEvent( "onClick", true ) 
addEventHandler("onClick", root , drug) 
  
function destroyMarker( ) 
	if isElement( marker) then 
		destroyElement(marker) 
	end 
end 
addEvent( "onClick2", true ) 
addEventHandler("onClick2", root , destroyMarker) 
  
function asignarValoresCripa(source, valorCripa) 
	setAccountData( source,"valorCripa", valorCripa) 
end 
addEvent( "addCripaCost", true ) 
addEventHandler("addCripaCost", root , asignarValoresCripa) 
  
function darValoresCripa (p) 
getAccountData(p,"valorCripa") 
end 
addEvent( "valorCripa", true ) 
addEventHandler("valorCripa", root , darValoresCripa) 

Client

GUIEditor = { 
    label = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
ventanaCompra = guiCreateWindow(222, 119, 395, 349, "Comprar Drogas a usuario", false) 
        guiWindowSetSizable(ventanaCompra, false) 
        cerrarCompra = guiCreateButton(46, 293, 93, 46, "Cerrar", false, ventanaCompra) 
        cantidadCripa = guiCreateEdit(248, 46, 43, 31, "", false, ventanaCompra) 
        cantidadRuedas = guiCreateEdit(248, 87, 43, 31, "", false, ventanaCompra) 
        cantidadPerica = guiCreateEdit(248, 128, 43, 31, "", false, ventanaCompra) 
        cantidadLsd = guiCreateEdit(248, 169, 43, 31, "", false, ventanaCompra) 
        cantidadHeroina = guiCreateEdit(248, 210, 43, 31, "", false, ventanaCompra) 
        cantidadRivotril = guiCreateEdit(248, 251, 43, 31, "", false, ventanaCompra) 
        precioCripa = guiCreateEdit(149, 46, 86, 31, "", false, ventanaCompra) 
        guiEditSetReadOnly(precioCripa, true) 
        precioRuedas = guiCreateEdit(149, 87, 86, 31, "", false, ventanaCompra) 
        guiEditSetReadOnly(precioRuedas, true) 
        precioPerica = guiCreateEdit(149, 128, 86, 31, "", false, ventanaCompra) 
        guiEditSetReadOnly(precioPerica, true) 
        precioLsd = guiCreateEdit(149, 169, 86, 31, "", false, ventanaCompra) 
        guiEditSetReadOnly(precioLsd, true) 
        precioHeroina = guiCreateEdit(149, 210, 86, 31, "", false, ventanaCompra) 
        guiEditSetReadOnly(precioHeroina, true) 
        precioRivotril = guiCreateEdit(149, 251, 86, 31, "", false, ventanaCompra) 
        guiEditSetReadOnly(precioRivotril, true) 
        GUIEditor.label[1] = guiCreateLabel(15, 47, 124, 236, "Cripa        Precio\n\n\nRuedas     Precio\n\n\nPerica      Precio\n\n\nLsd         Precio\n\n\nHeroina   Precio\n\n\nRivotril    Precio", false, ventanaCompra) 
        GUIEditor.label[2] = guiCreateLabel(241, 23, 50, 13, "Cantidad", false, ventanaCompra) 
        comprarCripa = guiCreateButton(310, 46, 68, 31, "Comprar", false, ventanaCompra) 
        comprarRuedas = guiCreateButton(310, 87, 68, 31, "Comprar", false, ventanaCompra) 
        comprarPerica = guiCreateButton(310, 128, 68, 31, "Comprar", false, ventanaCompra) 
        comprarLsd = guiCreateButton(310, 169, 68, 31, "Comprar", false, ventanaCompra) 
        comprarHeroina = guiCreateButton(310, 210, 68, 31, "Comprar", false, ventanaCompra) 
        comprarRivotril = guiCreateButton(310, 251, 68, 31, "Comprar", false, ventanaCompra)        
         
        --ventana Sell 
        panelSell = guiCreateWindow(251, 207, 294, 319, "Venta de drogas", false) 
        guiWindowSetSizable(panelSell, false) 
        priceWeed = guiCreateEdit(147, 30, 53, 29, "", false, panelSell) 
        priceRuedas = guiCreateEdit(147, 59, 53, 29, "", false, panelSell) 
        pricePerica = guiCreateEdit(147, 88, 53, 29, "", false, panelSell) 
        priceLsd = guiCreateEdit(147, 117, 53, 29, "", false, panelSell) 
        priceEsteroides = guiCreateEdit(147, 146, 53, 29, "", false, panelSell) 
        priceRivotril = guiCreateEdit(147, 175, 53, 29, "", false, panelSell) 
        stopSell = guiCreateButton(29, 234, 100, 48, "Parar de vender", false, panelSell) 
        GUIEditor.label[1] = guiCreateLabel(29, 40, 94, 16, "Cripa", false, panelSell) 
        GUIEditor.label[2] = guiCreateLabel(29, 66, 94, 16, "Ruedas", false, panelSell) 
        GUIEditor.label[3] = guiCreateLabel(29, 92, 94, 16, "Perica", false, panelSell) 
        GUIEditor.label[4] = guiCreateLabel(29, 120, 94, 16, "LSD", false, panelSell) 
        GUIEditor.label[5] = guiCreateLabel(29, 149, 94, 16, "Esteroides", false, panelSell) 
        GUIEditor.label[6] = guiCreateLabel(29, 178, 94, 16, "Rivortril", false, panelSell) 
        GUIEditor.label[7] = guiCreateLabel(145, 210, 45, 14, "Precios", false, panelSell) 
        guardaCripa = guiCreateButton(219, 33, 65, 26, "Guardar", false, panelSell) 
        guardaRuedas = guiCreateButton(220, 62, 64, 26, "Guardar", false, panelSell) 
        guardaPerica = guiCreateButton(220, 91, 64, 26, "Guardar", false, panelSell) 
        guardaLsd = guiCreateButton(220, 120, 60, 26, "Guardar", false, panelSell) 
        guardaEsteroides = guiCreateButton(220, 149, 60, 26, "Guardar", false, panelSell) 
        guardaRivotril = guiCreateButton(220, 178, 60, 26, "Guardar", false, panelSell)  
        guiSetVisible ( panelSell, false) 
        guiSetVisible ( ventanaCompra, false) 
         
        addEventHandler ( "onClientGUIClick", cerrarCompra, cerrarCompraEvent, false ) 
        addEventHandler ( "onClientGUIClick", stopSell, cerrarVentaEvent, false ) 
        addEventHandler ( "onClientGUIClick", guardaCripa, addPrecioCripa, false ) 
         
         
    end 
) 
--Window Shop 
  
--Funciones para vendedor 
  
  
  
  
function venderDroga( localPlayer ) 
triggerServerEvent ( "onClick", getLocalPlayer() ) 
guiSetVisible ( panelSell, true) 
showCursor ( true ) 
end 
addCommandHandler("venderdroga", venderDroga ) 
  
function addPrecioCripa (localPlayer) 
    local valorCripa = guiGetText ( priceWeed )  
    if ( tonumber(valorCripa)  > 0 ) then    
    triggerServerEvent ( "addCripaCost", getLocalPlayer(), source ) 
    outputChatBox("has puesto un precio a la cripa de "..valorCripa.."")    else 
    outputChatBox("Coloca un valor mayor a 0") end 
   end 
  
  
function cerrarVentaEvent ( localPlayer ) 
    triggerServerEvent ( "onClick2", getLocalPlayer() ) 
    guiSetVisible ( panelSell, false) 
    showCursor ( false ) 
    end 
  
  
  
--Funciones comprador 
function MarkerHit ( p, matchingDimension ) 
    local priceCripa = triggerServerEvent ( "valorCripa", getLocalPlayer() ) 
    if p == localPlayer then  
    guiSetVisible ( ventanaCompra, true) 
    showCursor ( true ) 
    guiSetText(precioCripa,  "..priceCripa..") 
    end 
end 
addEventHandler ( "onClientMarkerHit", getRootElement(marker), MarkerHit ) 
  
function cerrarCompraEvent ( localPlayer ) 
    guiSetVisible ( ventanaCompra, false) 
    showCursor ( false ) 
    end 

 

Link to comment
function drug( ) 
    local x, y, z = getElementPosition ( source ) 
    marker =  createMarker ( x, y, z-1, "cylinder", 1.5, 255, 255, 0, 170 ) 
end 
addEvent( "onClick", true ) 
addEventHandler("onClick", root , drug) 
  
function destroyMarker( ) 
	if isElement( marker) then 
		destroyElement(marker) 
	end 
end 
addEvent( "onClick2", true ) 
addEventHandler("onClick2", root , destroyMarker) 
  
function asignarValoresCripa(source, valorCripa) 
	setAccountData(getPlayerAccount(source) ,"valorCripa", valorCripa) 
end 
addEvent( "addCripaCost", true ) 
addEventHandler("addCripaCost", root , asignarValoresCripa) 
  
function darValoresCripa (p) 
getAccountData(getPlayerAccount(p) ,"valorCripa") 
end 
addEvent( "valorCripa", true ) 
addEventHandler("valorCripa", root , darValoresCripa)

 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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