Xwad Posted October 29, 2015 Share Posted October 29, 2015 Hi i made this script that teleport the player to a given cordinates. But when i press f then the debug says this: WARNING: machineGun\client.lua:31: Bad argument @ 'setElementPosition' [Expected element at argument 1, got string 'f'] WARNING: machineGun\client.lua:30: Bad argument @ 'getElementPosition' [Expected element at argument 1, got string 'f'] function binds() bindKey ( "f", "down", onEnter ) end addEventHandler('onClientResourceStart', getRootElement(), binds) function onEnter ( localPlayer, posX, posY, posZ ) local x,y,z = getElementPosition(localPlayer) setElementPosition ( localPlayer, -2422.1469, -607.8954, 132.56 ) end Link to comment
Dimos7 Posted October 29, 2015 Share Posted October 29, 2015 function binds() bindKey("f", "down", onEnter) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), binds) function onEnter(posX, posY, posZ) local x, y, z = getElementPosition(localPlayer) setElementPosition(localPlayer, -2422.1469, -607.8954, 132.56) end Link to comment
AMARANT Posted October 29, 2015 Share Posted October 29, 2015 Try it client-side. Or if you want it on the server add the first argument to your bindKey function like says your debug. It must be player element. And it's an obvious warning, learn to read it first. UPD: I didn't notice it's already client-side. Sorry. The solution is above, you just specified loclPlayer in bindKey handler function. Sorry again... Link to comment
Xwad Posted October 29, 2015 Author Share Posted October 29, 2015 its client sided. And its working thanks:D Link to comment
Xwad Posted October 30, 2015 Author Share Posted October 30, 2015 One more question. I tryed it in server but its also not working there. debugscript: Bad argumentum @ 'getElementPosition' [expected element at argumentum 1,got nil] Bad argumentum @ 'setElementPosition' [expected element at argumentum 1,got nil] Bad argumentum @ 'setElementFrozen' [expected element at argumentum 1,got nil] server function onEnter () outputChatBox ( "Test" ) local x, y, z = getElementPosition(thePlayer) setElementPosition(thePlayer, -2422.1469, -607.8954, 132.56) setElementFrozen ( thePlayer, true ) end addEvent( "check", true ) addEventHandler( "check", resourceRoot, onEnter ) client function binds() bindKey ( "e", "down", onEnter ) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), binds) function onEnter(posX, posY, posZ) triggerServerEvent ( "check", resourceRoot ) end Link to comment
Dimos7 Posted October 30, 2015 Share Posted October 30, 2015 function onEnter(thePlayer) local x, y, z = getElementPosition(thePlayer) setElementPosition(thePlayer, -2422.1469, -607.8954, 132.56) setElementFrozen(thePlayer, true) end addEvent("check", true) addEventHandler("check", getRootElement(), onEnter) function bind() bindKey(source, "e", "down", onEnter) end addEventHandler("onPlayerLogin", getRootElement(), bind) function binds() for i, v in ipairs(getElementsByType("player")) do bindKey(v, "e", "down", onEnter) end end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), binds) I wrote everything in server side Link to comment
Xwad Posted October 30, 2015 Author Share Posted October 30, 2015 no I dont want it in server. I want to make with triggerServerEvent. But then its always saying me bad argumentum! MY good i have always problems with argumentums! Link to comment
AMARANT Posted October 30, 2015 Share Posted October 30, 2015 no I dont want it in server. I want to make with triggerServerEvent. But then its always saying me bad argumentum! MY good i have always problems with argumentums! Then change 'thePlayer' argument to 'source' on the server. Link to comment
Xwad Posted January 23, 2016 Author Share Posted January 23, 2016 Hi. Pls help me again, its not working again and theres no debugscript.. The triggering is working.. Its starting the server side function but the animation and the position is not working client function onEnter() if guiGetVisible(icon) then triggerServerEvent ( "onEnter", resourceRoot ) end end server function onEnter ( posX, posY, posZ ) local x, y, z = getElementPosition(source) outputChatBox ( "Test" ) setElementPosition ( source, -2377.25, -578.71, 132.75 ) setPedAnimation ( source, "SILENCED", "SilenceCrouchfire", 1, false, false, false, true ) end addEvent( "onEnter", true ) addEventHandler( "onEnter", resourceRoot, onEnter ) Link to comment
ALw7sH Posted January 23, 2016 Share Posted January 23, 2016 Hi. Pls help me again, its not working again and theres no debugscript.. The triggering is working.. Its starting the server side function but the animation and the position is not workingclient function onEnter() if guiGetVisible(icon) then triggerServerEvent ( "onEnter", resourceRoot ) end end server function onEnter ( posX, posY, posZ ) local x, y, z = getElementPosition(source) outputChatBox ( "Test" ) setElementPosition ( source, -2377.25, -578.71, 132.75 ) setPedAnimation ( source, "SILENCED", "SilenceCrouchfire", 1, false, false, false, true ) end addEvent( "onEnter", true ) addEventHandler( "onEnter", resourceRoot, onEnter ) client function onEnter() if guiGetVisible(icon) then triggerServerEvent ( "onEnter", localPlayer ) end end server function onEnter () local x, y, z = getElementPosition(client) outputChatBox ( "Test" ) setElementPosition ( client, -2377.25, -578.71, 132.75 ) setPedAnimation ( client, "SILENCED", "SilenceCrouchfire", 1, false, false, false, true ) end addEvent( "onEnter", true ) addEventHandler( "onEnter", root, onEnter ) Link to comment
Xwad Posted January 24, 2016 Author Share Posted January 24, 2016 One more question. Now the bind key is not working. The debugscripts says its a bad argumentum server function onEnter () local x, y, z = getElementPosition(client) setElementPosition ( client, -2377.25, -578.71, 132.75 ) setPedAnimation ( client, "SILENCED", "SilenceCrouchfire", 1, false, false, false, true ) setTimer ( fireBind, 100, 1) end addEvent( "onEnter", true ) addEventHandler( "onEnter", root, onEnter ) function fireBind ( key, player ) bindKey ( player, "mouse1", "down", startFire ) bindKey ( player, "mouse1", "up", stopFire ) end Link to comment
Xwad Posted January 24, 2016 Author Share Posted January 24, 2016 One more question. Now the bind key is not working. The debugscripts says its a bad argumentum server function onEnter () local x, y, z = getElementPosition(client) setElementPosition ( client, -2377.25, -578.71, 132.75 ) setPedAnimation ( client, "SILENCED", "SilenceCrouchfire", 1, false, false, false, true ) setTimer ( fireBind, 100, 1) end addEvent( "onEnter", true ) addEventHandler( "onEnter", root, onEnter ) function fireBind ( key, player ) bindKey ( player, "mouse1", "down", startFire ) bindKey ( player, "mouse1", "up", stopFire ) end Link to comment
ALw7sH Posted January 24, 2016 Share Posted January 24, 2016 function onEnter () local x, y, z = getElementPosition(client) setElementPosition ( client, -2377.25, -578.71, 132.75 ) setPedAnimation ( client, "SILENCED", "SilenceCrouchfire", 1, false, false, false, true ) setTimer ( fireBind, 100, 1, client ) -- you haven't put the player argument here ( for the "fireBind" function ) end addEvent( "onEnter", true ) addEventHandler( "onEnter", root, onEnter ) function fireBind ( player ) bindKey ( player, "mouse1", "down", startFire ) bindKey ( player, "mouse1", "up", stopFire ) end Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now