BieHDC Posted May 30, 2013 Share Posted May 30, 2013 Hello, i want to make inside of a script something that starts commands like /mcreate in chat or mcreate in F8 console. In console this works but inside script it doesnt and i dont know why? It schould delete a current object, create a Ramp, rorate it. The commands after "do" are in the same script. I hope you will help me again Here is one of that i already tried: function makejump (player) do mdestroy do mcreate 1655 do rz -130 end addCommandHandler( "mjump", makejump ) Link to comment
xXMADEXx Posted May 30, 2013 Share Posted May 30, 2013 This script makes not scenes at all. Link to comment
myonlake Posted May 30, 2013 Share Posted May 30, 2013 Is this what you want? The command triggers a function, which deletes an existing ramp or creates a new one with the z-rotation -130. addCommandHandler("mjump", function(player, cmd) if (isElement(ramp)) then destroyElement(ramp) outputChatBox("* Ramp object destroyed.", player, 255, 0, 0, false) else local x, y, z = getElementPosition(player) local rx, ry, rz = getElementRotation(player) ramp = createObject(1655, x, y, z, rx, ry, -130) setElementInterior(ramp, getElementInterior(player)) setElementDimension(ramp, getElementDimension(player)) outputChatBox("* Ramp object created.", player, 0, 255, 0, false) end end ) Link to comment
BieHDC Posted May 30, 2013 Author Share Posted May 30, 2013 No i only wanna execute the 3 commands not more. I will post the full script Everything works exept last funktion local playerobj = {} local marker = {} objectid = {} maxobjects = 500 function playerLeave () setElementData ( source, "tempbuilder", false ) setElementData ( source, "permbuilder", false ) end function playerJoin () setElementData ( source, "tempbuilder", false ) setElementData ( source, "permbuilder", false ) local pname = getClientName(source) if (pname == "example") or (pname == "example2") then setElementData ( source, "permbuilder", true ) end end function thisResourceStart () local players = getElementsByType ( "player" ) for k,v in ipairs(players) do setElementData ( v, "tempbuilder", false ) setElementData ( v, "permbuilder", false ) local pname = getClientName(v) if (pname == "example") or (pname == "example2") then setElementData ( v, "permbuilder", true ) end end end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), thisResourceStart ) addEventHandler ( "onPlayerJoin", getRootElement(), playerJoin ) addEventHandler ( "onPlayerQuit", getRootElement(), playerLeave ) function createCurrentObject (player,cmd,objid) if ( hasObjectPermissionTo ( player, "function.unbanSerial", true)) or (getElementData ( player, "permbuilder" ) == true) or (getElementData ( player, "tempbuilder" ) == true) then if playerobj[player] then outputChatBox ( "You are already editing an object. Please save or delete to make another.", player ) else local x, y, z = getElementPosition(player) destroyMObj (player) playerobj[player] = createObject(tonumber(objid), x + 5, y + 5, z - 1) if marker[player] then destroyElement(marker[player]) end if playerobj[player] then marker[player] = createMarker ( x, y, z, "arrow", 5, 255, 255, 0, 255) attachElementToElement ( marker[player], playerobj[player], 0, 0, 10) else outputChatBox ( "" ..objid.. " does not appear to be a valid model ID.", player ) end end else outputChatBox ( "You do not have permission to build.", player ) end end addCommandHandler( "mcreate", createCurrentObject ) function moveObjZ (player,cmd,newz) if ( hasObjectPermissionTo ( player, "function.unbanSerial", true)) or (getElementData ( player, "permbuilder" ) == true) or (getElementData ( player, "tempbuilder" ) == true) then if playerobj[player] then local x, y, z = getElementPosition(playerobj[player]) moveObject ( playerobj[player], 200, x, y, z + tonumber(newz) ) end else outputChatBox ( "You do not have permission to build.", player ) end end addCommandHandler( "oz", moveObjZ ) function moveObjX (player,cmd,newx) if ( hasObjectPermissionTo ( player, "function.unbanSerial", true)) or (getElementData ( player, "permbuilder" ) == true) or (getElementData ( player, "tempbuilder" ) == true) then if playerobj[player] then local x, y, z = getElementPosition(playerobj[player]) moveObject ( playerobj[player], 200, x + tonumber(newx), y, z ) end else outputChatBox ( "You do not have permission to build.", player ) end end addCommandHandler( "ox", moveObjX ) function moveObjY (player,cmd,newy) if ( hasObjectPermissionTo ( player, "function.unbanSerial", true)) or (getElementData ( player, "permbuilder" ) == true) or (getElementData ( player, "tempbuilder" ) == true) then if playerobj[player] then local x, y, z = getElementPosition(playerobj[player]) moveObject ( playerobj[player], 200, x, y + tonumber(newy), z ) end else outputChatBox ( "You do not have permission to build.", player ) end end addCommandHandler( "oy", moveObjY ) function moveRotZ (player,cmd,newrz) if ( hasObjectPermissionTo ( player, "function.unbanSerial", true)) or (getElementData ( player, "permbuilder" ) == true) or (getElementData ( player, "tempbuilder" ) == true) then if playerobj[player] then local x, y, z = getElementPosition(playerobj[player]) moveObject ( playerobj[player], 200, x, y, z, 0, 0, tonumber(newrz) ) end else outputChatBox ( "You do not have permission to build.", player ) end end addCommandHandler( "rz", moveRotZ ) function moveRotX (player,cmd,newrx) if ( hasObjectPermissionTo ( player, "function.unbanSerial", true)) or (getElementData ( player, "permbuilder" ) == true) or (getElementData ( player, "tempbuilder" ) == true) then if playerobj[player] then local x, y, z = getElementPosition(playerobj[player]) moveObject ( playerobj[player], 200, x, y, z, tonumber(newrx), 0, 0 ) end else outputChatBox ( "You do not have permission to build.", player ) end end addCommandHandler( "rx", moveRotX ) function moveRotY (player,cmd,newry) if ( hasObjectPermissionTo ( player, "function.unbanSerial", true)) or (getElementData ( player, "permbuilder" ) == true) or (getElementData ( player, "tempbuilder" ) == true) then if playerobj[player] then local x, y, z = getElementPosition(playerobj[player]) moveObject ( playerobj[player], 200, x, y, z, 0, tonumber(newry), 0 ) end else outputChatBox ( "You do not have permission to build.", player ) end end addCommandHandler( "ry", moveRotY ) function destroyMObj (player,cmd) if ( hasObjectPermissionTo ( player, "function.unbanSerial", true)) or (getElementData ( player, "permbuilder" ) == true) or (getElementData ( player, "tempbuilder" ) == true) then if playerobj[player] then for i=0,maxobjects do if objectid[i] == playerobj[player] then local numstr = tostring(i) outputChatBox ( "Object ID deleted: " ..numstr.. "", player ) local succeed = destroyElement(playerobj[player]) if marker[player] then destroyElement(marker[player]) end objectid[i] = nil playerobj[player] = nil break end end end if marker[player] then destroyElement(marker[player]) end if playerobj[player] then destroyElement(playerobj[player]) end playerobj[player] = nil else outputChatBox ( "You do not have permission to build.", player ) end end addCommandHandler( "mdestroy", destroyMObj ) function clearObjects (player) if ( hasObjectPermissionTo ( player, "function.unbanSerial", true)) or (getElementData ( player, "permbuilder" ) == true) then for i=0,maxobjects do if objectid[i] then destroyElement(objectid[i]) end end objectid = nil objectid = {} local players = getElementsByType ( "player" ) for k,v in ipairs(players) do if marker[v] then destroyElement(marker[v]) end if playerobj[v] then destroyElement(playerobj[v]) end playerobj[v] = nil end if marker[player] then destroyElement(marker[player]) end if playerobj[player] then destroyElement(playerobj[player]) end playerobj[player] = nil outputChatBox ( "Map cleared.", player ) else outputChatBox ( "You do not have permission to build.", player ) end end addCommandHandler( "mclear", clearObjects ) function makejump (player) do mdestroy do mcreate 1655 do rz -130 end addCommandHandler( "mjump", makejump ) Link to comment
Metall Posted May 30, 2013 Share Posted May 30, 2013 Well if i get it right you can do it like this: addCommandHandler("cmd", function) addCommandHandler("cmd", function) Multiple times for different functions. Link to comment
BieHDC Posted May 30, 2013 Author Share Posted May 30, 2013 Would that look like: function makejump (player) addCommandHandler("cmd", mdestroy) addCommandHandler("cmd", mcreate 1655) addCommandHandler("cmd", rz -130) end addCommandHandler( "mjump", makejump ) Does it execute command "mdestroy" and then "mcreate 1655 ..... It schould execute the commands like i type in in F8 Command Panel Link to comment
Metall Posted May 30, 2013 Share Posted May 30, 2013 function commandPanel(plr) executeCommandHandler("yourCommand1", plr) executeCommandHandler("yourCommand2", plr) end addCommandHandler("commandpanel", commandPanel) ? Link to comment
BieHDC Posted May 30, 2013 Author Share Posted May 30, 2013 Would it look like this? function makejump(plr) executeCommandHandler("mdestroy", plr) executeCommandHandler("mcreate 1655", plr) executeCommandHandler("rz -130", plr) end addCommandHandler("mjump", makejump) Link to comment
Metall Posted May 30, 2013 Share Posted May 30, 2013 Well, if the commandHandler you made has a "-" in it, then yes. Like if your command handler under your function is: addCommandHandler("staff", function) Then it's executeCommandHandler("staff", localPlayer) Link to comment
Moderators IIYAMA Posted May 30, 2013 Moderators Share Posted May 30, 2013 (edited) function makejump(plr) executeCommandHandler("mdestroy", plr) executeCommandHandler("mcreate", plr,1655) executeCommandHandler("rz", plr,-130) end addCommandHandler("mjump", makejump) Edited May 30, 2013 by Guest Link to comment
BieHDC Posted May 30, 2013 Author Share Posted May 30, 2013 i dont know what that means i should be only like executeing in F8 or / command in chat Link to comment
Moderators IIYAMA Posted May 30, 2013 Moderators Share Posted May 30, 2013 updatd What don't you know? Link to comment
BieHDC Posted May 30, 2013 Author Share Posted May 30, 2013 (edited) ok clear^^ i will try i get acsess deneded but i am admin on my server. Has the script to run as admin? Edited May 30, 2013 by Guest Link to comment
Moderators IIYAMA Posted May 30, 2013 Moderators Share Posted May 30, 2013 It depends what the script request. If the script needs to kick a player or remove a file. Yes then it needs admin rights. If the script gives an error like that, it is missing his rights. resource.NAME Link to comment
BieHDC Posted May 30, 2013 Author Share Posted May 30, 2013 ok i will give the script admin rights Link to comment
BieHDC Posted May 30, 2013 Author Share Posted May 30, 2013 Now i get this: WARNING: [gamem.....\offedit.lua:185: Bad argument @ ´executeCom..ler´[Expected element at argument 2, got number ´1655´] some for line 186 with -130 So the numbers are not translated sucsessfully? Link to comment
Moderators IIYAMA Posted May 30, 2013 Moderators Share Posted May 30, 2013 function makejump(plr) executeCommandHandler("mdestroy", plr) executeCommandHandler("mcreate", plr,1655) executeCommandHandler("rz", plr,-130) end addCommandHandler("mjump", makejump) Link to comment
BieHDC Posted May 30, 2013 Author Share Posted May 30, 2013 Works perfect thank you very much Link to comment
Moderators IIYAMA Posted May 30, 2013 Moderators Share Posted May 30, 2013 np. good luck with it. Link to comment
ZPC2THLgate Posted June 13, 2013 Share Posted June 13, 2013 Are you sure that it saved the way I gave you? __________________________________________________________ Zopo smart phone ZOPO ZP810 ZOPO ZP300+ 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