[LUA]What is wrong with this script?

Snagg

Участник
Автор темы
25
7
Lua:
script_name('kicker')
--script_author('')
script_version('0.1')

local sampev = require 'lib.samp.events'

function main()
while not isSampAvailable() do wait(100) return end
sampRegisterChatCommand("hkick", hkick)
wait(-1)
end

function hkick(playerID, vehID)
if tonumber(playerID, vehID) then
    local result, pHandle = sampGetCharHandleBySampPlayerId(playerID)
    if result then
     local res = doesCharExist(pHandle)
   if res then
      local carResult, vehHandle = sampGetCarHandleBySampVehicleId(vehID)
        local vehExist = isCarOnScreen(vehHandle)
        if vehExist then
            targX, targY, targZ = getCharCoordinates(pHandle)
            setCarCollision(vehHandle, 1)
            sampForceTrailerSync(vehID)
        else
             sampAddChatMessage("Vehicle is not in the stream zone!", -1)
        end
    else
     sampAddChatMessage("Player is not in the stream zone!", -1)
 end
end
else
    sampAddChatMessage("Enter values!", -1)
end
end

function sampev.onSendTrailerSync(data)
data.position.x = targX
data.position.y = targY
data.position.z = targZ
end
 

astynk

Известный
Проверенный
742
530
Line 8: no need for return.
Line 13: Command handlers always get one argument. You need to parse it: playerID, vehID = arg:match('(%d+)%s+(%d+)')
Line 14: It should be tonumber(playerID) and tonumber(vehID)
Line 20: This function checks if the car is in sight (not behind a wall etc). You need to use doesVehicleExist to check if the car is streamed in.
 
  • Нравится
Реакции: Snagg