Jump to content

Początkowe problemy


Recommended Posts

Posted

Cześć wszystkim, zaczynam się bawić z LUA, robie wszystko zgodnie z poradnikiem na wiki i za żadne grzechy komenda nie działa:

function joinHandler() 
        local x = 1939.55 
        local y = -1714.46 
        local z = 15 
        spawnPlayer(source, x, y, z) 
        fadeCamera(source, true) 
        setCameraTarget(source, source) 
        outputChatBox("Witaj na moim serwerze!", source) 
end 
addEventHandler("onPlayerJoin", getRootElement(), joinHandler) 
  
function createVehicleForPlayer(thePlayer, command, vehicleModel) 
        local x,y,z getElementPosition(thePlayer) 
        x = x + 5 
        local createdVehicle(tonumber(vehicleModel),x,y,z) 
end 
  
addCommandHandler("v", createVehicleForPlayer) 
createVehicleForPlayer(thePlayer,"v","468")  
  

Co robię źle? :P

Posted

Po pierwsze używaj tagów [lua][/lua] jak cos wstawiasz na forum

po drugie

function createVehicleForPlayer(thePlayer, command, vehicleModel) 
        local x,y,z = getElementPosition(thePlayer) 
        createVehicle ( tonumber(vehicleModel), x, y, z + 10 ) 
end 
  
addCommandHandler("v", createVehicleForPlayer) 
createVehicleForPlayer(thePlayer,"v","468") 

i teraz tak zawsze po "local argument" dajesz "=" przykład local asdf = ciastko(thePlayer)

przy używaniu funkcji typu createVehicle musisz sprawdzic czy jest client czy server side, poczytaj trochę

https://wiki.multitheftauto.com/wiki/Scr ... troduction

Posted

Kod jest zdecydowanie po stronie serwera, widać to po nazwach eventów.

Wszystko co podałeś wydaje się być prawidłowe (chociaż kilka rzeczy można by napisać krócej), oprócz ostatniej linijki, która nie będzie działać, gdyż 1. zmienne thePlayer jest nieznana, 2. ta linia nie powinna znajdować się w tym miejscu. Niemniej jednak sam spawn gracza i komenda /v powinna działać.

Z czym konkretnie masz problem?

Posted
local x,y,z getElementPosition(thePlayer) 

@Wielebny: Nie wszystko jest poprawne, np. ten syntax error ;)

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

  • 1 month later...
Posted

Mefisto_PL podał Ci poprawiony kod przecież.

BTW: minął ponad miesiąc o.O

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...