Jump to content

help me with a SQL Table


iFoReX

Recommended Posts

try this:

local peds 
addEventHandler("onResourceStart",resourceRoot,function() 
    pedsTable = executeSQLQuery("SELECT * FROM peds") 
    for i,v in ipairs(pedsTable)do 
        local ped = createPed(v[2],v[3],v[4],v[5]) 
        setElementRotation(ped,v[6],v[7],v[8]) 
        peds = (v[1]) 
        outputChatBox("Ped Created",root,0,255,0) 
    end 
    outputChatBox("A total of "..tostring(peds).." was created.",root) 
end) 
  
addEvent("savePed",true) 
addEventHandler("savePed",root,function(ped) 
    if(ped)then 
        local x, y, z = getElementPosition( ped ) 
        local modelo = getElementModel( ped ) 
        local rotX, rotY, rotZ = getElementRotation( ped ) 
        local peds = peds+1 
        set("peds",peds) 
        executeSQLInsert ("peds","'"..peds.."','"..modelo.."', '"..xP.."', '"..yP.."', '"..zP.."', '"..rotX.."', '"..rotY.."', '"..rotZ.."'") 
    end 
end) 

Link to comment

try this:

Client:

function botoones() 
    local x, y, z = getElementPosition( getLocalPlayer() ) 
    local skinID = getElementModel( getLocalPlayer() ) 
    if source == GUIEditor_Button[1] then 
        guiSetText(GUIEditor_Edit[2], x) 
        guiSetText(GUIEditor_Edit[3], y) 
        guiSetText(GUIEditor_Edit[4], z) 
    elseif source == GUIEditor_Button[2] then 
        guiSetText(GUIEditor_Edit[5], rx) 
        guiSetText(GUIEditor_Edit[6], ry) 
        guiSetText(GUIEditor_Edit[7], rz) 
    elseif source == GUIEditor_Button[3] then 
        guiSetText(GUIEditor_Edit[1], skinID) 
    elseif source == GUIEditor_Button[5] then 
        guiSetText(GUIEditor_Edit[1], "") 
        guiSetText(GUIEditor_Edit[2], "") 
        guiSetText(GUIEditor_Edit[3], "") 
        guiSetText(GUIEditor_Edit[4], "") 
        guiSetText(GUIEditor_Edit[5], "") 
        guiSetText(GUIEditor_Edit[6], "") 
        guiSetText(GUIEditor_Edit[7], "") 
    elseif source == GUIEditor_Button[6] then 
        guiSetText(GUIEditor_Edit[1], "") 
        guiSetText(GUIEditor_Edit[2], "") 
        guiSetText(GUIEditor_Edit[3], "") 
        guiSetText(GUIEditor_Edit[4], "") 
        guiSetText(GUIEditor_Edit[5], "") 
        guiSetText(GUIEditor_Edit[6], "") 
        guiSetText(GUIEditor_Edit[7], "") 
        guiSetVisible(GUIEditor_Window[1],false) 
        showCursor(false) 
    elseif source == GUIEditor_Button[4] then 
        ped = createPed(tonumber(guiGetText(GUIEditor_Edit[1])), tonumber(guiGetText(GUIEditor_Edit[2])), tonumber(guiGetText(GUIEditor_Edit[3])), tonumber(guiGetText(GUIEditor_Edit[4])), tonumber(guiGetText(GUIEditor_Edit[5])), tonumber(guiGetText(GUIEditor_Edit[6])), tonumber(guiGetText(GUIEditor_Edit[7]))) 
        triggerServerEvent("savePed",localPlayer,ped) 
    end 
end 
addEventHandler("onClientGUIClick", guiRoot, botoones,true )--always include a bool at the end for button/gui click events 

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...