R1ddl3 Posted December 26, 2022 Posted December 26, 2022 I am new in MTA scripting. Created first resource. It's meta: <meta> <script src="vehicle.lua" type="server"/> <script src="myClient.lua" type="client"/> </meta> Vehicle.lua is working, it's content: function createVehicleForPlayer(thePlayer, command, vehicleModel) local x,y,z = getElementPosition(thePlayer) -- get the position of the player x = x + 5 -- add 5 units to the x position local createdVehicle = createVehicle(tonumber(vehicleModel),x,y,z) -- check if the return value was ''false'' if (createdVehicle == false) then -- if so, output a message to the chatbox, but only to this player. outputChatBox("Failed to create vehicle.",thePlayer) end end addCommandHandler("createvehicle", createVehicleForPlayer) myClient.lua is not working at all, content: function escapeMe ( commandName ) local x, y, z = getElementPosition ( localPlayer ) --Get player's position setElementPosition ( localPlayer, x+(math.random(-10,10)), y+(math.random(-10,10)), z+(math.random(1,15)) ) --Move a player randomly to a nearby location. X is current x + a number between -10, 10 and so on. end addCommandHandler ( "escape", escapeMe ) --When player types "/escape" in chatbox or "escape" in console I took this code from example from here https://wiki.multitheftauto.com/wiki/AddCommandHandler I have completely no idea why client side script is not working at all. I tried different this and nothing works. MTASA v1.5.9 server
Shady1 Posted December 26, 2022 Posted December 26, 2022 1 hour ago, R1ddl3 said: I am new in MTA scripting. Created first resource. It's meta: <meta> <script src="vehicle.lua" type="server"/> <script src="myClient.lua" type="client"/> </meta> Vehicle.lua is working, it's content: function createVehicleForPlayer(thePlayer, command, vehicleModel) local x,y,z = getElementPosition(thePlayer) -- get the position of the player x = x + 5 -- add 5 units to the x position local createdVehicle = createVehicle(tonumber(vehicleModel),x,y,z) -- check if the return value was ''false'' if (createdVehicle == false) then -- if so, output a message to the chatbox, but only to this player. outputChatBox("Failed to create vehicle.",thePlayer) end end addCommandHandler("createvehicle", createVehicleForPlayer) myClient.lua is not working at all, content: function escapeMe ( commandName ) local x, y, z = getElementPosition ( localPlayer ) --Get player's position setElementPosition ( localPlayer, x+(math.random(-10,10)), y+(math.random(-10,10)), z+(math.random(1,15)) ) --Move a player randomly to a nearby location. X is current x + a number between -10, 10 and so on. end addCommandHandler ( "escape", escapeMe ) --When player types "/escape" in chatbox or "escape" in console I took this code from example from here https://wiki.multitheftauto.com/wiki/AddCommandHandler I have completely no idea why client side script is not working at all. I tried different this and nothing works. MTASA v1.5.9 server hello welcome to the forum, i tested your code but there is no problem, can you tell me exactly what problem you are having
R1ddl3 Posted December 26, 2022 Author Posted December 26, 2022 Just now, Shady1 said: hello welcome to the forum, i tested your code but there is no problem, can you tell me exactly what problem you are having Oh maybe something wrong outside the code. I run mta server, I join my local server and only server side script works. I will try to find a solution. Will post if I find.
Shady1 Posted December 26, 2022 Posted December 26, 2022 (edited) 2 minutes ago, R1ddl3 said: Oh maybe something wrong outside the code. I run mta server, I join my local server and only server side script works. I will try to find a solution. Will post if I find. try "refreshall" Edited December 26, 2022 by Shady1
R1ddl3 Posted December 26, 2022 Author Posted December 26, 2022 Ok, solved. Maybe it is stupid what I did. I added such line in mtaserver.conf: <resource src="hydra_script" startup="1" protected="0" /> Now it works. Maybe I am a person who didn't read all tutorials, sorry. But without this line server-side script was working and I was expecting client-side should also work. Anywany thanks for help!
Shady1 Posted December 26, 2022 Posted December 26, 2022 6 minutes ago, R1ddl3 said: Ok, solved. Maybe it is stupid what I did. I added such line in mtaserver.conf: <resource src="hydra_script" startup="1" protected="0" /> Now it works. Maybe I am a person who didn't read all tutorials, sorry. But without this line server-side script was working and I was expecting client-side should also work. Anywany thanks for help! I'm glad if your problem is fixed, if you liked my comment you can like my comment have a nice day 1
Human Resources Staff Vinyard Posted December 27, 2022 Human Resources Staff Posted December 27, 2022 Closing this as the issue has been resolved.
Recommended Posts