Jump to content

script not working


Spajk

Recommended Posts

Hi, I am new to LUA and I tried to make a bit more complicated script and boom it's not working :)

Serverside code:

  
local LSMarker = createMarker( 1686.268, -2331.469, 14.132, "cylinder", 1.5, 255, 0, 0, 100) 
local SFMarker = createMarker( -1422.733, -288.374, 14.478, "cylinder", 1.5, 255, 0, 0, 100) 
local LVMarker = createMarker( 1674.72, 1447.909, 10.737, "cylinder", 1.5, 255, 0, 0, 100) 
  
function MarkerHit( hitElement, matchingDimension ) 
    if( getElementType( hitElement) == "player" and not isPedInVehicle( hitElement) ) then 
        local city 
        if( source == LSMarker) then 
            city = 1 
        else if ( source == SFMarker) then 
            city = 2 
        else if ( source == LVMarker) then 
            city = 3 
        else 
            return 
        end 
  
        if( getPlayerWantedLevel( hitElement) > 0 ) then 
            outputChatBox( "Airport security stoped you!", hitElement, 255, 0, 0)            
            return 
        end 
        triggerClientEvent( "OnClientEnterAirport", hitElement, city ) 
    end 
end 
addEventHandler( "onMarkerHit", getRootElement(), MarkerHit) 
  

Clientside code:

  
local GUI_window = guiCreateWindow(300,146,230,267,"SPAJK AIR",false) 
  
local GUI_grid = guiCreateGridList(13,35,203,195,false,GUI_window) 
guiGridListSetSelectionMode(GUI_grid,0) 
guiGridListAddColumn(GUI_grid,"Airports:",0.2) 
  
local LSR = guiGridListAddRow(GUI_grid) 
local LVR = guiGridListAddRow(GUI_grid) 
local SFR = guiGridListAddRow(GUI_grid) 
  
guiGridListSetItemText(GUI_grid,0,1,"Los Santos") 
guiGridListSetItemText(GUI_grid,1,1,"Las Venturas") 
guiGridListSetItemText(GUI_grid,2,1,"San Fierro") 
  
local GUI_label = guiCreateLabel(10,154,185,31,"ALL FLIGHTS COST $2000",false,GUI_window) 
guiLabelSetColor(GUI_label,255,0,0) 
guiLabelSetVerticalAlign(GUI_label,"center") 
guiLabelSetHorizontalAlign(GUI_label,"center",false) 
  
GUI_button1 = guiCreateButton(11,238,87,20,"Fly",false,GUI_window) 
GUI_button2 = guiCreateButton(131,238,87,20,"Close",false,GUI_window) 
  
addEvent( "OnClientEnterAirport", true) 
  
function Enter(city) 
    guiSetVisible( GUI_window, true) 
    if( city == 1 ) then 
        guiSetVisible( LSR, false) 
    elseif( city == 2 ) then 
        guiSetVisible( SFR, false) 
    elseif( city == 3 ) then 
        guiSetVisible( LVR, false) 
    end 
    showCursor(true) 
end 
  
addEventHandler( "OnClientEnterAirport", getRootElement(), Enter) 
  
function Click(button,state) 
    if( button == "left" and state == "down" ) then 
        if( source == GUI_button1 ) 
            if( getPlayerMoney()<2000 ) then 
                OutputChatBox("You don't have enough money for this flight!",255,0,0) 
            else 
                local city = guiGridListGetSelectedItem(GUI_grid) 
                playSound("landing.mp3") 
                SetTimer(GoGoGo,5000,1,city) 
                fadeCamera( true, 1.0) 
                if( city == 1 ) 
                    setCameraMatrix(1846.63671875, -2319.6220703125, 56.055404663086, 1898.8486328125, -2428.48046875, 17.950902938843) 
                elseif( city == 2 ) 
                    setCameraMatrix(-1303.6181640625, 150.23046875, 102.18531799316, -1354.0478515625, -10.3310546875, 39.475650787354) 
                elseif( city == 3 ) 
                    setCameraMatrix(1656.625, 1672.4169921875, 46.536811828613, 1641.220703125, 1646.908203125, 39.581771850586) 
                end 
                showPlayerHudComponent("all", false ) 
                ShowCursor(false) 
            end 
        elseif( source == GUI_button2 ) 
            guiSetVisible(GUI_window,false) 
            ShowCursor(false) 
        end 
    end 
end 
function GoGoGo(city) 
    fadeCamera( true, 1.0) 
    setCameraTarget( getLocalPlayer()) 
    if( city == 1 ) 
        setElementPosition ( getLocalPlayer(), 1686.154296875, -2327.875, 13.948606491089 ) 
    elseif( city == 2 ) 
        setElementPosition ( getLocalPlayer(), -1424.5205078125, -290.970703125, 14.650023460388 ) 
    elseif( city == 3 ) 
        setElementPosition ( getLocalPlayer(), 1690.9189453125, 1448.125, 10.736848831177 ) 
    end 
    guiSetVisible(GUI_window,false) 
    ShowCursor(false) 
    takePlayerMoney(2000) 
end 
addEventHandler( "onClientGUIClick", getRootElement(), Click ) 
  

there's some error outputed to console, but Idk how to fix it

Link to comment
  
local LSMarker = createMarker( 1686.268, -2331.469, 14.132, "cylinder", 1.5, 255, 0, 0, 100) 
local SFMarker = createMarker( -1422.733, -288.374, 14.478, "cylinder", 1.5, 255, 0, 0, 100) 
local LVMarker = createMarker( 1674.72, 1447.909, 10.737, "cylinder", 1.5, 255, 0, 0, 100) 
  
function MarkerHit( hitElement, matchingDimension ) 
    if( getElementType( hitElement) == "player" and not isPedInVehicle( hitElement) ) then 
        local city 
        if( source == LSMarker) then 
            city = 1 
        elseif ( source == SFMarker) then 
            city = 2 
        elseif ( source == LVMarker) then 
            city = 3 
        else 
            return 
        end 
  
        if( getPlayerWantedLevel( hitElement) > 0 ) then 
            outputChatBox( "Airport security stoped you!", hitElement, 255, 0, 0)           
            return 
        end 
        triggerClientEvent( "OnClientEnterAirport", hitElement, city ) 
    end 
end 
addEventHandler( "onMarkerHit", getRootElement(), MarkerHit) 
  

  
local GUI_window = guiCreateWindow(300,146,230,267,"SPAJK AIR",false) 
  
local GUI_grid = guiCreateGridList(13,35,203,195,false,GUI_window) 
guiGridListSetSelectionMode(GUI_grid,0) 
guiGridListAddColumn(GUI_grid,"Airports:",0.2) 
  
local LSR = guiGridListAddRow(GUI_grid) 
local LVR = guiGridListAddRow(GUI_grid) 
local SFR = guiGridListAddRow(GUI_grid) 
  
guiGridListSetItemText(GUI_grid,0,1,"Los Santos") 
guiGridListSetItemText(GUI_grid,1,1,"Las Venturas") 
guiGridListSetItemText(GUI_grid,2,1,"San Fierro") 
  
local GUI_label = guiCreateLabel(10,154,185,31,"ALL FLIGHTS COST $2000",false,GUI_window) 
guiLabelSetColor(GUI_label,255,0,0) 
guiLabelSetVerticalAlign(GUI_label,"center") 
guiLabelSetHorizontalAlign(GUI_label,"center",false) 
  
GUI_button1 = guiCreateButton(11,238,87,20,"Fly",false,GUI_window) 
GUI_button2 = guiCreateButton(131,238,87,20,"Close",false,GUI_window) 
  
addEvent( "OnClientEnterAirport", true) 
  
function Enter(city) 
    guiSetVisible( GUI_window, true) 
    if( city == 1 ) then 
        guiSetVisible( LSR, false) 
    elseif( city == 2 ) then 
        guiSetVisible( SFR, false) 
    elseif( city == 3 ) then 
        guiSetVisible( LVR, false) 
    end 
    showCursor(true) 
end 
  
addEventHandler( "OnClientEnterAirport", getRootElement(), Enter) 
  
function Click(button,state) 
    if( button == "left" and state == "down" ) then 
        if( source == GUI_button1 ) 
            if( getPlayerMoney()<2000 ) then 
                outputChatBox("You don't have enough money for this flight!",255,0,0) 
            else 
                local city = guiGridListGetSelectedItem(GUI_grid) 
                playSound("landing.mp3") 
                setTimer(GoGoGo,5000,1,city) 
                fadeCamera( true, 1.0) 
                if( city == 1 ) 
                    setCameraMatrix(1846.63671875, -2319.6220703125, 56.055404663086, 1898.8486328125, -2428.48046875, 17.950902938843) 
                elseif( city == 2 ) 
                    setCameraMatrix(-1303.6181640625, 150.23046875, 102.18531799316, -1354.0478515625, -10.3310546875, 39.475650787354) 
                elseif( city == 3 ) 
                    setCameraMatrix(1656.625, 1672.4169921875, 46.536811828613, 1641.220703125, 1646.908203125, 39.581771850586) 
                end 
                showPlayerHudComponent("all", false ) 
                showCursor(false) 
            end 
        elseif( source == GUI_button2 ) 
            guiSetVisible(GUI_window,false) 
            showCursor(false) 
        end 
    end 
end 
function GoGoGo(city) 
    fadeCamera( true, 1.0) 
    setCameraTarget( getLocalPlayer()) 
    if( city == 1 ) 
        setElementPosition ( getLocalPlayer(), 1686.154296875, -2327.875, 13.948606491089 ) 
    elseif( city == 2 ) 
        setElementPosition ( getLocalPlayer(), -1424.5205078125, -290.970703125, 14.650023460388 ) 
    elseif( city == 3 ) 
        setElementPosition ( getLocalPlayer(), 1690.9189453125, 1448.125, 10.736848831177 ) 
    end 
    guiSetVisible(GUI_window,false) 
    showCursor(false) 
    takePlayerMoney(2000) 
end 
addEventHandler( "onClientGUIClick", getRootElement(), Click ) 
  

You had a lot of functions starting with a capital, like ShowCursor and OutputChatBox, should be showCursor and outputChatBox.

Also it's elseif not else if.

Link to comment

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