Jump to content

Creando mi Primer SQL


Recommended Posts

que esta mal ? me sale error cerca del INTO expected near ')' linea 146

aqui los codes

-------------Server--------- 
function cb1 ( ) 
    local money = getPlayerMoney ( source ) 
    local name = getPlayerName ( source ) 
    if name == "~ElMota~" then 
    destroyElement(blip2) 
    destroyElement(blip3) 
    destroyElement(blip4) 
    destroyElement(blip5) 
    blip1 = createBlipAttachedTo( source, 58 ) 
    else 
        if ( money >= 6000 ) then 
            takePlayerMoney ( source, 6000 ) 
            destroyElement(blip2) 
            destroyElement(blip3) 
            destroyElement(blip4) 
            destroyElement(blip5) 
            blip1 = createBlipAttachedTo( source, 58 ) 
        else 
            outputChatBox ( "No Tienes Suficiente Dinero", source ) 
        end 
    end 
end 
addEvent( "comprarBlip1", true ) 
addEventHandler( "comprarBlip1", getRootElement(), cb1 ) 
  
function cb2() 
    local money = getPlayerMoney ( source ) 
    local name = getPlayerName ( source ) 
    if name == "~ElMota~" then 
destroyElement("blip1") 
destroyElement("blip3") 
destroyElement("blip4") 
destroyElement("blip5") 
blip2 = createBlipAttachedTo( source, 59 ) 
    else 
        if ( money >= 6000 ) then 
            takePlayerMoney ( source, 6000 ) 
destroyElement("blip1") 
destroyElement("blip3") 
destroyElement("blip4") 
destroyElement("blip5") 
blip2 = createBlipAttachedTo( source, 59 ) 
        else 
            outputChatBox ( "No Tienes Suficiente Dinero", source ) 
        end 
    end 
end 
addEvent( "comprarBlip2", true ) 
addEventHandler( "comprarBlip2", getRootElement(), cb2 ) 
  
function cb3() 
    local money = getPlayerMoney ( source ) 
    local name = getPlayerName ( source ) 
    if name == "~ElMota~" then 
destroyElement(blip1) 
destroyElement(blip2) 
destroyElement(blip4) 
destroyElement(blip5) 
blip3 = createBlipAttachedTo( source, 60 ) 
    else 
        if ( money >= 6000 ) then 
            takePlayerMoney ( source, 6000 ) 
destroyElement(blip1) 
destroyElement(blip2) 
destroyElement(blip4) 
destroyElement(blip5) 
blip3 = createBlipAttachedTo( source, 60 ) 
        else 
            outputChatBox ( "No Tienes Suficiente Dinero", source ) 
        end 
    end 
end 
addEvent( "comprarBlip3", true ) 
addEventHandler( "comprarBlip3", getRootElement(), cb3 ) 
  
function cb4() 
    local money = getPlayerMoney ( source ) 
    local name = getPlayerName ( source ) 
    if name == "~ElMota~" then 
destroyElement(blip1) 
destroyElement(blip2) 
destroyElement(blip3) 
destroyElement(blip5) 
blip4 = createBlipAttachedTo( source, 61 ) 
    else 
        if ( money >= 6000 ) then 
            takePlayerMoney ( source, 6000 ) 
destroyElement(blip1) 
destroyElement(blip2) 
destroyElement(blip3) 
destroyElement(blip5) 
blip4 = createBlipAttachedTo( source, 61 ) 
        else 
            outputChatBox ( "No Tienes Suficiente Dinero", source ) 
        end 
    end 
end 
addEvent( "comprarBlip4", true ) 
addEventHandler( "comprarBlip4", getRootElement(), cb4 ) 
  
function cb5() 
    local money = getPlayerMoney ( source ) 
    local name = getPlayerName ( source ) 
    if name == "~ElMota~" then 
destroyElement(blip1) 
destroyElement(blip2) 
destroyElement(blip3) 
destroyElement(blip4) 
blip5 = createBlipAttachedTo( source, 62 ) 
    else 
        if ( money >= 6000 ) then 
            takePlayerMoney ( source, 6000 ) 
destroyElement(blip1) 
destroyElement(blip2) 
destroyElement(blip3) 
destroyElement(blip4) 
blip5 = createBlipAttachedTo( source, 62 ) 
        else 
            outputChatBox ( "No Tienes Suficiente Dinero", source ) 
        end 
    end 
end 
addEvent( "comprarBlip5", true ) 
addEventHandler( "comprarBlip5", getRootElement(), cb5 ) 
  
function cb6() 
destroyElement(blip1) 
destroyElement(blip2) 
destroyElement(blip3) 
destroyElement(blip4) 
destroyElement(blip5) 
end 
addEvent( "comprarBlip6", true ) 
addEventHandler( "comprarBlip6", getRootElement(), cb6 ) 
  
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()),  
function() 
executeSQLQuery("CREATE TABLE IF NOT EXISTS blips (Cuenta STRING,blipN NUMBER)") 
end 
) 
  
addEventHandler("onPlayerQuit", getRootElement(),  
function() 
obtenerB = getBlipIcon( source ) 
executeSQLInsert(INSERT INTO 'blips' ('Cuenta', 'blipN') VALUES ('..getAccountName( source )..', '..obtenerB..')) 
end 
) 
  
addEventHandler("onPlayerLogin" getRootElement(),  
function() 
  
local consulta = executeSQLQuery("SELECT * FROM blips WHERE Cuenta = '"..getPlayerName(source).."'") 
local consulta2 = executeSQLQuery("SELECT * FROM blips WHERE blipN = '"..attachElements( source, obtenerB ).."'") 
end 
) 

GUIEditor_Window = {} 
GUIEditor_Button = {} 
GUIEditor_Label = {} 
GUIEditor_Image = {} 
  
GUIEditor_Window[1] = guiCreateWindow(0.36,0.225,0.2412,0.6017,"GUI Blips",true) 
guiWindowSetMovable(GUIEditor_Window[1],false) 
guiWindowSetSizable(GUIEditor_Window[1],false) 
GUIEditor_Image[1] = guiCreateStaticImage(34,63,31,26,"images/Blip58.png",false,GUIEditor_Window[1]) 
GUIEditor_Button[1] = guiCreateButton(69,63,105,28,"Buy Blip58",false,GUIEditor_Window[1]) 
GUIEditor_Image[2] = guiCreateStaticImage(33,106,32,30,"images/Blip59.png",false,GUIEditor_Window[1]) 
GUIEditor_Button[2] = guiCreateButton(69,108,105,28,"Buy Blip59",false,GUIEditor_Window[1]) 
GUIEditor_Image[3] = guiCreateStaticImage(33,151,32,32,"images/Blip60.png",false,GUIEditor_Window[1]) 
GUIEditor_Button[3] = guiCreateButton(69,157,105,28,"Buy Blip60",false,GUIEditor_Window[1]) 
GUIEditor_Image[4] = guiCreateStaticImage(33,204,32,31,"images/Blip61.png",false,GUIEditor_Window[1]) 
GUIEditor_Button[4] = guiCreateButton(69,208,105,28,"Buy Blip61",false,GUIEditor_Window[1]) 
GUIEditor_Image[5] = guiCreateStaticImage(33,253,32,27,"images/Blip62.png",false,GUIEditor_Window[1]) 
GUIEditor_Button[5] = guiCreateButton(69,255,105,28,"Buy Blip62",false,GUIEditor_Window[1]) 
GUIEditor_Label[1] = guiCreateLabel(31,292,149,18,"GUI Blips by ElMota",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[1],255,255,0) 
GUIEditor_Button[6] = guiCreateButton(68,322,108,28,"Usar el de defecto",false,GUIEditor_Window[1]) 
  
guiSetVisible(GUIEditor_Window[1],false) 
showCursor(false) 
  
bindKey("F7","down",  
function() 
guiSetVisible(GUIEditor_Window[1], not guiGetVisible(GUIEditor_Window[1])) 
showCursor(guiGetVisible(GUIEditor_Window[1])) 
end 
) 
  
addEventHandler("onClientMouseEnter", root,  
function() 
if source == GUIEditor_Button[1] then 
guiSetText(GUIEditor_Label[1], "Price : 6000") 
guiLabelSetColor(GUIEditor_Label[1], 0, 0, 255) 
elseif source == GUIEditor_Button[2] then 
guiLabelSetColor(GUIEditor_Label[1], 0, 0, 255) 
guiSetText(GUIEditor_Label[1], "Price : 6000") 
elseif source == GUIEditor_Button[3] then 
guiLabelSetColor(GUIEditor_Label[1], 0, 0, 255) 
guiSetText(GUIEditor_Label[1], "Price : 6000") 
elseif source == GUIEditor_Button[4] then 
guiLabelSetColor(GUIEditor_Label[1], 0, 0, 255) 
guiSetText(GUIEditor_Label[1], "Price : 6000") 
elseif source == GUIEditor_Button[5] then 
guiLabelSetColor(GUIEditor_Label[1], 0, 0, 255) 
guiSetText(GUIEditor_Label[1], "Price : 6000") 
end 
end 
) 
  
addEventHandler("onClientMouseLeave", root,  
function() 
if source == GUIEditor_Button[1] then 
guiLabelSetColor(GUIEditor_Label[1], 255, 255, 0) 
guiSetText(GUIEditor_Label[1], "GUI Blips by ElMota") 
elseif source == GUIEditor_Button[2] then 
guiLabelSetColor(GUIEditor_Label[1], 255, 255, 0) 
guiSetText(GUIEditor_Label[1], "GUI Blips by ElMota") 
elseif source == GUIEditor_Button[3] then 
guiLabelSetColor(GUIEditor_Label[1], 255, 255, 0) 
guiSetText(GUIEditor_Label[1], "GUI Blips by ElMota") 
elseif source == GUIEditor_Button[4] then 
guiLabelSetColor(GUIEditor_Label[1], 255, 255, 0) 
guiSetText(GUIEditor_Label[1], "GUI Blips by ElMota") 
elseif source == GUIEditor_Button[5] then 
guiLabelSetColor(GUIEditor_Label[1], 255, 255, 0) 
guiSetText(GUIEditor_Label[1], "GUI Blips by ElMota") 
end 
end 
) 
  
addEventHandler("onClientGUIClick", root,  
function() 
if source == GUIEditor_Button[1] then 
triggerServerEvent("comprarBlip1", getLocalPlayer()) 
elseif source == GUIEditor_Button[2] then 
triggerServerEvent("comprarBlip2", getLocalPlayer()) 
elseif source == GUIEditor_Button[3] then 
triggerServerEvent("comprarBlip3", getLocalPlayer()) 
elseif source == GUIEditor_Button[4] then 
triggerServerEvent("comprarBlip4", getLocalPlayer()) 
elseif source == GUIEditor_Button[5] then 
triggerServerEvent("comprarBlip5", getLocalPlayer()) 
elseif source == GUIEditor_Button[6] then 
triggerServerEvent("comprarBlip6", getLocalPlayer()) 
end 
end 
) 

gracias de antemano

Link to comment

Te falto las comillas del principio, y de los dos valores.

  
  
local account = getPlayerAccount(source) 
executeSQLQuery("INSERT INTO blips (Cuenta, blipN) VALUES ('"..getAccountName( account).."', '"..obtenerB.."')") 
  
  

Y pone query, no pongas insert porque es diferente.

Otra aclaracion, yo puse los ' ' como aclaracion, no se si lo toma como valido (creo que no hay problema en ponerlo, pero como nunca lo use, ni idea).

EDIT : otro super detalle , no pongas ...getAccountName(source) , porque necesitas el account no el player

Link to comment

no funciono D: me compre un blip reconecte y ya no tenia el blip D:

-------------Server--------- 
function cb1 ( ) 
    local money = getPlayerMoney ( source ) 
    local name = getPlayerName ( source ) 
    if name == "~ElMota~" then 
    destroyElement(blip2) 
    destroyElement(blip3) 
    destroyElement(blip4) 
    destroyElement(blip5) 
    blip1 = createBlipAttachedTo( source, 58 ) 
    else 
        if ( money >= 6000 ) then 
            takePlayerMoney ( source, 6000 ) 
            destroyElement(blip2) 
            destroyElement(blip3) 
            destroyElement(blip4) 
            destroyElement(blip5) 
            blip1 = createBlipAttachedTo( source, 58 ) 
        else 
            outputChatBox ( "No Tienes Suficiente Dinero", source ) 
        end 
    end 
end 
addEvent( "comprarBlip1", true ) 
addEventHandler( "comprarBlip1", getRootElement(), cb1 ) 
  
function cb2() 
    local money = getPlayerMoney ( source ) 
    local name = getPlayerName ( source ) 
    if name == "~ElMota~" then 
destroyElement("blip1") 
destroyElement("blip3") 
destroyElement("blip4") 
destroyElement("blip5") 
blip2 = createBlipAttachedTo( source, 59 ) 
    else 
        if ( money >= 6000 ) then 
            takePlayerMoney ( source, 6000 ) 
destroyElement("blip1") 
destroyElement("blip3") 
destroyElement("blip4") 
destroyElement("blip5") 
blip2 = createBlipAttachedTo( source, 59 ) 
        else 
            outputChatBox ( "No Tienes Suficiente Dinero", source ) 
        end 
    end 
end 
addEvent( "comprarBlip2", true ) 
addEventHandler( "comprarBlip2", getRootElement(), cb2 ) 
  
function cb3() 
    local money = getPlayerMoney ( source ) 
    local name = getPlayerName ( source ) 
    if name == "~ElMota~" then 
destroyElement(blip1) 
destroyElement(blip2) 
destroyElement(blip4) 
destroyElement(blip5) 
blip3 = createBlipAttachedTo( source, 60 ) 
    else 
        if ( money >= 6000 ) then 
            takePlayerMoney ( source, 6000 ) 
destroyElement(blip1) 
destroyElement(blip2) 
destroyElement(blip4) 
destroyElement(blip5) 
blip3 = createBlipAttachedTo( source, 60 ) 
        else 
            outputChatBox ( "No Tienes Suficiente Dinero", source ) 
        end 
    end 
end 
addEvent( "comprarBlip3", true ) 
addEventHandler( "comprarBlip3", getRootElement(), cb3 ) 
  
function cb4() 
    local money = getPlayerMoney ( source ) 
    local name = getPlayerName ( source ) 
    if name == "~ElMota~" then 
destroyElement(blip1) 
destroyElement(blip2) 
destroyElement(blip3) 
destroyElement(blip5) 
blip4 = createBlipAttachedTo( source, 61 ) 
    else 
        if ( money >= 6000 ) then 
            takePlayerMoney ( source, 6000 ) 
destroyElement(blip1) 
destroyElement(blip2) 
destroyElement(blip3) 
destroyElement(blip5) 
blip4 = createBlipAttachedTo( source, 61 ) 
        else 
            outputChatBox ( "No Tienes Suficiente Dinero", source ) 
        end 
    end 
end 
addEvent( "comprarBlip4", true ) 
addEventHandler( "comprarBlip4", getRootElement(), cb4 ) 
  
function cb5() 
    local money = getPlayerMoney ( source ) 
    local name = getPlayerName ( source ) 
    if name == "~ElMota~" then 
destroyElement(blip1) 
destroyElement(blip2) 
destroyElement(blip3) 
destroyElement(blip4) 
blip5 = createBlipAttachedTo( source, 62 ) 
    else 
        if ( money >= 6000 ) then 
            takePlayerMoney ( source, 6000 ) 
destroyElement(blip1) 
destroyElement(blip2) 
destroyElement(blip3) 
destroyElement(blip4) 
blip5 = createBlipAttachedTo( source, 62 ) 
        else 
            outputChatBox ( "No Tienes Suficiente Dinero", source ) 
        end 
    end 
end 
addEvent( "comprarBlip5", true ) 
addEventHandler( "comprarBlip5", getRootElement(), cb5 ) 
  
function cb6() 
destroyElement(blip1) 
destroyElement(blip2) 
destroyElement(blip3) 
destroyElement(blip4) 
destroyElement(blip5) 
end 
addEvent( "comprarBlip6", true ) 
addEventHandler( "comprarBlip6", getRootElement(), cb6 ) 
  
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()),  
function() 
executeSQLQuery("CREATE TABLE IF NOT EXISTS blips (Cuenta STRING,blipN NUMBER)") 
end 
) 
  
addEventHandler("onPlayerQuit", getRootElement(),  
function() 
obtenerB = getBlipIcon( source ) 
local account = getPlayerAccount(thePlayer) 
executeSQLQuery("INSERT INTO blips (Cuenta, blipN) VALUES ('"..getAccountName( account).."', '"..obtenerB.."')") 
end 
) 
  
addEventHandler("onPlayerLogin", getRootElement(),  
function() 
local consulta = executeSQLQuery("SELECT * FROM blips WHERE Cuenta = '"..getPlayerName(source).."'") 
local consulta2 = executeSQLQuery("SELECT * FROM blips WHERE blipN = '"..attachElements( source, obtenerB ).."'") 
end 
) 

Link to comment

Alex podes usar SQL para TODO. El tema es que lo uso mal...

  
  
function(_,account) 
local query = executeSQLQuery("SELECT * FROM blips WHERE Cuenta = '"..getAccountName(account).."'") 
if #query == 1 then 
createBlipAttachedTo(source,query[1]["blipN"]) 
  
end 
end 
  

Si entendi bien, eso es lo que queres, que se atachee el blip al jugador, por lo tanto si guardas el numero de blip

Link to comment
  • Recently Browsing   0 members

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