Jump to content

[help] MoveObject


kamani

Recommended Posts

Posted

Hey, i have object , i make script

when i go to in checkpoint. object moved, but moved object see only one player (hitplayer).

One question, how make the moved object to seen the other players ( for all players )...

Posted

make it server side, not client side

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

i have this in server.lua:

  
addEvent("ser",true) 
addEventHandler("ser",root, 
    function(keypadID) 
                               local gate = getElementByID(keypadID) 
        if gate then 
            local x = tonumber(getElementData(gate,"newPosX")) 
            local y = tonumber(getElementData(gate,"newPosY")) 
            local z = tonumber(getElementData(gate,"newPosZ")) 
            moveObject(gate,1500,x,y,z) 
            x = tonumber(getElementData(gate,"posX")) 
            y = tonumber(getElementData(gate,"posY")) 
            z = tonumber(getElementData(gate,"posZ"))    
            setTimer(moveObject,5000,1,gate,1500,x,y,z) 
        end 
    end 
) 
  

and in my console get Bad argument @ 'getElementsByType' , how get me object by id ?

Posted

i dont see any "getElementsByType" in your script.

post whole script.

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

I download keypad resource and changed for me, i want to make moved object to see for all players..

CLIENT

  
local Nuovada2 = createMarker( -1619.0522460938, 687.70208740234, 6.1344275474548, 'cylinder', 0.5, 71, 216, 0, source) 
function createKeypad() 
    local sWidth, sHeight = guiGetScreenSize() 
    local Width,Height = 142,276 
    local X = (sWidth/2) - (Width/2) 
    local Y = (sHeight/2) - (Height/2) 
    keypadWindow = guiCreateWindow(X,Y,Width,Height,"Kalejimo Sistema",false) 
    addEventHandler("onClientGUIClick",keypadWindow,processKeypadClicks,true) 
    guiWindowSetSizable(keypadWindow,false) 
    keypadButton1 = guiCreateButton(13,68,37,36,"1",false,keypadWindow) 
    keypadButton2 = guiCreateButton(53,68,37,36,"2",false,keypadWindow) 
    keypadButton3 = guiCreateButton(93,68,37,36,"3",false,keypadWindow) 
    keypadButton4 = guiCreateButton(13,108,37,36,"4",false,keypadWindow) 
    keypadButton5 = guiCreateButton(53,108,37,36,"5",false,keypadWindow) 
    keypadButton6 = guiCreateButton(93,108,37,36,"6",false,keypadWindow) 
    keypadButton7 = guiCreateButton(13,148,37,36,"7",false,keypadWindow) 
    keypadButton8 = guiCreateButton(53,148,37,36,"8",false,keypadWindow) 
    keypadButton9 = guiCreateButton(93,148,37,36,"9",false,keypadWindow) 
    keypadButtonAsterix = guiCreateButton(13,188,37,36,"*",false,keypadWindow) 
    keypadButton0 = guiCreateButton(53,188,37,36,"0",false,keypadWindow) 
    keypadButtonHash = guiCreateButton(93,188,37,36,"#",false,keypadWindow) 
    keypadButtonExit = guiCreateButton(13,235,37,36,"Iseiti",false,keypadWindow) 
    keypadButtonEnter = guiCreateButton(53,235,37,36,"Ivesti",false,keypadWindow) 
    keypadButtonClear = guiCreateButton(93,235,37,36,"Isvalyti",false,keypadWindow) 
    keypadGridlistDisplay = guiCreateGridList(13,25,117,33,false,keypadWindow) 
    guiGridListSetSelectionMode(keypadGridlistDisplay,2) 
    guiSetAlpha(keypadGridlistDisplay,0.6) 
    keypadLabelDisplay = guiCreateLabel(14,26,115,30,"Spauskite Isvalyti.",false,keypadWindow) 
    guiLabelSetColor(keypadLabelDisplay,255,000,000) 
    guiLabelSetVerticalAlign(keypadLabelDisplay,"center") 
    guiLabelSetHorizontalAlign(keypadLabelDisplay,"center",false) 
    guiSetVisible(keypadWindow,false) 
end 
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),createKeypad) 
function updateDisplay(text) 
    if text then 
        if tonumber(text) or text == "*" or text == "#" then 
            guiSetText(keypadLabelDisplay,guiGetText(keypadLabelDisplay) .. text) 
        else 
            guiSetText(keypadLabelDisplay,text) 
        end  
    else 
        guiSetText(keypadLabelDisplay,"") 
    end 
end 
function processKeypadClicks(button,state) 
    if button == "left" and state == "up" then 
        if getElementType(source) == "gui-button" then 
            triggerEvent("onKeypadButtonClicked",source,getElementData(keypadWindow,"keypadID")) 
        end 
    end 
end 
addEvent("onKeypadButtonClicked",false) 
addEventHandler("onKeypadButtonClicked",root, 
    function(keypadID) 
        if guiGetText(keypadLabelDisplay) == "Iveskite koda." or guiGetText(keypadLabelDisplay) == "Kodas netinka." then 
            updateDisplay() 
        end 
        if guiGetText(source) == "Isvalyti" then 
            updateDisplay() 
        elseif guiGetText(source) == "Ivesti" then 
            local code = guiGetText(keypadLabelDisplay) 
            if code then 
                triggerServerEvent("verifyKeypadCode",getLocalPlayer(),code,keypadID) 
            end 
        elseif guiGetText(source) == "Iseiti" then 
            guiSetVisible(keypadWindow,false) 
            updateDisplay("Iveskite koda.") 
            showCursor(false,false) 
        else 
            updateDisplay(guiGetText(source))    
        end 
    end 
) 
addEvent("onKeypadVerificationSuccessful",true) 
addEventHandler("onKeypadVerificationSuccessful",root, 
function() 
        guiSetVisible(keypadWindow,false) 
        updateDisplay("Iveskite koda.") 
        showCursor(false,false) 
                triggerServerEvent("Patikrinti",getLocalPlayer(),keypadID)        
    end 
) 
  
addEvent("onKeypadVerificationFailed",true) 
addEventHandler("onKeypadVerificationFailed",root, 
    function() 
        updateDisplay("Kodas netinka.") 
    end 
) 
addEventHandler ( "onClientMarkerHit", Nuovada2,function(hitPlayer, matchingDimension) 
        if hitPlayer == getLocalPlayer() then 
    guiSetVisible(keypadWindow,true) 
    showCursor(true,true) 
    setElementData(keypadWindow,"keypadID","GateKeypadCode",source) 
        end 
end) 
  

SERVER

  
local keypadCodes = { 
    ["GateKeypadCode"] = "1234" 
} 
addEvent("verifyKeypadCode",true) 
addEventHandler("verifyKeypadCode",root,function(code,keypadID) 
    if code then 
        if code == keypadCodes[keypadID] then 
            triggerClientEvent(client,"onKeypadVerificationSuccessful",client,keypadID) 
        else 
            triggerClientEvent(client,"onKeypadVerificationFailed",client,keypadID) 
        end 
    end 
end) 
  
addEvent("Patikrinti",true) 
addEventHandler("Patikrinti",root, 
    function(keypadID) 
        local gate = getElementByID(keypadID) 
        if gate then 
            local x = tonumber(getElementData(gate,"newPosX")) 
            local y = tonumber(getElementData(gate,"newPosY")) 
            local z = tonumber(getElementData(gate,"newPosZ")) 
            moveObject(gate,1500,x,y,z) 
            x = tonumber(getElementData(gate,"posX")) 
            y = tonumber(getElementData(gate,"posY")) 
            z = tonumber(getElementData(gate,"posZ"))    
            setTimer(moveObject,5000,1,gate,1500,x,y,z) 
        end 
    end) 
  

Posted

and where are you creating object you like to move?

i dont see any createObject in this script.

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

post line with this object

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

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