I’m writing this topic because I’m in trouble …
I tried to script the same thing as the “basic scripting” wiki, so I made a copy/paste just to see what it does.
So after that I launch my server which tell me that it started the resource “vehicle”. To this point everything looks like it’s going the right way but after when I try to do some commands in game like “/vehicle” to make a vehicle appear, nothing appears and my server doesn’t say the error message …
Maybe it is a problem with the locations of client.lua and server.lua which are in my script folder for now …
Thanks for help guys
See ya’
Here is the client.lua
RegisterNetEvent(“createCarAtPlayerPos”)
AddEventHandler(‘createCarAtPlayerPos’, function(message)
Citizen.CreateThread(function()
Citizen.Wait(50)
local carid = GetHashKey(message)
local playerPed = GetPlayerPed(-1)
if playerPed and playerPed ~= -1 then
RequestModel(carid)
while not HasModelLoaded(carid) do
Citizen.Wait(0)
end
local playerCoords = GetEntityCoords(playerPed)
playerCoords = playerCoords + vector3(0, 2, 0)
local car = CreateVehicle(carid, playerCoords, 0.0, true, false)
TaskWarpPedIntoVehicle(playerPed, car, -1)
TriggerEvent('chatMessage', 'SYSTEM', {0, 255, 0}, "Vehicle spawned.")
end
end)
end)
and the server.lua
RegisterServerEvent(“chatCommandEntered”)
AddEventHandler(‘chatCommandEntered’, function(fullcommand)
command = stringsplit(fullcommand, " ")
if(command[1] == "/vehicle") then
TriggerClientEvent("createCarAtPlayerPos", source, command[2])
end
end)
function stringsplit(self, delimiter)
local a = self:Split(delimiter)
local t = {}
Go into your FiveReborn Server/resources/initial folder and check if you have the __resource.lua - If not, create one and add "server_script ‘net_init.lua’ to it and your commands should work.