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