Jump to content

help


golanu21

Recommended Posts

Posted
function onPlayerCreateVehicle_Handler(source, cmd, ...) 
local message = table.concat({...}, " ") 
local messageParameters = split(message, " ") 
    if(string.match(tostring( messageParameters[1] ), "[0-9]")) then-- Check if first parameter are numbers, if so, continue checking. 
        if(not string.match(messageParameters[2], "[0-9]")) then -- Check if second parameter consist only of letters. If so, continue checking. 
                if(string.match(messageParameters[3], "[0-9]")) then -- Check if third parameter are numbers, if so, create vehicle. 
                    local playerX, playerY, playerZ = getElementPosition(source) 
                    local newVehicle = createVehicle(tonumber(messageParameters[1]), playerX, playerY-5, playerZ, 0, 0, 0, messageParameters[2]) 
                    local vehMarker = createMarker(playerX, playerY-5, playerZ-2, "cylinder", 5, 255, 0, 0, 100) 
                        setVehicleLocked(newVehicle, true) 
                    setElementData(source, "marker", vehMarker)  
                else 
                    outputChatBox("[server]: #FF0000/makeveh(Syntax Error!)#1, invalid Key ID! Must consist of numbers!", getRootElement(), 145, 145, 145, true) 
                end 
        else 
            outputChatBox("[server]: #FF0000/makeveh(Syntax Error!)#2, invalid License Plate Text! No numbers allowed!", getRootElement(), 145, 145, 145, true) 
        end 
    else 
        outputChatBox("[server]: #FF0000/makeveh(Syntax Error!)#3, incorrect Car ID!", getRootElement(), 145, 145, 145, true) 
    end 
end 
addCommandHandler("makeveh", onPlayerCreateVehicle_Handler, false) 
  
addEventHandler("onMarkerHit", vehMarker, 
function (hitPlayer, matchingDimension, cmd, vehMarker, ...) 
    if hitPlayer == source then 
        getElementData(source, "vehMarker") 
        outputChatBox("DA DA DA", source, 255, 255 ,255) 
    end 
end) 

ss\server.lua:24: Bad argument @ 'addEventHandler' [Expected element at argument 2, got nil] 

Posted

Found your problem!

local vehMarker = createMarker(playerX, playerY-5, playerZ-2, "cylinder", 5, 255, 0, 0, 100) -- line 9 

Also, predefine the marker;

local vehMarker; -- line 1 

beside that, you know the source of onMarkerHit is the marker that's being hit? Not the player thats walking in. Thats the hitElement.

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...