Jump to content

aymeness81

Members
  • Posts

    34
  • Joined

  • Last visited

Everything posted by aymeness81

  1. Hi guys, I have a problem in my resource of car spawner that i made, i hit the marker and it shows the gui of the list of the cars then it work normally, but when i click 2 times on another thing it respawn the previous car . thanks Server Side: markerp = createMarker( 1556.9852294922, -1608.1356201172, 12.3828125, "cylinder", 2, 0, 0, 255, 255 ) marker2p = createMarker( 1570.1909179688, -1610.1462402344, 12.3828125, "cylinder", 2, 0, 0, 255, 255 ) marker3p = createMarker( 1584.61328125, -1608.2557373047, 12.3828125, "cylinder", 2, 0, 0, 255, 255 ) marker4p = createMarker( 1595.1407470703, -1607.5220947266, 12.3828125, "cylinder", 2, 0, 0, 255, 255 ) local vehicles = {} function spawnVehP(id) local team = getPlayerTeam(source) local theTeamName = getTeamName(team) if ( theTeamName == "Police" ) or ( theTeamName == "FBI" ) then local x, y, z = getElementPosition(source) if isElement(vehicles[source]) then destroyElement(vehicles[source]) end vehicles[source] = createVehicle(id, x + 1, y, z) warpPedIntoVehicle(source, vehicles[source]) else outputChatBox("Only police agents and FBI can get free vehicles from here!", source, 255, 0, 0) end end addEvent("CreVehiceP",true) addEventHandler("CreVehiceP", root, spawnVehP) addEventHandler("onPlayerQuit", root, function() if isElement(vehicles[source]) then destroyElement(vehicles[source]) vehicles[source] = nil end end) function showGUIp(hitPlayer) setElementFrozen(source, true) triggerClientEvent (hitPlayer,"showGUI6p",getRootElement(),hitPlayer) end addEventHandler("onMarkerHit",markerp,showGUIp) function showGUIp(hitPlayer) setElementFrozen(source, true) triggerClientEvent (hitPlayer,"showGUI6p",getRootElement(),hitPlayer) end addEventHandler("onMarkerHit",marker2p,showGUIp) function showGUIp(hitPlayer) setElementFrozen(source, true) triggerClientEvent (hitPlayer,"showGUI6p",getRootElement(),hitPlayer) end addEventHandler("onMarkerHit",marker3p,showGUIp) function showGUIp(hitPlayer) setElementFrozen(source, true) triggerClientEvent (hitPlayer,"showGUI6p",getRootElement(),hitPlayer) end addEventHandler("onMarkerHit",marker4p,showGUIp) Client Side: Wnd = guiCreateWindow ( 0.2, 0.2, 0.25, 0.5, "Police Vehicles", true ) guiSetAlpha( Wnd, 1 ) button = guiCreateButton ( 0.01, 0.8, 0.99, 0.15, "Close", true, Wnd ) label = guiCreateLabel ( 0.1, 0.1, 0.9, 0.1, "Double Click Vehicle to take it.", true, Wnd ) showCursor(false) guiSetVisible( Wnd, false ) guiWindowSetSizable( Wnd, false ) guiWindowSetMovable( Wnd, false ) vehicles = { {"HPV1000", 523}, {"Police LS", 596}, {"Police LV", 598}, {"Police Ranger", 599}, } grid = guiCreateGridList(0.01, 0.2, 0.99, 0.5, true, Wnd) guiGridListAddColumn(grid, "Vehicles", 0.85) for i,veh in ipairs(vehicles) do row = guiGridListAddRow(grid) -- guiGridListSetItemText(grid, row, 1, tostring(veh[1]), false, false) guiGridListSetItemData(grid, row, 1, tostring(veh[2])) end function use() local row, col = guiGridListGetSelectedItem(grid) if (row and col and row ~= -1 and col ~= -1) then local model = tonumber(guiGridListGetItemData(grid, row, 1)) if model ~= "" then triggerServerEvent("CreVehiceP", localPlayer, model) end end end addEventHandler("onClientDoubleClick", root, use, false) function close() if (source == button) then guiSetVisible(Wnd,false) showCursor(false) end end addEventHandler("onClientGUIClick", button, close) function showGUI6p() guiSetVisible(Wnd,true) showCursor(true) end addEvent("showGUI6p",true) addEventHandler("showGUI6p", getRootElement(), showGUI6p)
  2. I Failed copying to community but my file is correct
  3. I need help, Im noob at scripting.. , Help me please TAPL.
  4. function createMyVehicle(vehicleid,x,y,z) -- check all the arguments exist if vehicleid and x and y and z then createVehicle(vehicleid,x,y,z) end end addEvent("createVehicleFromGUI",true) addEventHandler("createVehicleFromGUI",root,createMyVehicle)
  5. When I join the marker , it shows for me the gui, when I press on spawn , nothing hapened..
  6. ocal vehicles = {"Police LS", "Police LV", "Police Ranger", "Police SF", "Cheetah"} local bikes = createMarker(1545.62, -1610.17, 12.38, 'cylinder', 2, 0, 0, 255, 255) function createVehGui () MainGui = guiCreateWindow(408,203,240,349,"Vehicle",false) VehGrid = guiCreateGridList(17,32,200,256,false,MainGui) guiGridListSetSelectionMode(VehGrid,2) _bikes = guiGridListAddColumn(VehGrid,"Vehicle name:",0.85) Spawn = guiCreateButton(15,305,96,35,"Use",false,MainGui) guiSetFont(Spawn,"clear-normal") Cancel = guiCreateButton(128,305,96,35,"Close",false,MainGui) guiSetFont(Cancel,"clear-normal") for index, vehicle in ipairs(vehicles) do local row = guiGridListAddRow (VehGrid) guiGridListSetItemText ( VehGrid, row, _bikes, tostring(vehicle), false, false ) end end addEventHandler("onClientMarkerHit", bikes, function ( hitElement ) if (hitElement == localPlayer) then createVehGui ( hitElement ) if (MainGui ~= nil) then guiSetVisible(MainGui, true) showCursor(true) guiSetInputEnabled(true) else outputChatBox ("Error: Please Re-enter in the marker to get your vehicle.", 255, 0, 0) end end end ) addEventHandler("onClientGUIClick", root, function () if (source == Spawn) then guiSetVisible(MainGui, false) showCursor(false) guiSetInputEnabled(false) local row,col = guiGridListGetSelectedItem(VehGrid) if (row and col and row ~= -1 and col ~= -1) then local vehicleName = guiGridListGetItemText(VehGrid, row, 1) if vehicleName then triggerServerEvent("spawnBike",localPlayer,vehicleName) end else outputChatBox("Error: Please select a vehicle from the list.",255,0,0) end elseif (source == Cancel) then guiSetVisible(MainGui, false) showCursor(false) guiSetInputEnabled(false) end end ) addEventHandler("onClientPlayerWasted", root, function () guiSetVisible(MainGui, false) showCursor(false) guiSetInputEnabled(false) end)
  7. Please I need to make a script for Andromada, I want to set the back of the plane entrable with cars, so I want just to set interior for it . Please Help.
  8. Hre is The Server Side: local sql = { Query = executeSQLQuery }; addEventHandler( 'onResourceStart', resourceRoot, function() sql.Query( "CREATE TABLE IF NOT EXISTS house_data (\ ID INTEGER, en_X REAL, en_Y REAL, en_Z REAL,\ en_tX REAL, en_tY REAL, en_tZ REAL,\ ex_X REAL, ex_Y REAL, ex_Z REAL,\ ex_tX REAL, ex_tY REAL, ex_tZ REAL,\ int INTEGER, dim INTEGER, cost INTEGER, owner TEXT, key TEXT )" ); for i, v in ipairs( getElementsByType( 'player' ) ) do setElementData( v, 'k_len', tonumber( get( 'keyLength' ) ) ); local acc = getPlayerAccount( v ); if not isGuestAccount( acc ) then setElementData( v, 'HS_accountName', getAccountName( acc ) ); end; setElementData( v, 'mrk_in', nil ); end; local hr = sql.Query( "SELECT * FROM house_data" ); for i = 1, #hr do createHouse( false, hr.ID, hr.owner, hr.key, hr.en_X, hr.en_Y, hr.en_Z, hr.en_tX, hr.en_tY, hr.en_tZ, hr.ex_X, hr.ex_Y, hr.ex_Z, hr.ex_tX, hr.ex_tY, hr.ex_tZ, hr.int, hr.dim, hr.cost ); end; end ); addEventHandler( 'onResourceStop', resourceRoot, function() for i, v in ipairs( getElementsByType( 'player' ) ) do setElementData( v, 'k_len', nil ); setElementData( v, 'HS_accountName', nil ); end; end ); addEventHandler( 'onPlayerJoin', root, function() setElementData( source, 'k_len', tonumber( get( 'keyLength' ) ) ); end ); addEventHandler( 'onPlayerLogin', root, function( _, acc ) setElementData( source, 'HS_accountName', getAccountName( acc ) ); end ); addEventHandler( 'onPlayerLoout', root, function( _, acc ) setElementData( source, 'HS_accountName', nil ); end ); addCommandHandler( 'hpanel', function( player ) if isObjectInACLGroup( 'user.'..getAccountName( getPlayerAccount( player ) ), aclGetGroup( 'Admin' ) ) or hasObjectPermissionTo( player, 'function.banPlayer', false ) then if not getElementData( player, 'HP_Opened' ) and not getElementData( player, 'mrk_in' ) then triggerClientEvent( player, 'HP_SetVisible', root, true ); end; else outputChatBox( '* Access denied for this command!', player, 255, 36, 51 ); end; end ); addEvent( 'onPlayerAttemptCreateHouse', true ); addEventHandler( 'onPlayerAttemptCreateHouse', root, function( rt ) createHouse( true, #sql.Query( "SELECT * FROM house_data" ) + 1, '', '', unpack( rt ) ); outputChatBox( '* The new house has been created successfully!', client, 255, 255, 0 ); end ); function createHouse( add, ID, owner, key, eX, eY, eZ, etX, etY, etZ, exX, exY, exZ, extX, extY, extZ, int, dim, cost ) if add then sql.Query( "INSERT INTO house_data ( ID, en_X, en_Y, en_Z, en_tX, en_tY, en_tZ, ex_X, ex_Y, ex_Z, ex_tX, ex_tY, ex_tZ, int, dim, cost, owner, key ) VALUES ( "..ID..", "..eX..", "..eY..", "..eZ..", "..etX..", "..etY..", "..etZ..", "..exX..", "..exY..", "..exZ..", "..extX..", "..extY..", "..extZ..", "..int..", "..dim..", "..cost..", '', '' )" ); end; local m_Enter = createMarker( eX, eY, eZ - 1, 'cylinder', 1.25, 0, 153, 255, 150 ); setElementData( m_Enter, 'HS_INFO', { etX, etY, etZ, int, dim, cost, owner, key, ID } ); if getElementData( m_Enter, 'HS_INFO' )[7] ~= '' then setMarkerColor( m_Enter, 255, 51, 36, 150 ); end; addEventHandler( 'onMarkerHit', m_Enter, function( player ) if getElementType( player ) == 'player' and not getPedOccupiedVehicle( player ) then if not getElementData( player, 'HP_Opened' ) then if not isGuestAccount( getPlayerAccount( player ) ) then setElementData( player, 'mrk_in', getElementData( source, 'HS_INFO' )[9] ); onPlayerHouseMarkerHit( player, source, true ); setElementFrozen( player, true ); else outputChatBox( '* You must be logged in to get in this house!', player, 255, 51, 36 ); end; end; end; end ); addEventHandler( 'onMarkerLeave', m_Enter, function( player ) if getElementType( player ) == 'player' and not getPedOccupiedVehicle( player ) then setElementData( player, 'mrk_in', nil ); end; end ); local m_Exit = createMarker( exX, exY, exZ - 1, 'cylinder', 1.25, 0, 153, 255, 150 ); setElementData( m_Exit, 'parent', m_Enter ); setElementInterior( m_Exit, int ); setElementDimension( m_Exit, dim ); setElementData( m_Exit, 'extX', extX ); setElementData( m_Exit, 'extY', extY ); setElementData( m_Exit, 'extZ', extZ ); addEventHandler( 'onMarkerHit', m_Exit, function( player, dim ) if getElementType( player ) == 'player' and dim then toggleAllControls( player, false ); fadeCamera( player, false ); setTimer( function( player, mrk ) if getPedOccupiedVehicle( player ) then removePedFromVehicle( player ); end; local x, y, z = getElementData( mrk, 'extX' ), getElementData( mrk, 'extY' ), getElementData( mrk, 'extZ' ); setElementPosition( player, x, y, z ); setElementInterior( player, 0 ); setElementDimension( player, 0 ); toggleAllControls( player, true ); fadeCamera( player, true ); end, 1200, 1, player, source ); end; end ); end; function onPlayerHouseMarkerHit( player, mrk, cursor ) local acc = getPlayerAccount( player ); if isGuestAccount( acc ) then outputChatBox( '* You must be logged in to get in this house!', player, 255, 51, 36 ); setElementData( player, 'mrk_in', nil ); setElementFrozen( player, false ); return false; end; local tts = { [1] = true, [2] = false, [3] = false, [4] = true, [5] = false, [6] = false }; if isObjectInACLGroup( 'user.'..getAccountName( acc ), aclGetGroup( 'Admin' ) ) or hasObjectPermissionTo( player, 'function.banPlayer', false ) then tts[6] = true; end; local owner = getElementData( mrk, 'HS_INFO' )[7]; local accName = getAccountName( acc ); if owner == accName then tts[1] = false; tts[2] = true; tts[3] = true; tts[4] = true; tts[5] = true; end; if owner ~= accName and owner ~= '' then tts[1] = false; end; if owner == '' then if isObjectInACLGroup( 'user.'..getAccountName( acc ), aclGetGroup( 'Admin' ) ) or hasObjectPermissionTo( player, 'function.banPlayer', false ) then tts[4] = true; else tts[4] = false; end; end; tts[7] = getElementData( mrk, 'HS_INFO' )[9]; tts[8] = getElementData( mrk, 'HS_INFO' )[7]; tts[9] = getElementData( mrk, 'HS_INFO' )[6]; triggerClientEvent( player, 'openHouseManagementWnd', root, tts, cursor ); end; addEvent( 'HOUSE_Buy', true ); addEventHandler( 'HOUSE_Buy', root, function( cost, key ) local accName = getAccountName( getPlayerAccount( client ) ); local houseCounter = 0; for i, v in ipairs( getElementsByType( 'marker', getResourceRootElement() ) ) do if getElementData( v, 'HS_INFO' ) then local owner = getElementData( v, 'HS_INFO' )[7]; if owner == accName then houseCounter = houseCounter + 1; end; end; end; if houseCounter >= tonumber( get( 'playerHouseCounter' ) ) then outputChatBox( '* You can not buy more than #00FF00'..get( 'playerHouseCounter' )..' house(-s)#FF3324 at the same time!', client, 255, 51, 36, true ); setElementFrozen( client, false ); return false; end; if getPlayerMoney( client ) >= tonumber( cost ) then outputChatBox( '* Key has been set to #00FF00'..key, client, 255, 51, 36, true ); outputChatBox( '* Congratulations! You have bought a house!', client, 255, 255, 0 ); sql.Query( "UPDATE house_data SET owner = '"..accName.."', key = '"..key.."' WHERE ID = ?", getElementData( client, 'mrk_in' ) ); takePlayerMoney( client, cost ); local mrk = getHouseByID( getElementData( client, 'mrk_in' ) ); local t = {}; for i = 1, 6 do t = getElementData( mrk, 'HS_INFO' ); end; t[7] = accName; t[8] = key; t[9] = getElementData( client, 'mrk_in' ); setElementData( mrk, 'HS_INFO', { t[1], t[2], t[3], t[4], t[5], t[6], t[7], t[8], t[9] } ); setMarkerColor( mrk, 255, 51, 36, 150 ); setTimer( onPlayerHouseMarkerHit, 50, 1, client, mrk, true ); else outputChatBox( '* You do not have enough money!', client, 255, 51, 36 ); onPlayerHouseMarkerHit( client, getHouseByID( getElementData( client, 'mrk_in' ) ), true ); end; end ); addEvent( 'HOUSE_Sell', true ); addEventHandler( 'HOUSE_Sell', root, function() sql.Query( "UPDATE house_data SET owner = '', key = '' WHERE ID = ?", getElementData( client, 'mrk_in' ) ); local mrk = getHouseByID( getElementData( client, 'mrk_in' ) ); givePlayerMoney( client, getElementData( mrk, 'HS_INFO' )[6] / 2 ); local t = {}; for i = 1, 6 do t = getElementData( mrk, 'HS_INFO' ); end; t[7] = ''; t[8] = ''; t[9] = getElementData( client, 'mrk_in' ); setElementData( mrk, 'HS_INFO', { t[1], t[2], t[3], t[4], t[5], t[6], t[7], t[8], t[9] } ); setMarkerColor( mrk, 0, 153, 255, 150 ); setTimer( onPlayerHouseMarkerHit, 50, 1, client, mrk, false ); end ); addEvent( 'HOUSE_Enter', true ); addEventHandler( 'HOUSE_Enter', root, function() setElementFrozen( client, false ); local mrk = getHouseByID( getElementData( client, 'mrk_in' ) ); local t = {}; for i = 1, 5 do t = getElementData( mrk, 'HS_INFO' ); end; fadeCamera( client, false ); toggleAllControls( client, false ); setTimer( function( player, t ) if getPedOccupiedVehicle( player ) then removePedFromVehicle( player ); end; setElementInterior( player, t[4], t[1], t[2], t[3] ); setElementDimension( player, t[5] ); toggleAllControls( player, true ); fadeCamera( player, true ); setElementData( player, 'mrk_in', nil ) end, 1200, 1, client, t ); end ); addEvent( 'HOUSE_ChangeKey', true ); addEventHandler( 'HOUSE_ChangeKey', root, function( newKey ) local mrk = getHouseByID( getElementData( client, 'mrk_in' ) ); sql.Query( "UPDATE house_data SET key = '"..newKey.."' WHERE ID = ?", getElementData( client, 'mrk_in' ) ); local t = {}; for i = 1, 6 do t = getElementData( mrk, 'HS_INFO' ); end; t[7] = getAccountName( getPlayerAccount( client ) ); t[8] = newKey; t[9] = getElementData( client, 'mrk_in' ); setElementData( mrk, 'HS_INFO', { t[1], t[2], t[3], t[4], t[5], t[6], t[7], t[8], t[9] } ); end ); addEvent( 'HOUSE_ChangeOwner', true ); addEventHandler( 'HOUSE_ChangeOwner', root, function( name ) local mrk = getHouseByID( getElementData( client, 'mrk_in' ) ); local accName = getAccountName( getPlayerAccount( getPlayerFromName( name ) ) ); sql.Query( "UPDATE house_data SET owner = '"..accName.."' WHERE ID = ?", getElementData( client, 'mrk_in' ) ); local res = sql.Query( "SELECT key, owner FROM house_data WHERE ID = ?", getElementData( client, 'mrk_in' ) ); local t = {}; for i = 1, 6 do t = getElementData( mrk, 'HS_INFO' ); end; t[7] = res[1].owner; t[8] = res[1].key; t[9] = getElementData( client, 'mrk_in' ); setElementData( mrk, 'HS_INFO', { t[1], t[2], t[3], t[4], t[5], t[6], t[7], t[8], t[9] } ); setTimer( onPlayerHouseMarkerHit, 50, 1, client, mrk, false ); outputChatBox( '* #FFFF00'..getPlayerName( client )..'#00FF00 has given you his house!', getPlayerFromName( name ), 0, 255, 0, true ); end ); addEvent( 'HOUSE_Destroy', true ); addEventHandler( 'HOUSE_Destroy', root, function() local mrk = getHouseByID( getElementData( client, 'mrk_in' ) ); for ii, v in ipairs( getElementsByType( 'marker', getResourceRootElement() ) ) do if getElementData( v, 'parent' ) == mrk then destroyElement( v ); end; end; local hr = sql.Query( "SELECT * FROM house_data" ); for i = getElementData( source, 'mrk_in' ), #hr do if getHouseByID( i ) ~= mrk then sql.Query( "UPDATE house_data SET ID = "..( i - 1 ).." WHERE ID = ?", i ); local res = sql.Query( "SELECT owner, key FROM house_data WHERE ID = ?", i - 1 ); local nextMrk = getHouseByID( i ); local t = {}; for i = 1, 6 do t = getElementData( nextMrk, 'HS_INFO' ); end; t[7] = res[1].owner; t[8] = res[1].key; t[9] = i - 1; setElementData( nextMrk, 'HS_INFO', { t[1], t[2], t[3], t[4], t[5], t[6], t[7], t[8], t[9] } ); local player = getPlayerByHouseID( i - 1 ); setElementData( player, 'mrk_in', i - 1 ); else sql.Query( "DELETE FROM house_data WHERE ID = ?", i ); destroyElement( mrk ); end; end; outputChatBox( '* House #'..getElementData( source, 'mrk_in' )..' has been destroyed!', source, 255, 255, 0 ); setElementFrozen( source, false ); setElementData( source, 'mrk_in', nil ); end ); function getHouseByID( id ) for i, v in ipairs( getElementsByType( 'marker', getResourceRootElement() ) ) do if getElementData( v, 'HS_INFO' ) and getElementData( v, 'HS_INFO' )[9] == id then return v; end; end; return false; end; function getPlayerByHouseID( id ) for i, v in ipairs( getElementsByType( 'player' ) ) do if getElementData( v, 'mrk_in' ) == id then return v; end; end; return false; end; addEvent( 'setFrozen', true ); addEventHandler( 'setFrozen', root, function( state ) setElementFrozen( client, state ); end ); addEventHandler( 'onPlayerWasted', root, function() if getElementData( source, 'mrk_in' ) then setElementData( source, 'mrk_in', nil ); setElementFrozen( source, false ); end; end );
  9. I wanted to add house-system resource on my server , when i start the server on console error messages appears Here is a snap for error in Console:http://www.4shared.com/photo/jFbLhD2H/Error.html? Thanks for help
×
×
  • Create New...